Skip to content

Commit

Permalink
Hanging Festive Rubber Ladders Enhancement
Browse files Browse the repository at this point in the history
Festive Rubber Variant Map Colors
Bump Version
  • Loading branch information
FirstMegaGame4 committed Jul 10, 2024
1 parent 4ac227a commit 9e8b270
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9e8b270

Please sign in to comment.