Migrations

This commit is contained in:
Sebastian Hartte
2020-06-27 16:18:20 +02:00
parent d638d083c2
commit ba71a82288
303 changed files with 1216 additions and 1210 deletions
@@ -19,7 +19,7 @@
package appeng.items.contents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -86,7 +86,7 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final CompoundNBT data = this.target.getOrCreateTag();
final CompoundTag data = this.target.getOrCreateTag();
manager.writeToNBT(data);
});
@@ -31,9 +31,9 @@ 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.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -78,7 +78,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
super.addInformation(stack, world, lines, advancedTooltips);
if (materialType == MaterialType.NAME_PRESS) {
final CompoundNBT c = stack.getOrCreateTag();
final CompoundTag c = stack.getOrCreateTag();
if (c.contains(TAG_INSCRIBE_NAME)) {
lines.add(new StringTextComponent(c.getString(TAG_INSCRIBE_NAME)));
}
@@ -138,7 +138,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
}
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
PlayerEntity player = context.getPlayer();
Hand hand = context.getHand();
if (player.isCrouching()) {
@@ -161,12 +161,12 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
if (u != null) {
if (player.world.isRemote) {
return ActionResultType.PASS;
return ActionResult.PASS;
}
final InventoryAdaptor ad = new AdaptorItemHandler(upgrades);
player.setHeldItem(hand, ad.addItems(player.getHeldItem(hand)));
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
}
}
@@ -25,12 +25,12 @@ import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
@@ -88,7 +88,7 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
}
private static int getGrowthTicks(final ItemStack is) {
CompoundNBT tag = is.getTag();
CompoundTag tag = is.getTag();
return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0;
}
@@ -27,8 +27,8 @@ 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.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -57,15 +57,15 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
this.clearPattern(player.getHeldItem(hand), player);
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
return this.clearPattern(stack, context.getPlayer()) ? ActionResultType.SUCCESS : ActionResultType.PASS;
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
return this.clearPattern(stack, context.getPlayer()) ? ActionResult.SUCCESS : ActionResult.PASS;
}
private boolean clearPattern(final ItemStack stack, final PlayerEntity player) {
@@ -25,10 +25,10 @@ import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.item.*;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ActionResult;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
@@ -62,7 +62,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
}
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
return AEApi.instance().partHelper().placeBus(stack, context.getPos(), context.getFace(), context.getPlayer(),
context.getHand(), context.getWorld());
}
@@ -117,7 +117,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
}
final ItemStack is = new ItemStack(this);
final CompoundNBT data = new CompoundNBT();
final CompoundTag data = new CompoundTag();
data.putString(NBT_ITEM_ID, itemStack.getItem().getRegistryName().toString());
is.setTag(data);
return is;
@@ -136,7 +136,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
@Override
public ItemStack getTextureItem(ItemStack is) {
CompoundNBT nbt = is.getTag();
CompoundTag nbt = is.getTag();
if (nbt == null) {
return ItemStack.EMPTY;
@@ -180,7 +180,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
return ItemStack.EMPTY;
}
final CompoundNBT facadeTag = new CompoundNBT();
final CompoundTag facadeTag = new CompoundTag();
facadeTag.putString(NBT_ITEM_ID, item.getRegistryName().toString());
facadeStack.setTag(facadeTag);
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ActionResult;
import appeng.api.AEApi;
import appeng.api.implementations.items.IItemGroup;
@@ -47,11 +47,11 @@ public class PartItem<T extends IPart> extends AEBaseItem implements IPartItem<T
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
public ActionResult onItemUse(ItemUseContext context) {
PlayerEntity player = context.getPlayer();
ItemStack held = player.getHeldItem(context.getHand());
if (held.getItem() != this) {
return ActionResultType.PASS;
return ActionResult.PASS;
}
return AEApi.instance().partHelper().placeBus(held, context.getPos(), context.getFace(), player,
@@ -26,8 +26,8 @@ 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.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
@@ -140,9 +140,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World world, final PlayerEntity player, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World world, final PlayerEntity player, final Hand hand) {
this.disassembleDrive(player.getHeldItem(hand), world, player);
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
}
private boolean disassembleDrive(final ItemStack stack, final World world, final PlayerEntity player) {
@@ -193,9 +193,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
protected abstract void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player);
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
return this.disassembleDrive(stack, context.getWorld(), context.getPlayer()) ? ActionResultType.SUCCESS
: ActionResultType.PASS;
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
return this.disassembleDrive(stack, context.getWorld(), context.getPlayer()) ? ActionResult.SUCCESS
: ActionResult.PASS;
}
@Override
@@ -22,7 +22,7 @@ import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -84,7 +84,7 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
@Override
public DimensionType getStoredDimension(final ItemStack is) {
final CompoundNBT c = is.getTag();
final CompoundTag c = is.getTag();
if (c != null && c.contains(TAG_DIMENSION_ID)) {
try {
ResourceLocation dimTypeId = new ResourceLocation(c.getString(TAG_DIMENSION_ID));
@@ -146,7 +146,7 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
}
private void setStoredDimension(final ItemStack is, DimensionType dim) {
final CompoundNBT c = is.getOrCreateTag();
final CompoundTag c = is.getOrCreateTag();
c.putString(TAG_DIMENSION_ID, dim.getRegistryName().toString());
}
}
@@ -27,9 +27,9 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
@@ -50,14 +50,14 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
if (p.isCrouching()) {
this.encode(p.getHeldItem(hand), p);
p.swingArm(hand);
return ActionResult.resultSuccess(p.getHeldItem(hand));
return TypedActionResult.resultSuccess(p.getHeldItem(hand));
}
return ActionResult.resultPass(p.getHeldItem(hand));
return TypedActionResult.resultPass(p.getHeldItem(hand));
}
@Override
@@ -93,10 +93,10 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
@Override
public void setProfile(final ItemStack itemStack, final GameProfile profile) {
final CompoundNBT tag = itemStack.getOrCreateTag();
final CompoundTag tag = itemStack.getOrCreateTag();
if (profile != null) {
final CompoundNBT pNBT = new CompoundNBT();
final CompoundTag pNBT = new CompoundTag();
NBTUtil.writeGameProfile(pNBT, profile);
tag.put("profile", pNBT);
} else {
@@ -106,7 +106,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
@Override
public GameProfile getProfile(final ItemStack is) {
final CompoundNBT tag = is.getOrCreateTag();
final CompoundTag tag = is.getOrCreateTag();
if (tag.contains("profile")) {
return NBTUtil.readGameProfile(tag.getCompound("profile"));
}
@@ -115,7 +115,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
@Override
public EnumSet<SecurityPermissions> getPermissions(final ItemStack is) {
final CompoundNBT tag = is.getOrCreateTag();
final CompoundTag tag = is.getOrCreateTag();
final EnumSet<SecurityPermissions> result = EnumSet.noneOf(SecurityPermissions.class);
for (final SecurityPermissions sp : SecurityPermissions.values()) {
@@ -129,13 +129,13 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
@Override
public boolean hasPermission(final ItemStack is, final SecurityPermissions permission) {
final CompoundNBT tag = is.getOrCreateTag();
final CompoundTag tag = is.getOrCreateTag();
return tag.getBoolean(permission.name());
}
@Override
public void removePermission(final ItemStack itemStack, final SecurityPermissions permission) {
final CompoundNBT tag = itemStack.getOrCreateTag();
final CompoundTag tag = itemStack.getOrCreateTag();
if (tag.contains(permission.name())) {
tag.remove(permission.name());
}
@@ -143,7 +143,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
@Override
public void addPermission(final ItemStack itemStack, final SecurityPermissions permission) {
final CompoundNBT tag = itemStack.getOrCreateTag();
final CompoundTag tag = itemStack.getOrCreateTag();
tag.putBoolean(permission.name(), true);
}
@@ -25,9 +25,9 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -64,7 +64,7 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
this.getSettingsName(stack));
lines.add(new TranslationTextComponent(firstLineKey));
final CompoundNBT data = this.getData(stack);
final CompoundTag data = this.getData(stack);
if (data.contains("tooltip")) {
String tooltipKey = getFirstValidTranslationKey(data.getString("tooltip") + ".name",
data.getString("tooltip"));
@@ -101,29 +101,29 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
}
@Override
public void setMemoryCardContents(final ItemStack is, final String settingsName, final CompoundNBT data) {
final CompoundNBT c = is.getOrCreateTag();
public void setMemoryCardContents(final ItemStack is, final String settingsName, final CompoundTag data) {
final CompoundTag c = is.getOrCreateTag();
c.putString("Config", settingsName);
c.put("Data", data);
}
@Override
public String getSettingsName(final ItemStack is) {
final CompoundNBT c = is.getOrCreateTag();
final CompoundTag c = is.getOrCreateTag();
final String name = c.getString("Config");
return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name;
}
@Override
public CompoundNBT getData(final ItemStack is) {
final CompoundNBT c = is.getOrCreateTag();
CompoundNBT o = c.getCompound("Data");
public CompoundTag getData(final ItemStack is) {
final CompoundTag c = is.getOrCreateTag();
CompoundTag o = c.getCompound("Data");
return o.copy();
}
@Override
public AEColor[] getColorCode(ItemStack is) {
final CompoundNBT tag = this.getData(is);
final CompoundTag tag = this.getData(is);
if (tag.contains("colorCode")) {
final int[] frequency = tag.getIntArray("colorCode");
@@ -164,19 +164,19 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
public ActionResult onItemUse(ItemUseContext context) {
if (context.getPlayer().isCrouching()) {
if (!context.getPlayer().world.isRemote) {
this.clearCard(context.getPlayer(), context.getWorld(), context.getHand());
}
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
} else {
return super.onItemUse(context);
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World w, PlayerEntity player, Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World w, PlayerEntity player, Hand hand) {
if (player.isCrouching()) {
if (!w.isRemote) {
this.clearCard(player, w, hand);
@@ -24,9 +24,9 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
@@ -72,7 +72,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
if (Platform.isClient()) {
final RayTraceResult mop = AppEng.proxy.getRTR();
@@ -81,11 +81,11 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
}
}
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
final BlockRayTraceResult mop = new BlockRayTraceResult(context.getHitVec(), context.getFace(),
context.getPos(), context.isInside());
final TileEntity te = context.getWorld().getTileEntity(context.getPos());
@@ -95,20 +95,20 @@ 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 ActionResultType.FAIL;
return ActionResult.FAIL;
} else if (context.getPlayer().isCrouching()) {
return ActionResultType.PASS;
return ActionResult.PASS;
}
}
} else if (te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo(mop)) {
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
if (Platform.isClient()) {
NetworkHandler.instance().sendToServer(new ClickPacket(context));
}
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
@Override
@@ -32,13 +32,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.SnowballItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.state.IProperty;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -115,7 +115,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
public ActionResult onItemUse(ItemUseContext context) {
World w = context.getWorld();
BlockPos pos = context.getPos();
ItemStack is = context.getItem();
@@ -143,7 +143,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
}
if (p != null && !Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
final double powerPerUse = 100;
@@ -157,7 +157,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE,
new BaseActionSource());
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
}
}
@@ -170,7 +170,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource());
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
((PaintSplotchesTileEntity) painted).cleanSide(side.getOpposite());
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
} else if (!paintBall.isEmpty()) {
final AEColor color = this.getColorFromItem(paintBall);
@@ -180,7 +180,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE,
new BaseActionSource());
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
}
}
@@ -190,7 +190,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
this.cycleColors(is, paintBall, 1);
}
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
@Override
@@ -235,9 +235,9 @@ public class ColorApplicatorItem extends AEBasePoweredItem
}
public ItemStack getColor(final ItemStack is) {
final CompoundNBT c = is.getTag();
final CompoundTag c = is.getTag();
if (c != null && c.contains(TAG_COLOR)) {
final CompoundNBT color = c.getCompound(TAG_COLOR);
final CompoundTag color = c.getCompound(TAG_COLOR);
final ItemStack oldColor = ItemStack.read(color);
if (!oldColor.isEmpty()) {
return oldColor;
@@ -307,11 +307,11 @@ public class ColorApplicatorItem extends AEBasePoweredItem
}
private void setColor(final ItemStack is, final ItemStack newColor) {
final CompoundNBT data = is.getOrCreateTag();
final CompoundTag data = is.getOrCreateTag();
if (newColor.isEmpty()) {
data.remove(TAG_COLOR);
} else {
final CompoundNBT color = new CompoundNBT();
final CompoundTag color = new CompoundTag();
newColor.write(color);
data.put(TAG_COLOR, color);
}
@@ -24,7 +24,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.TNTBlock;
import net.minecraft.block.material.Material;
import net.minecraft.block.Material;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
@@ -202,11 +202,11 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
// Overridden to allow use of the item on WATER and LAVA which are otherwise not
// considered for onItemUse
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
final RayTraceResult target = rayTrace(w, p, RayTraceContext.FluidMode.ANY);
if (target.getType() != RayTraceResult.Type.BLOCK) {
return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.FAIL, p.getHeldItem(hand));
} else {
BlockPos pos = ((BlockRayTraceResult) target).getPos();
final BlockState state = w.getBlockState(pos);
@@ -218,11 +218,11 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
}
}
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
public ActionResult onItemUse(ItemUseContext context) {
World w = context.getWorld();
ItemStack item = context.getItem();
BlockPos pos = context.getPos();
@@ -231,7 +231,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
boolean tryBoth = false;
if (p == null) {
if (w.isRemote) {
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
p = Platform.getPlayer((ServerWorld) w);
// Fake players cannot crouch and we cannot communicate whether they want to
@@ -241,7 +241,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
if (this.getAECurrentPower(item) > 1600) {
if (!p.canPlayerEdit(pos, side, item)) {
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
final Block block = w.getBlockState(pos).getBlock();
@@ -251,26 +251,26 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
if (this.canCool(block, fluid)) {
this.extractAEPower(item, 1600, Actionable.MODULATE);
this.cool(block, fluid, w, pos);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
}
if (tryBoth || !p.isCrouching()) {
if (block instanceof TNTBlock) {
w.removeBlock(pos, false);
block.catchFire(w.getBlockState(pos), w, pos, context.getFace(), p);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
if (block instanceof TinyTNTBlock) {
w.removeBlock(pos, false);
((TinyTNTBlock) block).startFuse(w, pos, p);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
if (this.canHeat(block, fluid)) {
this.extractAEPower(item, 1600, Actionable.MODULATE);
this.heat(block, fluid, w, pos);
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
final ItemStack[] stack = Platform.getBlockDrops(w, pos);
@@ -317,12 +317,12 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
Platform.spawnDrops(w, pos, or.getDrops());
}
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
} else {
final BlockPos offsetPos = pos.offset(side);
if (!p.canPlayerEdit(offsetPos, side, item)) {
return ActionResultType.FAIL;
return ActionResult.FAIL;
}
if (w.isAirBlock(offsetPos)) {
@@ -333,11 +333,11 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
w.setBlockState(offsetPos, Blocks.FIRE.getDefaultState());
}
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
}
}
return ActionResultType.PASS;
return ActionResult.PASS;
}
}
@@ -32,10 +32,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Direction;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
@@ -105,7 +105,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) {
if (this.getAECurrentPower(p.getHeldItem(hand)) > ENERGY_PER_SHOT) {
int shots = 1;
@@ -127,18 +127,18 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
this.extractAEPower(p.getHeldItem(hand), ENERGY_PER_SHOT, Actionable.MODULATE);
if (Platform.isClient()) {
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
aeAmmo.setStackSize(1);
final ItemStack ammo = aeAmmo.createItemStack();
if (ammo.isEmpty()) {
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
aeAmmo = inv.extractItems(aeAmmo, Actionable.MODULATE, new PlayerSource(p, null));
if (aeAmmo == null) {
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(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 ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(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 ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
}
}
return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.FAIL, p.getHeldItem(hand));
}
private void shootPaintBalls(final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d,
@@ -25,8 +25,8 @@ 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.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -61,9 +61,9 @@ public class PortableCellItem extends AEBasePoweredItem implements IStorageCell<
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
ContainerOpener.openContainer(MEPortableCellContainer.TYPE, player, ContainerLocator.forHand(player, hand));
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -24,9 +24,9 @@ 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.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
@@ -54,9 +54,9 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
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 ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -66,7 +66,7 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless
super.addInformation(stack, world, lines, advancedTooltips);
if (stack.hasTag()) {
final CompoundNBT tag = stack.getOrCreateTag();
final CompoundTag tag = stack.getOrCreateTag();
if (tag != null) {
final String encKey = tag.getString("encryptionKey");
@@ -99,7 +99,7 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless
@Override
public IConfigManager getConfigManager(final ItemStack target) {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final CompoundNBT data = target.getOrCreateTag();
final CompoundTag data = target.getOrCreateTag();
manager.writeToNBT(data);
});
@@ -113,13 +113,13 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless
@Override
public String getEncryptionKey(final ItemStack item) {
final CompoundNBT tag = item.getOrCreateTag();
final CompoundTag tag = item.getOrCreateTag();
return tag.getString("encryptionKey");
}
@Override
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
final CompoundNBT tag = item.getOrCreateTag();
final CompoundTag tag = item.getOrCreateTag();
tag.putString("encryptionKey", encKey);
tag.putString("name", name);
}
@@ -25,7 +25,7 @@ import java.util.function.DoubleSupplier;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
@@ -57,7 +57,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
@Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
final ITooltipFlag advancedTooltips) {
final CompoundNBT tag = stack.getTag();
final CompoundTag tag = stack.getTag();
double internalCurrentPower = 0;
final double internalMaxPower = this.getAEMaxPower(stack);
@@ -84,7 +84,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
if (this.isInGroup(group)) {
final ItemStack charged = new ItemStack(this, 1);
final CompoundNBT tag = charged.getOrCreateTag();
final CompoundTag tag = charged.getOrCreateTag();
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged));
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged));
@@ -115,7 +115,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
final double overflow = amount - required;
if (mode == Actionable.MODULATE) {
final CompoundNBT data = is.getOrCreateTag();
final CompoundTag data = is.getOrCreateTag();
final double toAdd = Math.min(amount, required);
data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage + toAdd);
@@ -130,7 +130,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
final double fulfillable = Math.min(amount, currentStorage);
if (mode == Actionable.MODULATE) {
final CompoundNBT data = is.getOrCreateTag();
final CompoundTag data = is.getOrCreateTag();
data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable);
}
@@ -145,7 +145,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
@Override
public double getAECurrentPower(final ItemStack is) {
final CompoundNBT data = is.getOrCreateTag();
final CompoundTag data = is.getOrCreateTag();
return data.getDouble(CURRENT_POWER_NBT_KEY);
}
@@ -156,7 +156,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) {
return new PoweredItemCapabilities(stack, this);
}
}
@@ -21,7 +21,7 @@ package appeng.items.tools.powered.powersink;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
@@ -22,8 +22,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -47,22 +47,22 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
public ActionResult onItemUse(ItemUseContext context) {
PlayerEntity player = context.getPlayer();
if (Platform.isServer() && player != null) {
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, context.getPlayer(),
ContainerLocator.forItemUseContext(context));
}
return ActionResultType.SUCCESS;
return ActionResult.SUCCESS;
}
@Override
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
if (Platform.isServer()) {
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
}
p.swingArm(hand);
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, p.getHeldItem(hand));
}
@Override
@@ -23,7 +23,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import appeng.api.implementations.items.IAEWrench;
@@ -39,7 +39,7 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench {
}
@Override
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
if (!context.getPlayer().isCrouching() && Platform
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getPos()), context.getPlayer())) {
@@ -48,17 +48,17 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench {
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 ? ActionResultType.SUCCESS : ActionResultType.PASS;
return !context.getWorld().isRemote ? ActionResult.SUCCESS : ActionResult.PASS;
}
AEBaseBlock aeBlock = (AEBaseBlock) block;
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) {
context.getPlayer().swingArm(context.getHand());
return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.FAIL;
return !context.getWorld().isRemote ? ActionResult.SUCCESS : ActionResult.FAIL;
}
}
}
return ActionResultType.PASS;
return ActionResult.PASS;
}
@Override