From 9e8b27050ea76e2736d937a6630c41006e69b397 Mon Sep 17 00:00:00 2001 From: FirstMegaGame4 <84094287+FirstMegaGame4@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:05:23 +0200 Subject: [PATCH] Hanging Festive Rubber Ladders Enhancement Festive Rubber Variant Map Colors Bump Version --- gradle.properties | 2 +- .../extravaganza/ExtravaganzaColor.java | 26 ++++++++++++++++++ .../extravaganza/block/RubberLadderBlock.java | 27 +++++++++++++++++++ .../extravaganza/init/ExtravaganzaBlocks.java | 4 +-- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/mmodding/extravaganza/block/RubberLadderBlock.java diff --git a/gradle.properties b/gradle.properties index 52910965..b8c04fb1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.21+build.1 loader_version=0.15.11 # Mod Properties -mod_version=0.1.6-beta +mod_version=0.1.7-beta maven_group=com.mmodding.extravaganza archives_base_name=extravaganza diff --git a/src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java b/src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java index 5d940fab..8b439111 100644 --- a/src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java +++ b/src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java @@ -1,6 +1,7 @@ package com.mmodding.extravaganza; import com.mmodding.extravaganza.entity.FestiveBallEntity; +import net.minecraft.block.MapColor; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; @@ -30,6 +31,31 @@ public String asString() { return this.name().toLowerCase(); } + public MapColor getMapColor() { + return switch (this) { + case BLACK -> MapColor.BLACK; + case BLUE -> MapColor.BLUE; + case BROWN -> MapColor.BROWN; + case CYAN -> MapColor.CYAN; + case GRAY -> MapColor.GRAY; + case GREEN -> MapColor.GREEN; + case LIGHT_BLUE -> MapColor.LIGHT_BLUE; + case LIGHT_GRAY -> MapColor.LIGHT_GRAY; + case LIME -> MapColor.LIME; + case MAGENTA -> MapColor.MAGENTA; + case ORANGE -> MapColor.ORANGE; + case PINK -> MapColor.PINK; + case PURPLE -> MapColor.PURPLE; + case RED -> MapColor.RED; + case WHITE -> MapColor.WHITE; + case YELLOW -> MapColor.YELLOW; + case PLANT -> MapColor.PALE_GREEN; + case TOMATO -> MapColor.DULL_RED; + case TEAR -> MapColor.WATER_BLUE; + case NYMPH -> MapColor.DULL_PINK; + }; + } + public ItemStack createBallStack() { return Registries.ITEM.get(Extravaganza.createId(this.asString() + "_festive_ball")).getDefaultStack(); } diff --git a/src/main/java/com/mmodding/extravaganza/block/RubberLadderBlock.java b/src/main/java/com/mmodding/extravaganza/block/RubberLadderBlock.java new file mode 100644 index 00000000..189bad51 --- /dev/null +++ b/src/main/java/com/mmodding/extravaganza/block/RubberLadderBlock.java @@ -0,0 +1,27 @@ +package com.mmodding.extravaganza.block; + +import net.minecraft.block.BlockState; +import net.minecraft.block.LadderBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.WorldView; + +public class RubberLadderBlock extends LadderBlock { + + public RubberLadderBlock(Settings settings) { + super(settings); + } + + @Override + protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + return world.getBlockState(pos.up()).getBlock() instanceof RubberLadderBlock || super.canPlaceAt(state, world, pos); + } + + @Override + protected void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) { + BlockState downState = world.getBlockState(pos.down()); + if (!(newState.getBlock() instanceof RubberLadderBlock) && downState.getBlock() instanceof RubberLadderBlock && !state.canPlaceAt(world, pos.down())) { + world.breakBlock(pos.down(), true); + } + } +} diff --git a/src/main/java/com/mmodding/extravaganza/init/ExtravaganzaBlocks.java b/src/main/java/com/mmodding/extravaganza/init/ExtravaganzaBlocks.java index 293ddbba..23a3af71 100644 --- a/src/main/java/com/mmodding/extravaganza/init/ExtravaganzaBlocks.java +++ b/src/main/java/com/mmodding/extravaganza/init/ExtravaganzaBlocks.java @@ -92,7 +92,7 @@ public static void register() { ExtravaganzaBlocks.registerBlockWithItem("tomato_stained_glass", ExtravaganzaBlocks.TOMATO_STAINED_GLASS); ExtravaganzaBlocks.registerBlockWithItem("nymph_stained_glass", ExtravaganzaBlocks.NYMPH_STAINED_GLASS); ExtravaganzaColor.VALUES.forEach(color -> ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_trash_can", new TrashCanBlock(AbstractBlock.Settings.create().requiresTool().strength(2.5f, 3.0f).nonOpaque().sounds(BlockSoundGroup.LANTERN)))); - ExtravaganzaColor.VALUES.forEach(color -> ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_festive_rubber_ladder", new LadderBlock(AbstractBlock.Settings.create().strength(1.5f, 3.0f).nonOpaque().sounds(BlockSoundGroup.PACKED_MUD)))); + ExtravaganzaColor.VALUES.forEach(color -> ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_festive_rubber_ladder", new RubberLadderBlock(AbstractBlock.Settings.create().strength(1.5f, 3.0f).nonOpaque().sounds(BlockSoundGroup.PACKED_MUD)))); ExtravaganzaBlocks.registerColoredBlockSet("festive_rubber", AbstractBlock.Settings.create().sounds(BlockSoundGroup.PACKED_MUD)); ExtravaganzaBlocks.registerColoredBlockSet("striped_festive_rubber", AbstractBlock.Settings.create().sounds(BlockSoundGroup.PACKED_MUD)); ExtravaganzaBlocks.registerColoredBlockSet("poured_festive_rubber", AbstractBlock.Settings.create().sounds(BlockSoundGroup.PACKED_MUD)); @@ -121,7 +121,7 @@ private static void registerBlockWithItem(String path, Block block) { private static void registerColoredBlockSet(String path, AbstractBlock.Settings settings) { ExtravaganzaColor.VALUES.forEach( color -> { - Block block = new Block(settings.strength(1.5f, 3.0f)); + Block block = new Block(settings.strength(1.5f, 3.0f).mapColor(color.getMapColor())); ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_" + path, block); ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_" + path + "_stairs", new StairsBlock(block.getDefaultState(), settings)); ExtravaganzaBlocks.registerBlockWithItem(color.asString() + "_" + path + "_slab", new SlabBlock(settings));