Add boundary markers

This commit is contained in:
Andrew-71 2023-10-01 16:27:25 +03:00
parent dfaa80fc16
commit 483f2730e3
88 changed files with 768 additions and 20 deletions

View file

@ -1,20 +1,19 @@
package su.a71.new_soviet.blocks;
import net.minecraft.block.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BucketItem;
import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
@ -50,11 +49,14 @@ public class BoundaryMarkerBlock extends Block implements Waterloggable {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (player.getInventory().getMainHandStack().getItem() instanceof DyeItem) {
if (!world.isClient()) {
int id = ((DyeItem) player.getInventory().getMainHandStack().getItem()).getColor().getId();
if (id == state.get(COLOUR))
return ActionResult.CONSUME;
if (!player.isCreative()) {
player.getInventory().getMainHandStack().decrement(1);
}
world.setBlockState(pos, state.with(COLOUR, id));
world.playSound((PlayerEntity)null, pos, SoundEvents.ITEM_DYE_USE, SoundCategory.BLOCKS, 1.0F, 1.0F);
// world.setBlockState(pos, state.with(COLOUR, player.getInventory().getMainHandStack().getItem()))
}
return ActionResult.SUCCESS;
}
@ -76,6 +78,29 @@ public class BoundaryMarkerBlock extends Block implements Waterloggable {
static {
WATERLOGGED = Properties.WATERLOGGED;
SHAPE = Block.createCuboidShape(5, 0, 5, 11, 16, 11);
COLOUR = IntProperty.of("border_colour", 0, 16); // 0 - undyed, 1-16 = dyes
COLOUR = IntProperty.of("border_colour", 0, 15); // 0-16 = dyes
}
// DyeColor IDs with better colours
public static int getColour(int id) {
return switch (id) {
case 0 -> 0xffffff;
case 1 -> 0xb67134;
case 2 -> 0xab4d8b;
case 3 -> 0x398b9c;
case 4 -> 0xb08732;
case 5 -> 0x489d1b;
case 6 -> 0xcf7a92;
case 7 -> 0x353e42;
case 8 -> 0x777771;
case 9 -> 0x18797e;
case 10 -> 0x813995;
case 11 -> 0x354a85;
case 12 -> 0x614332;
case 13 -> 0x1b6031;
case 14 -> 0x8b2030;
case 15 -> 0x272228;
default -> 0xffffff;
};
}
}