aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch155
1 files changed, 155 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch
new file mode 100644
index 0000000000..665bad6233
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/DebugStickItem.java.patch
@@ -0,0 +1,155 @@
+--- a/net/minecraft/world/item/DebugStickItem.java
++++ b/net/minecraft/world/item/DebugStickItem.java
+@@ -1,3 +1,4 @@
++// mc-dev import
+ package net.minecraft.world.item;
+
+ import java.util.Collection;
+@@ -8,88 +9,85 @@
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.network.chat.Component;
+ import net.minecraft.server.level.ServerPlayer;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.context.UseOnContext;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.block.Block;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.block.state.StateDefinition;
+ import net.minecraft.world.level.block.state.properties.Property;
+
+ public class DebugStickItem extends Item {
+
+- public DebugStickItem(Item.Properties item_properties) {
+- super(item_properties);
++ public DebugStickItem(Item.Properties properties) {
++ super(properties);
+ }
+
+ @Override
+- @Override
+- public boolean isFoil(ItemStack itemstack) {
++ public boolean isFoil(ItemStack stack) {
+ return true;
+ }
+
+ @Override
+- @Override
+- public boolean canAttackBlock(BlockState blockstate, Level level, BlockPos blockpos, Player player) {
++ public boolean canAttackBlock(IBlockData state, Level level, BlockPos pos, Player player) {
+ if (!level.isClientSide) {
+- this.handleInteraction(player, blockstate, level, blockpos, false, player.getItemInHand(InteractionHand.MAIN_HAND));
++ this.handleInteraction(player, state, level, pos, false, player.getItemInHand(EnumHand.MAIN_HAND));
+ }
+
+ return false;
+ }
+
+ @Override
+- @Override
+- public InteractionResult useOn(UseOnContext useoncontext) {
+- Player player = useoncontext.getPlayer();
+- Level level = useoncontext.getLevel();
++ public InteractionResult useOn(UseOnContext context) {
++ Player entityhuman = context.getPlayer();
++ Level world = context.getLevel();
+
+- if (!level.isClientSide && player != null) {
+- BlockPos blockpos = useoncontext.getClickedPos();
++ if (!world.isClientSide && entityhuman != null) {
++ BlockPos blockposition = context.getClickedPos();
+
+- if (!this.handleInteraction(player, level.getBlockState(blockpos), level, blockpos, true, useoncontext.getItemInHand())) {
++ if (!this.handleInteraction(entityhuman, world.getBlockState(blockposition), world, blockposition, true, context.getItemInHand())) {
+ return InteractionResult.FAIL;
+ }
+ }
+
+- return InteractionResult.sidedSuccess(level.isClientSide);
++ return InteractionResult.sidedSuccess(world.isClientSide);
+ }
+
+- private boolean handleInteraction(Player player, BlockState blockstate, LevelAccessor levelaccessor, BlockPos blockpos, boolean flag, ItemStack itemstack) {
++ public boolean handleInteraction(Player player, IBlockData stateClicked, LevelAccessor accessor, BlockPos pos, boolean shouldCycleState, ItemStack debugStack) {
+ if (!player.canUseGameMasterBlocks()) {
+ return false;
+ } else {
+- Block block = blockstate.getBlock();
+- StateDefinition<Block, BlockState> statedefinition = block.getStateDefinition();
+- Collection<Property<?>> collection = statedefinition.getProperties();
++ Block block = stateClicked.getBlock();
++ StateDefinition<Block, IBlockData> blockstatelist = block.getStateDefinition();
++ Collection<Property<?>> collection = blockstatelist.getProperties();
+ String s = BuiltInRegistries.BLOCK.getKey(block).toString();
+
+ if (collection.isEmpty()) {
+ message(player, Component.translatable(this.getDescriptionId() + ".empty", s));
+ return false;
+ } else {
+- CompoundTag compoundtag = itemstack.getOrCreateTagElement("DebugProperty");
+- String s1 = compoundtag.getString(s);
+- Property<?> property = statedefinition.getProperty(s1);
++ CompoundTag nbttagcompound = debugStack.getOrCreateTagElement("DebugProperty");
++ String s1 = nbttagcompound.getString(s);
++ Property<?> iblockstate = blockstatelist.getProperty(s1);
+
+- if (flag) {
+- if (property == null) {
+- property = (Property) collection.iterator().next();
++ if (shouldCycleState) {
++ if (iblockstate == null) {
++ iblockstate = (Property) collection.iterator().next();
+ }
+
+- BlockState blockstate1 = cycleState(blockstate, property, player.isSecondaryUseActive());
++ IBlockData iblockdata1 = cycleState(stateClicked, iblockstate, player.isSecondaryUseActive());
+
+- levelaccessor.setBlock(blockpos, blockstate1, 18);
+- message(player, Component.translatable(this.getDescriptionId() + ".update", property.getName(), getNameHelper(blockstate1, property)));
++ accessor.setBlock(pos, iblockdata1, 18);
++ message(player, Component.translatable(this.getDescriptionId() + ".update", iblockstate.getName(), getNameHelper(iblockdata1, iblockstate)));
+ } else {
+- property = (Property) getRelative(collection, property, player.isSecondaryUseActive());
+- String s2 = property.getName();
++ iblockstate = (Property) getRelative(collection, iblockstate, player.isSecondaryUseActive());
++ String s2 = iblockstate.getName();
+
+- compoundtag.putString(s, s2);
+- message(player, Component.translatable(this.getDescriptionId() + ".select", s2, getNameHelper(blockstate, property)));
++ nbttagcompound.putString(s, s2);
++ message(player, Component.translatable(this.getDescriptionId() + ".select", s2, getNameHelper(stateClicked, iblockstate)));
+ }
+
+ return true;
+@@ -97,19 +95,19 @@
+ }
+ }
+
+- private static <T extends Comparable<T>> BlockState cycleState(BlockState blockstate, Property<T> property, boolean flag) {
+- return (BlockState) blockstate.setValue(property, (Comparable) getRelative(property.getPossibleValues(), blockstate.getValue(property), flag));
++ private static <T extends Comparable<T>> IBlockData cycleState(IBlockData state, Property<T> property, boolean backwards) {
++ return (IBlockData) state.setValue(property, getRelative(property.getPossibleValues(), state.getValue(property), backwards)); // CraftBukkit - decompile error
+ }
+
+- private static <T> T getRelative(Iterable<T> iterable, @Nullable T t0, boolean flag) {
+- return flag ? Util.findPreviousInIterable(iterable, t0) : Util.findNextInIterable(iterable, t0);
++ private static <T> T getRelative(Iterable<T> allowedValues, @Nullable T currentValue, boolean backwards) {
++ return backwards ? Util.findPreviousInIterable(allowedValues, currentValue) : Util.findNextInIterable(allowedValues, currentValue);
+ }
+
+- private static void message(Player player, Component component) {
+- ((ServerPlayer) player).sendSystemMessage(component, true);
++ private static void message(Player player, Component messageComponent) {
++ ((ServerPlayer) player).sendSystemMessage(messageComponent, true);
+ }
+
+- private static <T extends Comparable<T>> String getNameHelper(BlockState blockstate, Property<T> property) {
+- return property.getName(blockstate.getValue(property));
++ private static <T extends Comparable<T>> String getNameHelper(IBlockData state, Property<T> property) {
++ return property.getName(state.getValue(property));
+ }
+ }