Fabric port in progress
This commit is contained in:
@@ -20,21 +20,24 @@ package appeng.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public abstract class AEBaseItem extends Item {
|
||||
|
||||
public AEBaseItem(Item.Properties properties) {
|
||||
super(properties.setNoRepair());
|
||||
public AEBaseItem(Item.Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
|
||||
Identifier id = Registry.ITEM.getId(this);
|
||||
String regName = id != Registry.ITEM.getDefaultId() ? id.getPath() : "unregistered";
|
||||
return this.getClass().getSimpleName() + "[" + regName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
|
||||
public boolean canRepair(ItemStack stack, ItemStack ingredient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
@@ -66,21 +66,21 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
private final MaterialType materialType;
|
||||
|
||||
public MaterialItem(Properties properties, MaterialType materialType) {
|
||||
public MaterialItem(Settings properties, MaterialType materialType) {
|
||||
super(properties);
|
||||
this.materialType = materialType;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
|
||||
if (materialType == MaterialType.NAME_PRESS) {
|
||||
final CompoundTag c = stack.getOrCreateTag();
|
||||
if (c.contains(TAG_INSCRIBE_NAME)) {
|
||||
lines.add(new StringTextComponent(c.getString(TAG_INSCRIBE_NAME)));
|
||||
lines.add(new LiteralText(c.getString(TAG_INSCRIBE_NAME)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,12 +96,12 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
final IItemGroup ig = (IItemGroup) j.getKey().getItem();
|
||||
final String str = ig.getUnlocalizedGroupName(u.getSupported().keySet(), j.getKey());
|
||||
if (str != null) {
|
||||
name = new TranslatableText(str).appendText(limit > 1 ? " (" + limit + ')' : "");
|
||||
name = new TranslatableText(str).append(limit > 1 ? " (" + limit + ')' : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = j.getKey().getDisplayName().appendText((limit > 1 ? " (" + limit + ')' : ""));
|
||||
name = j.getKey().getName().append((limit > 1 ? " (" + limit + ')' : ""));
|
||||
}
|
||||
|
||||
if (!textList.contains(name)) {
|
||||
@@ -138,11 +138,11 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
Hand hand = context.getHand();
|
||||
if (player.isCrouching()) {
|
||||
final BlockEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||
if (player.isInSneakingPose()) {
|
||||
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||
ItemTransferable upgrades = null;
|
||||
|
||||
if (te instanceof IPartHost) {
|
||||
@@ -154,18 +154,18 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
upgrades = ((ISegmentedInventory) te).getInventoryByName("upgrades");
|
||||
}
|
||||
|
||||
if (upgrades != null && !player.getHeldItem(hand).isEmpty()
|
||||
&& player.getHeldItem(hand).getItem() instanceof IUpgradeModule) {
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getHeldItem(hand).getItem();
|
||||
final Upgrades u = um.getType(player.getHeldItem(hand));
|
||||
if (upgrades != null && !player.getStackInHand(hand).isEmpty()
|
||||
&& player.getStackInHand(hand).getItem() instanceof IUpgradeModule) {
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getStackInHand(hand).getItem();
|
||||
final Upgrades u = um.getType(player.getStackInHand(hand));
|
||||
|
||||
if (u != null) {
|
||||
if (player.world.isRemote) {
|
||||
if (player.world.isClient) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler(upgrades);
|
||||
player.setHeldItem(hand, ad.addItems(player.getHeldItem(hand)));
|
||||
player.setHeldItem(hand, ad.addItems(player.getStackInHand(hand)));
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,23 +22,25 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.items.IGrowableCrystal;
|
||||
@@ -67,12 +69,15 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
*/
|
||||
private final IItemProvider grownItem;
|
||||
|
||||
public CrystalSeedItem(Properties properties, IItemProvider grownItem) {
|
||||
public CrystalSeedItem(Settings properties, IItemProvider grownItem) {
|
||||
super(properties);
|
||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||
// Expose the growth of the seed to the model system
|
||||
addPropertyOverride(new Identifier("appliedenergistics2:growth"),
|
||||
(is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED);
|
||||
FabricModelPredicateProviderRegistry.register(
|
||||
this,
|
||||
new Identifier(AppEng.MOD_ID, "growth"),
|
||||
(is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -104,17 +109,17 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
lines.add(ButtonToolTips.DoesntDespawn.getTranslationKey());
|
||||
lines.add(getGrowthTooltipItem(stack));
|
||||
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
}
|
||||
|
||||
public Text getGrowthTooltipItem(ItemStack stack) {
|
||||
final int progress = getGrowthTicks(stack);
|
||||
return new StringTextComponent(Math.round(100 * progress / (float) GROWTH_TICKS_REQUIRED) + "%");
|
||||
return new LiteralText(Math.round(100 * progress / (float) GROWTH_TICKS_REQUIRED) + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,16 +22,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
@@ -52,24 +52,24 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
// rather simple client side caching.
|
||||
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<>();
|
||||
|
||||
public EncodedPatternItem(Properties properties) {
|
||||
public EncodedPatternItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
this.clearPattern(player.getHeldItem(hand), player);
|
||||
this.clearPattern(player.getStackInHand(hand), player);
|
||||
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
return this.clearPattern(stack, context.getPlayer()) ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
}
|
||||
|
||||
private boolean clearPattern(final ItemStack stack, final PlayerEntity player) {
|
||||
if (player.isCrouching()) {
|
||||
if (player.isInSneakingPose()) {
|
||||
if (Platform.isClient()) {
|
||||
return false;
|
||||
}
|
||||
@@ -93,8 +93,8 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
final ICraftingPatternDetails details = this.getPatternForItem(stack, world);
|
||||
|
||||
if (details == null) {
|
||||
@@ -107,35 +107,35 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
InvalidPatternHelper invalid = new InvalidPatternHelper(stack);
|
||||
|
||||
final Text label = (invalid.isCraftable() ? GuiText.Crafts.textComponent()
|
||||
: GuiText.Creates.textComponent()).appendText(": ");
|
||||
final Text and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent())
|
||||
.appendText(" ");
|
||||
final Text with = GuiText.With.textComponent().appendText(": ");
|
||||
: GuiText.Creates.textComponent()).append(": ");
|
||||
final Text and = new LiteralText(" ").append(GuiText.And.textComponent())
|
||||
.append(" ");
|
||||
final Text with = GuiText.With.textComponent().append(": ");
|
||||
|
||||
boolean first = true;
|
||||
for (final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs()) {
|
||||
lines.add((first ? label : and).deepCopy().appendSibling(output.getFormattedToolTip()));
|
||||
lines.add((first ? label : and).deepCopy().append(output.getFormattedToolTip()));
|
||||
first = false;
|
||||
}
|
||||
|
||||
first = true;
|
||||
for (final InvalidPatternHelper.PatternIngredient input : invalid.getInputs()) {
|
||||
lines.add((first ? with : and).deepCopy().appendSibling(input.getFormattedToolTip()));
|
||||
lines.add((first ? with : and).deepCopy().append(input.getFormattedToolTip()));
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (invalid.isCraftable()) {
|
||||
final Text substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final Text substitutionLabel = GuiText.Substitute.textComponent().append(" ");
|
||||
final Text canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent()
|
||||
: GuiText.No.textComponent();
|
||||
|
||||
lines.add(substitutionLabel.appendSibling(canSubstitute));
|
||||
lines.add(substitutionLabel.append(canSubstitute));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack.hasDisplayName()) {
|
||||
if (stack.hasCustomName()) {
|
||||
stack.removeChildTag("display");
|
||||
}
|
||||
|
||||
@@ -146,10 +146,10 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
final IAEItemStack[] out = details.getCondensedOutputs();
|
||||
|
||||
final Text label = (isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent())
|
||||
.appendText(": ");
|
||||
final Text and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent())
|
||||
.appendText(" ");
|
||||
final Text with = GuiText.With.textComponent().appendText(": ");
|
||||
.append(": ");
|
||||
final Text and = new LiteralText(" ").append(GuiText.And.textComponent())
|
||||
.append(" ");
|
||||
final Text with = GuiText.With.textComponent().append(": ");
|
||||
|
||||
boolean first = true;
|
||||
for (final IAEItemStack anOut : out) {
|
||||
@@ -157,8 +157,8 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
continue;
|
||||
}
|
||||
|
||||
lines.add((first ? label : and).deepCopy().appendText(anOut.getStackSize() + "x ")
|
||||
.appendSibling(Platform.getItemDisplayName(anOut)));
|
||||
lines.add((first ? label : and).deepCopy().append(anOut.getStackSize() + "x ")
|
||||
.append(Platform.getItemDisplayName(anOut)));
|
||||
first = false;
|
||||
}
|
||||
|
||||
@@ -168,16 +168,16 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
continue;
|
||||
}
|
||||
|
||||
lines.add((first ? with : and).deepCopy().appendText(anIn.getStackSize() + "x ")
|
||||
.appendSibling(Platform.getItemDisplayName(anIn)));
|
||||
lines.add((first ? with : and).deepCopy().append(anIn.getStackSize() + "x ")
|
||||
.append(Platform.getItemDisplayName(anIn)));
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (isCrafting) {
|
||||
final Text substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final Text substitutionLabel = GuiText.Substitute.textComponent().append(" ");
|
||||
final Text canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent();
|
||||
|
||||
lines.add(substitutionLabel.appendSibling(canSubstitute));
|
||||
lines.add(substitutionLabel.append(canSubstitute));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PaintBallItem extends AEBaseItem {
|
||||
|
||||
private final boolean lumen;
|
||||
|
||||
public PaintBallItem(Properties properties, AEColor color, boolean lumen) {
|
||||
public PaintBallItem(Settings properties, AEColor color, boolean lumen) {
|
||||
super(properties);
|
||||
this.color = color;
|
||||
this.lumen = lumen;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ColoredPartItem<T extends IPart> extends PartItem<T> {
|
||||
|
||||
private final AEColor color;
|
||||
|
||||
public ColoredPartItem(Properties properties, PartType type, Function<ItemStack, T> factory, AEColor color) {
|
||||
public ColoredPartItem(Settings properties, PartType type, Function<ItemStack, T> factory, AEColor color) {
|
||||
super(properties, type, factory);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -57,28 +57,28 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
|
||||
private static final String NBT_ITEM_ID = "item";
|
||||
|
||||
public FacadeItem(Properties properties) {
|
||||
public FacadeItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
return AEApi.instance().partHelper().placeBus(stack, context.getPos(), context.getFace(), context.getPlayer(),
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
return AEApi.instance().partHelper().placeBus(stack, context.getBlockPos(), context.getSide(), context.getPlayer(),
|
||||
context.getHand(), context.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName(ItemStack is) {
|
||||
public Text getName(ItemStack is) {
|
||||
try {
|
||||
final ItemStack in = this.getTextureItem(is);
|
||||
if (!in.isEmpty()) {
|
||||
return super.getDisplayName(is).deepCopy().appendText(" - ").appendSibling(in.getDisplayName());
|
||||
return super.getName(is).deepCopy().append(" - ").append(in.getName());
|
||||
}
|
||||
} catch (final Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return super.getDisplayName(is);
|
||||
return super.getName(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,7 +195,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
return false;
|
||||
}
|
||||
|
||||
return RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucent())
|
||||
|| RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucentNoCrumbling());
|
||||
return RenderTypeLookup.canRenderInLayer(blockState, RenderLayer.getTranslucent())
|
||||
|| RenderTypeLookup.canRenderInLayer(blockState, RenderLayer.getTranslucentNoCrumbling());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -40,21 +40,21 @@ public class PartItem<T extends IPart> extends AEBaseItem implements IPartItem<T
|
||||
|
||||
private final Function<ItemStack, T> factory;
|
||||
|
||||
public PartItem(Properties properties, PartType type, Function<ItemStack, T> factory) {
|
||||
public PartItem(Settings properties, PartType type, Function<ItemStack, T> factory) {
|
||||
super(properties);
|
||||
this.type = type;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUseContext context) {
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack held = player.getHeldItem(context.getHand());
|
||||
ItemStack held = player.getStackInHand(context.getHand());
|
||||
if (held.getItem() != this) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
return AEApi.instance().partHelper().placeBus(held, context.getPos(), context.getFace(), player,
|
||||
return AEApi.instance().partHelper().placeBus(held, context.getBlockPos(), context.getSide(), player,
|
||||
context.getHand(), context.getWorld());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.util.Set;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -65,7 +65,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
protected final MaterialType component;
|
||||
protected final int totalBytes;
|
||||
|
||||
public AbstractStorageCell(Properties properties, final MaterialType whichCell, final int kilobytes) {
|
||||
public AbstractStorageCell(Settings properties, final MaterialType whichCell, final int kilobytes) {
|
||||
super(properties);
|
||||
this.totalBytes = kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
@@ -73,8 +73,8 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
AEApi.instance().client().addCellInformation(
|
||||
AEApi.instance().registries().cell().getCellInventory(stack, null, this.getChannel()), lines);
|
||||
}
|
||||
@@ -141,12 +141,12 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World world, final PlayerEntity player, final Hand hand) {
|
||||
this.disassembleDrive(player.getHeldItem(hand), world, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
this.disassembleDrive(player.getStackInHand(hand), world, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
private boolean disassembleDrive(final ItemStack stack, final World world, final PlayerEntity player) {
|
||||
if (player.isCrouching()) {
|
||||
if (player.isInSneakingPose()) {
|
||||
if (Platform.isClient()) {
|
||||
return false;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
protected abstract void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player);
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
return this.disassembleDrive(stack, context.getWorld(), context.getPlayer()) ? ActionResult.SUCCESS
|
||||
: ActionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class BasicStorageCellItem extends AbstractStorageCell<IAEItemStack
|
||||
protected final int perType;
|
||||
protected final double idleDrain;
|
||||
|
||||
public BasicStorageCellItem(Properties props, final MaterialType whichCell, final int kilobytes) {
|
||||
public BasicStorageCellItem(Settings props, final MaterialType whichCell, final int kilobytes) {
|
||||
super(props, whichCell, kilobytes);
|
||||
switch (whichCell) {
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
@@ -39,7 +39,7 @@ import appeng.items.contents.CellConfig;
|
||||
|
||||
public class CreativeStorageCellItem extends AEBaseItem implements ICellWorkbenchItem {
|
||||
|
||||
public CreativeStorageCellItem(Properties props) {
|
||||
public CreativeStorageCellItem(Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ public class CreativeStorageCellItem extends AEBaseItem implements ICellWorkbenc
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory(stack, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CreativeStorageCellItem extends AEBaseItem implements ICellWorkbenc
|
||||
|
||||
for (final ItemStack is : cc) {
|
||||
if (!is.isEmpty()) {
|
||||
lines.add(is.getDisplayName());
|
||||
lines.add(is.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ package appeng.items.storage;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
@@ -48,15 +48,15 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
|
||||
|
||||
private final int maxRegion;
|
||||
|
||||
public SpatialStorageCellItem(Properties props, final int spatialScale) {
|
||||
public SpatialStorageCellItem(Settings props, final int spatialScale) {
|
||||
super(props);
|
||||
this.maxRegion = spatialScale;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
final DimensionType dimType = this.getStoredDimension(stack);
|
||||
if (dimType == null) {
|
||||
lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC));
|
||||
@@ -67,7 +67,7 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
|
||||
|
||||
if (advancedTooltips.isAdvanced()) {
|
||||
if (dimType != null && dimType.getRegistryName() != null) {
|
||||
lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName()));
|
||||
lines.add(new LiteralText("Dimension: " + dimType.getRegistryName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
public class ViewCellItem extends AEBaseItem implements ICellWorkbenchItem {
|
||||
|
||||
public ViewCellItem(Properties properties) {
|
||||
public ViewCellItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -45,27 +45,27 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
public BiometricCardItem(Properties properties) {
|
||||
public BiometricCardItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (p.isCrouching()) {
|
||||
this.encode(p.getHeldItem(hand), p);
|
||||
if (p.isInSneakingPose()) {
|
||||
this.encode(p.getStackInHand(hand), p);
|
||||
p.swingArm(hand);
|
||||
return TypedActionResult.resultSuccess(p.getHeldItem(hand));
|
||||
return TypedActionResult.resultSuccess(p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
return TypedActionResult.resultPass(p.getHeldItem(hand));
|
||||
return TypedActionResult.resultPass(p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack is, final PlayerEntity player, final LivingEntity target,
|
||||
final Hand hand) {
|
||||
if (target instanceof PlayerEntity && !player.isCrouching()) {
|
||||
if (target instanceof PlayerEntity && !player.isInSneakingPose()) {
|
||||
if (player.isCreative()) {
|
||||
is = player.getHeldItem(hand);
|
||||
is = player.getStackInHand(hand);
|
||||
}
|
||||
this.encode(is, (PlayerEntity) target);
|
||||
player.swingArm(hand);
|
||||
@@ -75,10 +75,10 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName(final ItemStack is) {
|
||||
public Text getName(final ItemStack is) {
|
||||
final GameProfile username = this.getProfile(is);
|
||||
return username != null ? super.getDisplayName(is).appendText(" - " + username.getName())
|
||||
: super.getDisplayName(is);
|
||||
return username != null ? super.getName(is).append(" - " + username.getName())
|
||||
: super.getName(is);
|
||||
}
|
||||
|
||||
private void encode(final ItemStack is, final PlayerEntity p) {
|
||||
@@ -154,8 +154,8 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
final EnumSet<SecurityPermissions> perms = this.getPermissions(stack);
|
||||
if (perms.isEmpty()) {
|
||||
lines.add(new TranslatableText(GuiText.NoPermissions.getLocal()));
|
||||
@@ -166,7 +166,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
if (msg == null) {
|
||||
msg = new TranslatableText(sp.getTranslatedName());
|
||||
} else {
|
||||
msg = msg.appendText(", ").appendSibling(new TranslatableText(sp.getTranslatedName()));
|
||||
msg = msg.append(", ").append(new TranslatableText(sp.getTranslatedName()));
|
||||
}
|
||||
}
|
||||
lines.add(msg);
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.List;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
@@ -52,14 +52,14 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT, };
|
||||
|
||||
public MemoryCardItem(Properties properties) {
|
||||
public MemoryCardItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
String firstLineKey = this.getFirstValidTranslationKey(this.getSettingsName(stack) + ".name",
|
||||
this.getSettingsName(stack));
|
||||
lines.add(new TranslatableText(firstLineKey));
|
||||
@@ -164,9 +164,9 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUseContext context) {
|
||||
if (context.getPlayer().isCrouching()) {
|
||||
if (!context.getPlayer().world.isRemote) {
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
if (context.getPlayer().isInSneakingPose()) {
|
||||
if (!context.getPlayer().world.isClient) {
|
||||
this.clearCard(context.getPlayer(), context.getWorld(), context.getHand());
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
@@ -177,8 +177,8 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(World w, PlayerEntity player, Hand hand) {
|
||||
if (player.isCrouching()) {
|
||||
if (!w.isRemote) {
|
||||
if (player.isInSneakingPose()) {
|
||||
if (!w.isClient) {
|
||||
this.clearCard(player, w, hand);
|
||||
}
|
||||
}
|
||||
@@ -192,8 +192,8 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
}
|
||||
|
||||
private void clearCard(final PlayerEntity player, final World w, final Hand hand) {
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem(hand).getItem();
|
||||
final IMemoryCard mem = (IMemoryCard) player.getStackInHand(hand).getItem();
|
||||
mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
player.getHeldItem(hand).setTag(null);
|
||||
player.getStackInHand(hand).setTag(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
@@ -57,7 +57,7 @@ import appeng.util.Platform;
|
||||
|
||||
public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
|
||||
public NetworkToolItem(Properties properties) {
|
||||
public NetworkToolItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
if (pos == null) {
|
||||
return new NetworkToolViewer(is, null);
|
||||
}
|
||||
final BlockEntity te = world.getTileEntity(pos);
|
||||
final BlockEntity te = world.getBlockEntity(pos);
|
||||
return new NetworkToolViewer(is, (IGridHost) (te instanceof IGridHost ? te : null));
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
}
|
||||
}
|
||||
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
final BlockRayTraceResult mop = new BlockRayTraceResult(context.getHitVec(), context.getFace(),
|
||||
context.getPos(), context.isInside());
|
||||
final BlockEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
final BlockHitResult mop = new BlockHitResult(context.getHitVec(), context.getSide(),
|
||||
context.getBlockPos(), context.isInside());
|
||||
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.getHitVec());
|
||||
@@ -96,7 +96,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
if (part.part != null || part.facade != null) {
|
||||
if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) {
|
||||
return ActionResult.FAIL;
|
||||
} else if (context.getPlayer().isCrouching()) {
|
||||
} else if (context.getPlayer().isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -116,35 +116,35 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean serverSideToolLogic(ItemUseContext useContext) {
|
||||
public boolean serverSideToolLogic(ItemUsageContext useContext) {
|
||||
BlockPos pos = useContext.getPos();
|
||||
PlayerEntity p = useContext.getPlayer();
|
||||
World w = p.world;
|
||||
Hand hand = useContext.getHand();
|
||||
Direction side = useContext.getFace();
|
||||
Direction side = useContext.getSide();
|
||||
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final BlockState bs = w.getBlockState(pos);
|
||||
if (!p.isCrouching()) {
|
||||
final BlockEntity te = w.getTileEntity(pos);
|
||||
if (!p.isInSneakingPose()) {
|
||||
final BlockEntity te = w.getBlockEntity(pos);
|
||||
if (!(te instanceof IGridHost)) {
|
||||
if (bs.rotate(w, pos, Rotation.CLOCKWISE_90) != bs) {
|
||||
bs.neighborChanged(w, pos, Blocks.AIR, pos, false);
|
||||
p.swingArm(hand);
|
||||
return !w.isRemote;
|
||||
return !w.isClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.isCrouching()) {
|
||||
if (!p.isInSneakingPose()) {
|
||||
if (p.openContainer instanceof AEBaseContainer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlockEntity te = w.getTileEntity(pos);
|
||||
final BlockEntity te = w.getBlockEntity(pos);
|
||||
|
||||
if (te instanceof IGridHost) {
|
||||
ContainerOpener.openContainer(NetworkStatusContainer.TYPE, p,
|
||||
@@ -155,8 +155,8 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
BlockRayTraceResult rtr = new BlockRayTraceResult(useContext.getHitVec(), side, pos, false);
|
||||
bs.onBlockActivated(w, p, hand, rtr);
|
||||
BlockHitResult rtr = new BlockHitResult(useContext.getHitVec(), side, pos, false);
|
||||
bs.onUse(w, p, hand, rtr);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -33,7 +33,7 @@ import appeng.util.Platform;
|
||||
|
||||
public class ChargedStaffItem extends AEBasePoweredItem {
|
||||
|
||||
public ChargedStaffItem(Item.Properties props) {
|
||||
public ChargedStaffItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getChargedStaffBattery(), props);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,37 +18,7 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -75,9 +45,37 @@ import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.misc.PaintBallItem;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.tile.misc.PaintSplotchesTileEntity;
|
||||
import appeng.tile.misc.PaintSplotchesBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem {
|
||||
@@ -102,24 +100,28 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
public ColorApplicatorItem(Item.Properties props) {
|
||||
public ColorApplicatorItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getColorApplicatorBattery(), props);
|
||||
addPropertyOverride(new Identifier(AppEng.MOD_ID, "colored"), (itemStack, world, entity) -> {
|
||||
// If the stack has no color, don't use the colored model since the impact of
|
||||
// calling getColor for every quad is extremely high, if the stack tries to
|
||||
// re-search its
|
||||
// inventory for a new paintball everytime
|
||||
AEColor col = getActiveColor(itemStack);
|
||||
return (col != null) ? 1 : 0;
|
||||
});
|
||||
FabricModelPredicateProviderRegistry.register(
|
||||
this,
|
||||
new Identifier(AppEng.MOD_ID, "colored"),
|
||||
(itemStack, world, entity) -> {
|
||||
// If the stack has no color, don't use the colored model since the impact of
|
||||
// calling getColor for every quad is extremely high, if the stack tries to
|
||||
// re-search its
|
||||
// inventory for a new paintball everytime
|
||||
AEColor col = getActiveColor(itemStack);
|
||||
return (col != null) ? 1 : 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUseContext context) {
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
World w = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
ItemStack is = context.getItem();
|
||||
Direction side = context.getFace();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
ItemStack is = context.getStack();
|
||||
Direction side = context.getSide();
|
||||
PlayerEntity p = context.getPlayer(); // This can be null
|
||||
if (p == null && w instanceof ServerWorld) {
|
||||
p = Platform.getPlayer((ServerWorld) w);
|
||||
@@ -148,7 +150,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
|
||||
final double powerPerUse = 100;
|
||||
if (!paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem) {
|
||||
final BlockEntity te = w.getTileEntity(pos);
|
||||
final BlockEntity te = w.getBlockEntity(pos);
|
||||
// clean cables.
|
||||
if (te instanceof IColorableTile && p != null) {
|
||||
if (this.getAECurrentPower(is) > powerPerUse
|
||||
@@ -164,12 +166,12 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
|
||||
// clean paint balls..
|
||||
final Block testBlk = w.getBlockState(pos.offset(side)).getBlock();
|
||||
final BlockEntity painted = w.getTileEntity(pos.offset(side));
|
||||
final BlockEntity painted = w.getBlockEntity(pos.offset(side));
|
||||
if (this.getAECurrentPower(is) > powerPerUse && testBlk instanceof PaintSplotchesBlock
|
||||
&& painted instanceof PaintSplotchesTileEntity) {
|
||||
&& painted instanceof PaintSplotchesBlockEntity) {
|
||||
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource());
|
||||
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
|
||||
((PaintSplotchesTileEntity) painted).cleanSide(side.getOpposite());
|
||||
((PaintSplotchesBlockEntity) painted).cleanSide(side.getOpposite());
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
} else if (!paintBall.isEmpty()) {
|
||||
@@ -186,7 +188,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
}
|
||||
}
|
||||
|
||||
if (p != null && p.isCrouching()) {
|
||||
if (p != null && p.isInSneakingPose()) {
|
||||
this.cycleColors(is, paintBall, 1);
|
||||
}
|
||||
|
||||
@@ -194,7 +196,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName(final ItemStack is) {
|
||||
public Text getName(final ItemStack is) {
|
||||
Text extra = GuiText.Empty.textComponent();
|
||||
|
||||
final AEColor selected = this.getActiveColor(is);
|
||||
@@ -203,7 +205,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
extra = new TranslatableText(selected.translationKey);
|
||||
}
|
||||
|
||||
return super.getDisplayName(is).appendText(" - ").appendSibling(extra);
|
||||
return super.getName(is).append(" - ").append(extra);
|
||||
}
|
||||
|
||||
public AEColor getActiveColor(final ItemStack tol) {
|
||||
@@ -331,11 +333,22 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
return w.setBlockState(pos, newState);
|
||||
}
|
||||
|
||||
BlockEntity be = w.getBlockEntity(pos);
|
||||
if (be instanceof IColorableTile) {
|
||||
IColorableTile ct = (IColorableTile) be;
|
||||
AEColor c = ct.getColor();
|
||||
if (c != newColor) {
|
||||
ct.recolourBlock(side, newColor, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blk instanceof CableBusBlock && p != null) {
|
||||
return ((CableBusBlock) blk).recolorBlock(w, pos, side, newColor.dye, p);
|
||||
}
|
||||
|
||||
return blk.recolorBlock(state, w, pos, side, newColor.dye);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> BlockState copyProp(BlockState oldState, BlockState newState,
|
||||
@@ -356,9 +369,9 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory(stack,
|
||||
null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
@@ -36,8 +36,8 @@ import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.World;
|
||||
@@ -57,7 +57,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> heatUp;
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> coolDown;
|
||||
|
||||
public EntropyManipulatorItem(Item.Properties props) {
|
||||
public EntropyManipulatorItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getEntropyManipulatorBattery(), props);
|
||||
|
||||
this.heatUp = new HashMap<>();
|
||||
@@ -138,7 +138,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
Platform.spawnDrops(w, pos, r.getDrops());
|
||||
}
|
||||
|
||||
if (!w.isRemote) {
|
||||
if (!w.isClient) {
|
||||
// Same effect as emptying a water bucket in the nether (see BucketItem)
|
||||
w.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F,
|
||||
2.6F + (w.rand.nextFloat() - w.rand.nextFloat()) * 0.8F);
|
||||
@@ -206,31 +206,31 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
final HitResult target = rayTrace(w, p, RayTraceContext.FluidMode.ANY);
|
||||
|
||||
if (target.getType() != HitResult.Type.BLOCK) {
|
||||
return new TypedActionResult<>(ActionResult.FAIL, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, p.getStackInHand(hand));
|
||||
} else {
|
||||
BlockPos pos = ((BlockRayTraceResult) target).getPos();
|
||||
BlockPos pos = ((BlockHitResult) target).getPos();
|
||||
final BlockState state = w.getBlockState(pos);
|
||||
if (state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER) {
|
||||
if (Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
ItemUseContext context = new ItemUseContext(p, hand, (BlockRayTraceResult) target);
|
||||
ItemUsageContext context = new ItemUsageContext(p, hand, (BlockHitResult) target);
|
||||
this.onItemUse(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUseContext context) {
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
World w = context.getWorld();
|
||||
ItemStack item = context.getItem();
|
||||
BlockPos pos = context.getPos();
|
||||
Direction side = context.getFace();
|
||||
ItemStack item = context.getStack();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
Direction side = context.getSide();
|
||||
PlayerEntity p = context.getPlayer();
|
||||
boolean tryBoth = false;
|
||||
if (p == null) {
|
||||
if (w.isRemote) {
|
||||
if (w.isClient) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
p = Platform.getPlayer((ServerWorld) w);
|
||||
@@ -247,17 +247,17 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
final Block block = w.getBlockState(pos).getBlock();
|
||||
final Fluid fluid = w.getFluidState(pos).getFluid();
|
||||
|
||||
if (tryBoth || p.isCrouching()) {
|
||||
if (tryBoth || p.isInSneakingPose()) {
|
||||
if (this.canCool(block, fluid)) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
this.cool(block, fluid, w, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
if (tryBoth || !p.isCrouching()) {
|
||||
if (tryBoth || !p.isInSneakingPose()) {
|
||||
if (block instanceof TNTBlock) {
|
||||
w.removeBlock(pos, false);
|
||||
block.catchFire(w.getBlockState(pos), w, pos, context.getFace(), p);
|
||||
block.catchFire(w.getBlockState(pos), w, pos, context.getSide(), p);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
@@ -42,7 +42,7 @@ import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
@@ -77,7 +77,7 @@ import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.misc.PaintBallItem;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.helpers.PlayerSource;
|
||||
import appeng.tile.misc.PaintSplotchesTileEntity;
|
||||
import appeng.tile.misc.PaintSplotchesBlockEntity;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -88,15 +88,15 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
*/
|
||||
private static final int ENERGY_PER_SHOT = 1600;
|
||||
|
||||
public MatterCannonItem(Item.Properties props) {
|
||||
public MatterCannonItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getMatterCannonBattery(), props);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory(stack,
|
||||
null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
@@ -106,16 +106,16 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) {
|
||||
if (this.getAECurrentPower(p.getHeldItem(hand)) > ENERGY_PER_SHOT) {
|
||||
if (this.getAECurrentPower(p.getStackInHand(hand)) > ENERGY_PER_SHOT) {
|
||||
int shots = 1;
|
||||
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory(p.getHeldItem(hand));
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory(p.getStackInHand(hand));
|
||||
if (cu != null) {
|
||||
shots += cu.getInstalledUpgrades(Upgrades.SPEED);
|
||||
}
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory(
|
||||
p.getHeldItem(hand), null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
p.getStackInHand(hand), null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
if (inv != null) {
|
||||
final IItemList<IAEItemStack> itemList = inv.getAvailableItems(
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
|
||||
@@ -124,21 +124,21 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
shots = Math.min(shots, (int) req.getStackSize());
|
||||
for (int sh = 0; sh < shots; sh++) {
|
||||
IAEItemStack aeAmmo = req.copy();
|
||||
this.extractAEPower(p.getHeldItem(hand), ENERGY_PER_SHOT, Actionable.MODULATE);
|
||||
this.extractAEPower(p.getStackInHand(hand), ENERGY_PER_SHOT, Actionable.MODULATE);
|
||||
|
||||
if (Platform.isClient()) {
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
aeAmmo.setStackSize(1);
|
||||
final ItemStack ammo = aeAmmo.createItemStack();
|
||||
if (ammo.isEmpty()) {
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
aeAmmo = inv.extractItems(aeAmmo, Actionable.MODULATE, new PlayerSource(p, null));
|
||||
if (aeAmmo == null) {
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
final LookDirection dir = Platform.getPlayerRay(p, 32);
|
||||
@@ -158,7 +158,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
if (type.getItem() instanceof PaintBallItem) {
|
||||
this.shootPaintBalls(type, w, p, rayFrom, rayTo, direction, d0, d1, d2);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
} else {
|
||||
this.standardAmmo(penetration, w, p, rayFrom, rayTo, direction, d0, d1, d2);
|
||||
}
|
||||
@@ -167,11 +167,11 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
if (Platform.isServer()) {
|
||||
p.sendMessage(PlayerMessages.AmmoDepleted.get());
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.FAIL, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
private void shootPaintBalls(final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d,
|
||||
@@ -255,9 +255,9 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
|
||||
entityHit.attackEntityFrom(DamageSource.causePlayerDamage(p), 0);
|
||||
NetworkHandler.instance().sendToAll(marker.getPacket());
|
||||
} else if (pos instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
final Direction side = blockResult.getFace();
|
||||
} else if (pos instanceof BlockHitResult) {
|
||||
BlockHitResult blockResult = (BlockHitResult) pos;
|
||||
final Direction side = blockResult.getSide();
|
||||
final BlockPos hitPos = blockResult.getPos().offset(side);
|
||||
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, hitPos), p)) {
|
||||
@@ -271,10 +271,10 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
});
|
||||
}
|
||||
|
||||
final BlockEntity te = w.getTileEntity(hitPos);
|
||||
if (te instanceof PaintSplotchesTileEntity) {
|
||||
final BlockEntity te = w.getBlockEntity(hitPos);
|
||||
if (te instanceof PaintSplotchesBlockEntity) {
|
||||
final Vec3d hp = pos.getHitVec().subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ());
|
||||
((PaintSplotchesTileEntity) te).addBlot(type, side.getOpposite(), hp);
|
||||
((PaintSplotchesBlockEntity) te).addBlot(type, side.getOpposite(), hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,8 +367,8 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
} else if (entityHit.attackEntityFrom(dmgSrc, dmg)) {
|
||||
hasDestroyed = true;
|
||||
}
|
||||
} else if (pos instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
} else if (pos instanceof BlockHitResult) {
|
||||
BlockHitResult blockResult = (BlockHitResult) pos;
|
||||
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.MASS_CANNON_BLOCK_DAMAGE)) {
|
||||
penetration = 0;
|
||||
@@ -383,7 +383,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
hasDestroyed = true;
|
||||
penetration -= hardness;
|
||||
penetration *= 0.60;
|
||||
w.destroyBlock(blockPos, true);
|
||||
w.breakBlock(blockPos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.items.tools.powered;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -56,21 +56,21 @@ import appeng.items.contents.PortableCellViewer;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
|
||||
public class PortableCellItem extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup {
|
||||
public PortableCellItem(Item.Properties props) {
|
||||
public PortableCellItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getPortableCellBattery(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
ContainerOpener.openContainer(MEPortableCellContainer.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory(stack,
|
||||
null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -36,7 +36,6 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
@@ -49,21 +48,21 @@ import appeng.util.ConfigManager;
|
||||
|
||||
public class WirelessTerminalItem extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public WirelessTerminalItem(Item.Properties props) {
|
||||
public WirelessTerminalItem(Item.Settings props) {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player, hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getStackInHand(hand), w, player, hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
super.appendTooltip(stack, world, lines, advancedTooltips);
|
||||
|
||||
if (stack.hasTag()) {
|
||||
final CompoundTag tag = stack.getOrCreateTag();
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -46,7 +46,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
|
||||
private static final String MAX_POWER_NBT_KEY = "internalMaxPower";
|
||||
private final DoubleSupplier powerCapacity;
|
||||
|
||||
public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props) {
|
||||
public AEBasePoweredItem(final DoubleSupplier powerCapacity, Settings props) {
|
||||
super(props);
|
||||
// FIXME this.setFull3D();
|
||||
|
||||
@@ -55,8 +55,8 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
|
||||
final TooltipContext advancedTooltips) {
|
||||
final CompoundTag tag = stack.getTag();
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getAEMaxPower(stack);
|
||||
@@ -68,9 +68,9 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
|
||||
final double percent = internalCurrentPower / internalMaxPower;
|
||||
|
||||
lines.add(GuiText.StoredEnergy.textComponent()
|
||||
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
|
||||
.appendSibling(new TranslatableText(PowerUnits.AE.unlocalizedName))
|
||||
.appendText(" - " + MessageFormat.format(" {0,number,#.##%} ", percent)));
|
||||
.append(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
|
||||
.append(new TranslatableText(PowerUnits.AE.unlocalizedName))
|
||||
.append(" - " + MessageFormat.format(" {0,number,#.##%} ", percent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.util.Platform;
|
||||
public class QuartzAxeItem extends AxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzAxeItem(Item.Properties props, final AEFeature type) {
|
||||
public QuartzAxeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 6.0F, -3.1F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.items.tools.quartz;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -41,13 +41,13 @@ import appeng.util.Platform;
|
||||
public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzCuttingKnifeItem(Item.Properties props, final AEFeature type) {
|
||||
public QuartzCuttingKnifeItem(Item.Settings props, final AEFeature type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUseContext context) {
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (Platform.isServer() && player != null) {
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, context.getPlayer(),
|
||||
@@ -62,7 +62,7 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
p.swingArm(hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.util.Platform;
|
||||
public class QuartzHoeItem extends HoeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzHoeItem(Item.Properties props, final AEFeature type) {
|
||||
public QuartzHoeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, -1.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.util.Platform;
|
||||
public class QuartzPickaxeItem extends PickaxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzPickaxeItem(Item.Properties props, final AEFeature type) {
|
||||
public QuartzPickaxeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 1, -2.8F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.util.Platform;
|
||||
public class QuartzSpadeItem extends ShovelItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzSpadeItem(Item.Properties props, final AEFeature type) {
|
||||
public QuartzSpadeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 1.5F, -3.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.util.Platform;
|
||||
public class QuartzSwordItem extends SwordItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzSwordItem(Item.Properties props, AEFeature type) {
|
||||
public QuartzSwordItem(Item.Settings props, AEFeature type) {
|
||||
super(ItemTier.IRON, 3, -2.4F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -34,27 +34,27 @@ import appeng.util.Platform;
|
||||
|
||||
public class QuartzWrenchItem extends AEBaseItem implements IAEWrench {
|
||||
|
||||
public QuartzWrenchItem(Item.Properties props) {
|
||||
public QuartzWrenchItem(Item.Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (!context.getPlayer().isCrouching() && Platform
|
||||
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getPos()), context.getPlayer())) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (!context.getPlayer().isInSneakingPose() && Platform
|
||||
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getBlockPos()), context.getPlayer())) {
|
||||
|
||||
Block block = context.getWorld().getBlockState(context.getPos()).getBlock();
|
||||
Block block = context.getWorld().getBlockState(context.getBlockPos()).getBlock();
|
||||
if (block instanceof AEBaseBlock) {
|
||||
if (Platform.isClient()) {
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server.
|
||||
// Fix that in all Block#onItemUseFirst overrides.
|
||||
return !context.getWorld().isRemote ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) {
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getFace())) {
|
||||
context.getPlayer().swingArm(context.getHand());
|
||||
return !context.getWorld().isRemote ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user