mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
Don't dye/undye turtles when right clicked
While it's a nice immersive interaction, it's far too easy to trigger by accident. Dying/undying can now only be done via crafting and the cauldron. Closes #1321
This commit is contained in:
parent
81dad421d5
commit
66b20d2bdb
@ -29,14 +29,10 @@ import net.minecraft.nbt.ListTag;
|
|||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.DyeItem;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
@ -88,42 +84,6 @@ public class TurtleBlockEntity extends AbstractComputerBlockEntity implements Ba
|
|||||||
if (!hasMoved()) super.unload();
|
if (!hasMoved()) super.unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public InteractionResult use(Player player, InteractionHand hand) {
|
|
||||||
// Apply dye
|
|
||||||
var currentItem = player.getItemInHand(hand);
|
|
||||||
if (!currentItem.isEmpty()) {
|
|
||||||
if (currentItem.getItem() instanceof DyeItem dyeItem) {
|
|
||||||
// Dye to change turtle colour
|
|
||||||
if (!getLevel().isClientSide) {
|
|
||||||
var dye = dyeItem.getDyeColor();
|
|
||||||
if (brain.getDyeColour() != dye) {
|
|
||||||
brain.setDyeColour(dye);
|
|
||||||
if (!player.isCreative()) {
|
|
||||||
currentItem.shrink(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
|
||||||
} else if (currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1) {
|
|
||||||
// Water to remove turtle colour
|
|
||||||
if (!getLevel().isClientSide) {
|
|
||||||
if (brain.getColour() != -1) {
|
|
||||||
brain.setColour(-1);
|
|
||||||
if (!player.isCreative()) {
|
|
||||||
player.setItemInHand(hand, new ItemStack(Items.BUCKET));
|
|
||||||
player.getInventory().setChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.sidedSuccess(getLevel().isClientSide);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open GUI or whatever
|
|
||||||
return super.use(player, hand);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canNameWithTag(Player player) {
|
protected boolean canNameWithTag(Player player) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user