Lots of fixes
This commit is contained in:
@@ -20,7 +20,10 @@ package appeng.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.hooks.AEToolItem;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,6 +32,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@@ -40,7 +44,7 @@ import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
public class MemoryCardItem extends AEBaseItem implements AEToolItem, IMemoryCard {
|
||||
|
||||
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
@@ -158,15 +162,21 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getPlayer().isInSneakingPose()) {
|
||||
// Bypass the memory card's own use handler and go straight to the block
|
||||
if (!context.getPlayer().world.isClient) {
|
||||
this.clearCard(context.getPlayer(), context.getWorld(), context.getHand());
|
||||
BlockState state = context.getWorld().getBlockState(context.getBlockPos());
|
||||
ActionResult useResult = state.onUse(context.getWorld(), context.getPlayer(), context.getHand(),
|
||||
new BlockHitResult(context.getHitPos(), context.getSide(), context.getBlockPos(), context.hitsInsideBlock()));
|
||||
if (!useResult.isAccepted()) {
|
||||
clearCard(context.getPlayer(), context.getWorld(), context.getHand());
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return super.useOnBlock(context);
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,15 +190,10 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
return super.use(w, player, hand);
|
||||
}
|
||||
|
||||
// FIXME FABRIC probably needs a custom mixin
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public boolean doesSneakBypassUse(ItemStack stack, WorldView world, BlockPos pos, PlayerEntity player) {
|
||||
// FIXME FABRIC return true;
|
||||
// FIXME FABRIC }
|
||||
|
||||
private void clearCard(final PlayerEntity player, final World w, final Hand hand) {
|
||||
final IMemoryCard mem = (IMemoryCard) player.getStackInHand(hand).getItem();
|
||||
mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
player.getStackInHand(hand).setTag(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
}
|
||||
|
||||
// FIXME FABRIC: No direct equivalent
|
||||
// FIXME FABRIC: Might already be handled by onItemUseFirst though
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public boolean doesSneakBypassUse(ItemStack stack, WorldView world, BlockPos pos, PlayerEntity player) {
|
||||
// FIXME FABRIC return true;
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.QuartzKnifeContainer;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.mixins.RemainderSetter;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -48,8 +51,7 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isServer()) {
|
||||
// FIXME FABRIC ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
throw new IllegalStateException();
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
p.swingHand(hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
@@ -58,7 +60,6 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world,
|
||||
final BlockPos pos) {
|
||||
// FIXME FABRIC return new QuartzKnifeObj(is);
|
||||
throw new IllegalStateException();
|
||||
return new QuartzKnifeObj(is);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user