diff --git a/src/datagen/java/xyz/nucleoid/extras/data/provider/NEBlockTagProvider.java b/src/datagen/java/xyz/nucleoid/extras/data/provider/NEBlockTagProvider.java index 3e45339..65a3760 100644 --- a/src/datagen/java/xyz/nucleoid/extras/data/provider/NEBlockTagProvider.java +++ b/src/datagen/java/xyz/nucleoid/extras/data/provider/NEBlockTagProvider.java @@ -18,13 +18,31 @@ public NEBlockTagProvider(FabricDataOutput dataOutput, CompletableFuture new TransientDoorBlock(Blocks.BAMBOO_DOOR, settings)); public static final Block TRANSIENT_CRIMSON_DOOR = register("transient_crimson_door", AbstractBlock.Settings.copy(Blocks.CRIMSON_DOOR), settings -> new TransientDoorBlock(Blocks.CRIMSON_DOOR, settings)); public static final Block TRANSIENT_WARPED_DOOR = register("transient_warped_door", AbstractBlock.Settings.copy(Blocks.WARPED_DOOR), settings -> new TransientDoorBlock(Blocks.WARPED_DOOR, settings)); - // pale oak + public static final Block TRANSIENT_COPPER_DOOR = register("transient_copper_door", AbstractBlock.Settings.copy(Blocks.COPPER_DOOR), settings -> new TransientOxidizableDoorBlock(Blocks.COPPER_DOOR, settings)); + public static final Block TRANSIENT_EXPOSED_COPPER_DOOR = register("transient_exposed_copper_door", AbstractBlock.Settings.copy(Blocks.EXPOSED_COPPER_DOOR), settings -> new TransientOxidizableDoorBlock(Blocks.EXPOSED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_WEATHERED_COPPER_DOOR = register("transient_weathered_copper_door", AbstractBlock.Settings.copy(Blocks.WEATHERED_COPPER_DOOR), settings -> new TransientOxidizableDoorBlock(Blocks.WEATHERED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_OXIDIZED_COPPER_DOOR = register("transient_oxidized_copper_door", AbstractBlock.Settings.copy(Blocks.OXIDIZED_COPPER_DOOR), settings -> new TransientOxidizableDoorBlock(Blocks.OXIDIZED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_WAXED_COPPER_DOOR = register("transient_waxed_copper_door", AbstractBlock.Settings.copy(Blocks.WAXED_COPPER_DOOR), settings -> new TransientDoorBlock(Blocks.WAXED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_WAXED_EXPOSED_COPPER_DOOR = register("transient_waxed_exposed_copper_door", AbstractBlock.Settings.copy(Blocks.WAXED_EXPOSED_COPPER_DOOR), settings -> new TransientDoorBlock(Blocks.WAXED_EXPOSED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_WAXED_WEATHERED_COPPER_DOOR = register("transient_waxed_weathered_copper_door", AbstractBlock.Settings.copy(Blocks.WAXED_WEATHERED_COPPER_DOOR), settings -> new TransientDoorBlock(Blocks.WAXED_WEATHERED_COPPER_DOOR, settings)); + public static final Block TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR = register("transient_waxed_oxidized_copper_door", AbstractBlock.Settings.copy(Blocks.WAXED_OXIDIZED_COPPER_DOOR), settings -> new TransientDoorBlock(Blocks.WAXED_OXIDIZED_COPPER_DOOR, settings)); public static final Block NUCLE_PAST_LOGO = registerTaterBlock("nucle_past_logo", new DustParticleEffect(0x52C471, 1), "65ed3e4d6ec42bd84d2b5e452087d454aac141a978540f6d200bd8aa863d4db8"); @@ -524,6 +533,15 @@ private static Block registerLightTaterBlock(String id, String texture) { } public static void register() { + registerOxidizableBlockPair(NEBlocks.TRANSIENT_COPPER_DOOR, NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR); + registerOxidizableBlockPair(NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR, NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR); + registerOxidizableBlockPair(NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR, NEBlocks.TRANSIENT_OXIDIZED_COPPER_DOOR); + + OxidizableBlocksRegistry.registerWaxableBlockPair(NEBlocks.TRANSIENT_COPPER_DOOR, NEBlocks.TRANSIENT_WAXED_COPPER_DOOR); + OxidizableBlocksRegistry.registerWaxableBlockPair(NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR, NEBlocks.TRANSIENT_WAXED_EXPOSED_COPPER_DOOR); + OxidizableBlocksRegistry.registerWaxableBlockPair(NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR, NEBlocks.TRANSIENT_WAXED_WEATHERED_COPPER_DOOR); + OxidizableBlocksRegistry.registerWaxableBlockPair(NEBlocks.TRANSIENT_OXIDIZED_COPPER_DOOR, NEBlocks.TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR); + registerBlockEntity("launch_pad", LAUNCH_PAD_ENTITY); registerBlockEntity("contributor_statue", CONTRIBUTOR_STATUE_ENTITY); registerBlockEntity("tateroid", TATEROID_ENTITY); @@ -538,6 +556,16 @@ private static T register(String id, Block.Settings settings, return Registry.register(Registries.BLOCK, key, block); } + private static void registerOxidizableBlockPair(Block less, Block more) { + OxidizableBlocksRegistry.registerOxidizableBlockPair(less, more); + + // TransientOxidizableDoorBlock#hasRandomTicks is dependent on the above registration, + // so the cached BlockState#ticksRandomly field must be recomputed with the new result + for (BlockState state : less.getStateManager().getStates()) { + state.initShapeCache(); + } + } + private static BlockEntityType registerBlockEntity(String id, BlockEntityType type) { Registry.register(Registries.BLOCK_ENTITY_TYPE, NucleoidExtras.identifier(id), type); PolymerBlockUtils.registerBlockEntity(type); diff --git a/src/main/java/xyz/nucleoid/extras/lobby/NEItems.java b/src/main/java/xyz/nucleoid/extras/lobby/NEItems.java index 1ab66ca..bb8a4d0 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/NEItems.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/NEItems.java @@ -91,6 +91,14 @@ public class NEItems { entries.add(NEItems.TRANSIENT_BAMBOO_DOOR); entries.add(NEItems.TRANSIENT_CRIMSON_DOOR); entries.add(NEItems.TRANSIENT_WARPED_DOOR); + entries.add(NEItems.TRANSIENT_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_EXPOSED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_WEATHERED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_OXIDIZED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_WAXED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_WAXED_EXPOSED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_WAXED_WEATHERED_COPPER_DOOR); + entries.add(NEItems.TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR); entries.add(NEItems.BLACK_CONCRETE_POWDER); entries.add(NEItems.BLUE_CONCRETE_POWDER); entries.add(NEItems.BROWN_CONCRETE_POWDER); @@ -145,6 +153,14 @@ public class NEItems { public static final Item TRANSIENT_BAMBOO_DOOR = register("transient_bamboo_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_BAMBOO_DOOR, settings, Items.BAMBOO_DOOR)); public static final Item TRANSIENT_CRIMSON_DOOR = register("transient_crimson_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_CRIMSON_DOOR, settings, Items.CRIMSON_DOOR)); public static final Item TRANSIENT_WARPED_DOOR = register("transient_warped_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WARPED_DOOR, settings, Items.WARPED_DOOR)); + public static final Item TRANSIENT_COPPER_DOOR = register("transient_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_COPPER_DOOR, settings, Items.COPPER_DOOR)); + public static final Item TRANSIENT_EXPOSED_COPPER_DOOR = register("transient_exposed_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR, settings, Items.EXPOSED_COPPER_DOOR)); + public static final Item TRANSIENT_WEATHERED_COPPER_DOOR = register("transient_weathered_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR, settings, Items.WEATHERED_COPPER_DOOR)); + public static final Item TRANSIENT_OXIDIZED_COPPER_DOOR = register("transient_oxidized_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_OXIDIZED_COPPER_DOOR, settings, Items.OXIDIZED_COPPER_DOOR)); + public static final Item TRANSIENT_WAXED_COPPER_DOOR = register("transient_waxed_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WAXED_COPPER_DOOR, settings, Items.WAXED_COPPER_DOOR)); + public static final Item TRANSIENT_WAXED_EXPOSED_COPPER_DOOR = register("transient_waxed_exposed_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WAXED_EXPOSED_COPPER_DOOR, settings, Items.WAXED_EXPOSED_COPPER_DOOR)); + public static final Item TRANSIENT_WAXED_WEATHERED_COPPER_DOOR = register("transient_waxed_weathered_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WAXED_WEATHERED_COPPER_DOOR, settings, Items.WAXED_WEATHERED_COPPER_DOOR)); + public static final Item TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR = register("transient_waxed_oxidized_copper_door", new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyTallBlockItem(NEBlocks.TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR, settings, Items.WAXED_OXIDIZED_COPPER_DOOR)); public static final Item BLACK_CONCRETE_POWDER = registerSimple("black_concrete_powder", NEBlocks.BLACK_CONCRETE_POWDER, Items.BLACK_CONCRETE_POWDER); public static final Item BLUE_CONCRETE_POWDER = registerSimple("blue_concrete_powder", NEBlocks.BLUE_CONCRETE_POWDER, Items.BLUE_CONCRETE_POWDER); diff --git a/src/main/java/xyz/nucleoid/extras/lobby/block/TransientOxidizableDoorBlock.java b/src/main/java/xyz/nucleoid/extras/lobby/block/TransientOxidizableDoorBlock.java new file mode 100644 index 0000000..8f6eb46 --- /dev/null +++ b/src/main/java/xyz/nucleoid/extras/lobby/block/TransientOxidizableDoorBlock.java @@ -0,0 +1,37 @@ +package xyz.nucleoid.extras.lobby.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DoorBlock; +import net.minecraft.block.Oxidizable; +import net.minecraft.block.OxidizableDoorBlock; +import net.minecraft.block.enums.DoubleBlockHalf; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; + +public class TransientOxidizableDoorBlock extends TransientDoorBlock implements Oxidizable { + private final Oxidizable.OxidationLevel oxidationLevel; + + public TransientOxidizableDoorBlock(Block block, Block.Settings settings) { + super(block, settings); + this.oxidationLevel = block instanceof OxidizableDoorBlock door ? door.getDegradationLevel() : Oxidizable.OxidationLevel.UNAFFECTED; + } + + @Override + protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER) { + this.tickDegradation(state, world, pos, random); + } + } + + @Override + protected boolean hasRandomTicks(BlockState state) { + return Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent(); + } + + @Override + public OxidationLevel getDegradationLevel() { + return this.oxidationLevel; + } +} diff --git a/src/main/resources/data/nucleoid_extras/lang/en_us.json b/src/main/resources/data/nucleoid_extras/lang/en_us.json index 79a7155..ee34bc3 100644 --- a/src/main/resources/data/nucleoid_extras/lang/en_us.json +++ b/src/main/resources/data/nucleoid_extras/lang/en_us.json @@ -48,6 +48,14 @@ "block.nucleoid_extras.transient_bamboo_door": "Transient Bamboo Door (Lobby only!)", "block.nucleoid_extras.transient_crimson_door": "Transient Crimson Door (Lobby only!)", "block.nucleoid_extras.transient_warped_door": "Transient Warped Door (Lobby only!)", + "block.nucleoid_extras.transient_copper_door": "Transient Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_exposed_copper_door": "Transient Exposed Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_weathered_copper_door": "Transient Weathered Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_oxidized_copper_door": "Transient Oxidized Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_waxed_copper_door": "Transient Waxed Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_waxed_exposed_copper_door": "Transient Waxed Exposed Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_waxed_weathered_copper_door": "Transient Waxed Weathered Copper Door (Lobby only!)", + "block.nucleoid_extras.transient_waxed_oxidized_copper_door": "Transient Waxed Oxidized Copper Door (Lobby only!)", "block.nucleoid_extras.black_concrete_powder": "Floating Black Concrete Powder (Lobby only!)", "block.nucleoid_extras.blue_concrete_powder": "Floating Blue Concrete Powder (Lobby only!)",