Add vintage lamp and improve backend
This commit is contained in:
parent
9758a0ad31
commit
37e3a8c2db
30 changed files with 300 additions and 72 deletions
|
@ -9,34 +9,21 @@ import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
|||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CandleBlock;
|
||||
import net.minecraft.data.client.BlockStateModelGenerator;
|
||||
import net.minecraft.data.client.ItemModelGenerator;
|
||||
import net.minecraft.data.server.recipe.RecipeJsonProvider;
|
||||
import net.minecraft.data.server.recipe.RecipeProvider;
|
||||
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
|
||||
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.condition.BlockStatePropertyLootCondition;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.entry.LootPoolEntry;
|
||||
import net.minecraft.loot.function.ExplosionDecayLootFunction;
|
||||
import net.minecraft.loot.function.LootFunctionConsumingBuilder;
|
||||
import net.minecraft.loot.function.SetCountLootFunction;
|
||||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||
import net.minecraft.predicate.StatePredicate;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Util;
|
||||
import su.a71.new_soviet.blocks.CheckerBlock;
|
||||
import su.a71.new_soviet.registration.NSE_Blocks;
|
||||
import su.a71.new_soviet.registration.NSE_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
@ -239,7 +226,8 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
addDrop(NSE_Custom.BROWN_TV);
|
||||
addDrop(NSE_Custom.RADIO_RECEIVER);
|
||||
addDrop(NSE_Custom.SIREN);
|
||||
addDrop(NSE_Custom.LAMP);
|
||||
addDrop(NSE_Custom.TABLE_LAMP);
|
||||
addDrop(NSE_Custom.VINTAGE_LAMP);
|
||||
addDrop(NSE_Custom.CEILING_FAN);
|
||||
addDrop(NSE_Custom.SWITCH);
|
||||
|
||||
|
@ -971,7 +959,7 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
.offerTo(exporter);
|
||||
}
|
||||
|
||||
private void lampRecipe(Consumer<RecipeJsonProvider> exporter, ItemConvertible output) {
|
||||
private void tableLampRecipe(Consumer<RecipeJsonProvider> exporter, ItemConvertible output) {
|
||||
ShapedRecipeJsonBuilder.create(RecipeCategory.DECORATIONS, output, 3)
|
||||
.pattern("WWW")
|
||||
.pattern("WTW")
|
||||
|
@ -979,13 +967,30 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
|
||||
.input('S', Items.STICK)
|
||||
.input('T', Items.TORCH)
|
||||
.input('W', Items.WHITE_WOOL)
|
||||
.input('W', ItemTags.WOOL)
|
||||
.criterion(RecipeProvider.hasItem(Items.TORCH),
|
||||
RecipeProvider.conditionsFromItem(Items.TORCH))
|
||||
.criterion(RecipeProvider.hasItem(Items.STICK),
|
||||
RecipeProvider.conditionsFromItem(Items.STICK))
|
||||
.criterion(RecipeProvider.hasItem(Items.WHITE_WOOL),
|
||||
RecipeProvider.conditionsFromItem(Items.WHITE_WOOL))
|
||||
.criterion("has_wool", RecipeProvider.conditionsFromTag(ItemTags.WOOL))
|
||||
.offerTo(exporter);
|
||||
}
|
||||
|
||||
private void vintageLampRecipe(Consumer<RecipeJsonProvider> exporter, ItemConvertible output) {
|
||||
ShapedRecipeJsonBuilder.create(RecipeCategory.DECORATIONS, output, 3)
|
||||
.pattern("NNN")
|
||||
.pattern("GTG")
|
||||
.pattern(" N ")
|
||||
|
||||
.input('N', Items.IRON_NUGGET)
|
||||
.input('T', Items.TORCH)
|
||||
.input('G', Items.GREEN_STAINED_GLASS)
|
||||
.criterion(RecipeProvider.hasItem(Items.TORCH),
|
||||
RecipeProvider.conditionsFromItem(Items.TORCH))
|
||||
.criterion(RecipeProvider.hasItem(Items.IRON_NUGGET),
|
||||
RecipeProvider.conditionsFromItem(Items.IRON_NUGGET))
|
||||
.criterion(RecipeProvider.hasItem(Items.GREEN_STAINED_GLASS),
|
||||
RecipeProvider.conditionsFromItem(Items.GREEN_STAINED_GLASS))
|
||||
.offerTo(exporter);
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1047,8 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
tvRecipe(exporter, NSE_Custom.RED_TV, Items.RED_DYE);
|
||||
radioRecipe(exporter, NSE_Custom.RADIO_RECEIVER);
|
||||
ceilingFanRecipe(exporter, NSE_Custom.CEILING_FAN);
|
||||
lampRecipe(exporter, NSE_Custom.LAMP);
|
||||
tableLampRecipe(exporter, NSE_Custom.TABLE_LAMP);
|
||||
vintageLampRecipe(exporter, NSE_Custom.VINTAGE_LAMP);
|
||||
sickleRecipe(exporter, NSE_Items.SICKLE);
|
||||
rakeRecipe(exporter, NSE_Items.RAKE);
|
||||
|
||||
|
@ -1315,7 +1321,7 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, NSE_Blocks.CHISELED_SPRUCE_DOOR, Blocks.SPRUCE_DOOR);
|
||||
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, NSE_Blocks.CHISELED_BIRCH_DOOR, Blocks.BIRCH_DOOR);
|
||||
|
||||
ShapedRecipeJsonBuilder.create(RecipeCategory.DECORATIONS, NSE_Custom.LIGHT_BULB, 1)
|
||||
ShapedRecipeJsonBuilder.create(RecipeCategory.DECORATIONS, NSE_Custom.LIGHT_BULB_LAMP, 1)
|
||||
.input('X', Items.IRON_INGOT).input('Y', Items.IRON_NUGGET).input('Z', NSE_Items.LIGHT_BULB)
|
||||
.pattern(" X ").pattern(" Y ").pattern(" Z ")
|
||||
.criterion(hasItem(NSE_Items.LIGHT_BULB), conditionsFromItem(NSE_Items.LIGHT_BULB)).offerTo(exporter);
|
||||
|
@ -1493,7 +1499,6 @@ public class DataGeneration implements DataGeneratorEntrypoint {
|
|||
|
||||
@Override
|
||||
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
|
||||
|
||||
// BlockStateModelGenerator.createStairsBlockState(NSE_Blocks.SAND_TILES_STAIRS, new Identifier(NewSoviet.MOD_ID, "sand_tiles_stairs"));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ public abstract class LampBlock extends Block implements Waterloggable {
|
|||
public LampBlock(AbstractBlock.Settings settings, boolean defaultLightState, java.util.function.ToIntFunction<net.minecraft.block.BlockState> luminance) {
|
||||
super(settings.luminance(luminance == null ? (BlockState state) -> {
|
||||
if (state.get(INVERTED)) {
|
||||
return state.get(ON) ? 0 : 12;
|
||||
return state.get(ON) ? 0 : 14;
|
||||
} else {
|
||||
return state.get(ON) ? 12 : 0;
|
||||
return state.get(ON) ? 14 : 0;
|
||||
}
|
||||
} : luminance));
|
||||
this.defaultLightState = defaultLightState;
|
||||
|
|
|
@ -4,10 +4,7 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.text.Text;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
|
@ -18,34 +15,31 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.Config;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
import su.a71.new_soviet.registration.NSE_Sounds;
|
||||
|
||||
public class LightBulbBlock extends LampBlock {
|
||||
public class LightBulbLampBlock extends LampBlock {
|
||||
protected static final VoxelShape SHAPE;
|
||||
public static final BooleanProperty BROKEN;
|
||||
|
||||
public LightBulbBlock(Block.Settings settings) {
|
||||
public LightBulbLampBlock(Block.Settings settings) {
|
||||
super(settings, false, (BlockState state) -> {
|
||||
if (state.get(BROKEN)) {
|
||||
return 0;
|
||||
}
|
||||
if (state.get(INVERTED)) {
|
||||
return state.get(ON) ? 0 : 12;
|
||||
return state.get(ON) ? 0 : 14;
|
||||
} else {
|
||||
return state.get(ON) ? 12 : 0;
|
||||
return state.get(ON) ? 14 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +61,7 @@ public class LightBulbBlock extends LampBlock {
|
|||
} else {
|
||||
player.getItemCooldownManager().set(NSE_Items.LIGHT_BULB, 10);
|
||||
player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized"));
|
||||
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Custom.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f);
|
||||
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f);
|
||||
if (!player.isCreative()) {
|
||||
player.damage(world.getDamageSources().lightningBolt(), NewSoviet.RANDOM.nextBetween(1, 4));
|
||||
}
|
|
@ -9,7 +9,7 @@ import net.minecraft.world.BlockView;
|
|||
import net.minecraft.world.WorldView;
|
||||
|
||||
public class TableLampBlock extends LampBlock {
|
||||
protected static final VoxelShape SHAPE;
|
||||
protected final VoxelShape SHAPE = getStandingShape();;
|
||||
|
||||
public TableLampBlock(AbstractBlock.Settings settings) {
|
||||
super(settings, true, null);
|
||||
|
@ -24,9 +24,7 @@ public class TableLampBlock extends LampBlock {
|
|||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static VoxelShape getStandingShape(){
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.25, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625));
|
||||
|
@ -35,8 +33,4 @@ public class TableLampBlock extends LampBlock {
|
|||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
|
||||
static {
|
||||
SHAPE = getStandingShape();
|
||||
}
|
||||
}
|
23
src/main/java/su/a71/new_soviet/blocks/VintageLampBlock.java
Normal file
23
src/main/java/su/a71/new_soviet/blocks/VintageLampBlock.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
|
||||
public class VintageLampBlock extends TableLampBlock {
|
||||
public VintageLampBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.28125, 0, 0.28125, 0.71875, 0.125, 0.71875));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.40625, 0.125, 0.40625, 0.59375, 0.625, 0.59375));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.625, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.1875, 0.875, 0.1875, 0.8125, 1.125, 0.8125));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.25, 1.125, 0.25, 0.75, 1.1875, 0.75));
|
||||
|
||||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
}
|
|
@ -31,21 +31,19 @@ public class NSE_Custom extends NSE_BaseRegistration {
|
|||
public static final RadioReceiverBlock RADIO_RECEIVER = new RadioReceiverBlock();
|
||||
|
||||
public static final SwitchBlock SWITCH = new SwitchBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f).mapColor(MapColor.TERRACOTTA_WHITE));
|
||||
public static final TableLampBlock LAMP = new TableLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final LightBulbBlock LIGHT_BULB = new LightBulbBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.GLASS).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final TableLampBlock TABLE_LAMP = new TableLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final TableLampBlock VINTAGE_LAMP = new VintageLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final LightBulbLampBlock LIGHT_BULB_LAMP = new LightBulbLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.GLASS).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
|
||||
public static final CeilingFanBlock CEILING_FAN = new CeilingFanBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
|
||||
public static final SirenBlock SIREN = new SirenBlock();
|
||||
|
||||
public static final SoundEvent ELECTRIC_HIT = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "electric_hit"));
|
||||
|
||||
public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY).offset(AbstractBlock.OffsetType.XZ).dynamicBounds());
|
||||
//games
|
||||
//checkers
|
||||
|
||||
public static final CheckerBlock WHITE_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.WHITE));
|
||||
public static final CheckerBlock BLACK_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.BLACK));
|
||||
//chess
|
||||
|
||||
public static final ChessBlock WHITE_BISHOP = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,8,5,11,9,11), Block.createCuboidShape(5,10,5,11,16,11), Block.createCuboidShape(7,16,7,9,19,9)));
|
||||
public static final ChessBlock WHITE_KING = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,13,5,11,16,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5)));
|
||||
public static final ChessBlockKnight WHITE_KNIGHT = new ChessBlockKnight(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque());
|
||||
|
@ -71,8 +69,9 @@ public class NSE_Custom extends NSE_BaseRegistration {
|
|||
registerBlock("red_tv", () -> RED_TV, NSE_CUSTOM_TAB);
|
||||
registerBlock("brown_tv", () -> BROWN_TV, NSE_CUSTOM_TAB);
|
||||
registerBlock("radio_receiver", () -> RADIO_RECEIVER, NSE_CUSTOM_TAB);
|
||||
registerBlock("lamp", () -> LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("light_bulb", () -> LIGHT_BULB, NSE_CUSTOM_TAB);
|
||||
registerBlock("table_lamp", () -> TABLE_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("vintage_lamp", () -> VINTAGE_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("light_bulb_lamp", () -> LIGHT_BULB_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("ceiling_fan", () -> CEILING_FAN, NSE_CUSTOM_TAB);
|
||||
registerBlock("siren", () -> SIREN, NSE_CUSTOM_TAB);
|
||||
registerBlock("landmine", () -> LANDMINE, NSE_CUSTOM_TAB);
|
||||
|
|
|
@ -2,6 +2,8 @@ package su.a71.new_soviet.registration;
|
|||
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
|
||||
public class NSE_Sounds extends NSE_BaseRegistration {
|
||||
public static SoundEvent DICE_SOUND = registerSoundEvent("dice_sound");
|
||||
|
@ -35,6 +37,7 @@ public class NSE_Sounds extends NSE_BaseRegistration {
|
|||
public static SoundEvent CIGARETTE_PAUSE = registerSoundEvent("cigarette_pause");
|
||||
|
||||
public static final SoundEvent SIREN_SOUND = registerSoundEvent("siren_sound");
|
||||
public static final SoundEvent ELECTRIC_HIT = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "electric_hit"));
|
||||
|
||||
public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = registerSoundEvent("light_bulb_broken_sound");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue