Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transient copper doors #187

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,31 @@ public NEBlockTagProvider(FabricDataOutput dataOutput, CompletableFuture<Registr
@Override
protected void configure(WrapperLookup lookup) {
this.getOrCreateTagBuilder(BlockTags.DOORS)
.add(NEBlocks.TRANSIENT_IRON_DOOR);
.add(NEBlocks.TRANSIENT_IRON_DOOR)
.add(NEBlocks.TRANSIENT_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_OXIDIZED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_EXPOSED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_WEATHERED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR);

this.getOrCreateTagBuilder(NEBlockTags.LUCKY_TATER_DROPS)
.add(NEBlocks.BRONZE_CAPSULE_TATER)
.add(NEBlocks.SILVER_CAPSULE_TATER)
.add(NEBlocks.GOLD_CAPSULE_TATER);

this.getOrCreateTagBuilder(BlockTags.MOB_INTERACTABLE_DOORS)
.add(NEBlocks.TRANSIENT_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_EXPOSED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WEATHERED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_OXIDIZED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_EXPOSED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_WEATHERED_COPPER_DOOR)
.add(NEBlocks.TRANSIENT_WAXED_OXIDIZED_COPPER_DOOR);

this.getOrCreateTagBuilder(NEBlockTags.NON_VIBRATING_TATERS)
.addOptionalTag(BlockTags.DAMPENS_VIBRATIONS)
.add(NEBlocks.WARDEN_TATER);
Expand Down
30 changes: 29 additions & 1 deletion src/main/java/xyz/nucleoid/extras/lobby/NEBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import eu.pb4.polymer.core.api.block.SimplePolymerBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.registry.OxidizableBlocksRegistry;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.MapColor;
import net.minecraft.block.entity.BlockEntity;
Expand Down Expand Up @@ -78,7 +80,14 @@ public class NEBlocks {
public static final Block TRANSIENT_BAMBOO_DOOR = register("transient_bamboo_door", AbstractBlock.Settings.copy(Blocks.BAMBOO_DOOR), settings -> 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");

Expand Down Expand Up @@ -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);
Expand All @@ -538,6 +556,16 @@ private static <T extends Block> 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 <T extends BlockEntity> BlockEntityType<T> registerBlockEntity(String id, BlockEntityType<T> type) {
Registry.register(Registries.BLOCK_ENTITY_TYPE, NucleoidExtras.identifier(id), type);
PolymerBlockUtils.registerBlockEntity(type);
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/xyz/nucleoid/extras/lobby/NEItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
8 changes: 8 additions & 0 deletions src/main/resources/data/nucleoid_extras/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!)",
Expand Down
Loading