Utils ported
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
@@ -52,7 +52,7 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(ItemTransferable inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
public void onChangeInventory(FixedItemInv inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory {
|
||||
|
||||
private static class NetworkToolInventoryFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return stack.getItem() instanceof IUpgradeModule
|
||||
&& ((IUpgradeModule) stack.getItem()).getType(stack) != null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventory() {
|
||||
public FixedItemInv getInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
@@ -41,7 +41,7 @@ import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
@@ -53,7 +53,7 @@ import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
|
||||
public final class MaterialItem extends AEBaseItem implements IStorageComponent, IUpgradeModule {
|
||||
|
||||
@@ -143,7 +143,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
Hand hand = context.getHand();
|
||||
if (player.isInSneakingPose()) {
|
||||
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||
ItemTransferable upgrades = null;
|
||||
FixedItemInv upgrades = null;
|
||||
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart sp = ((IPartHost) te).selectPart(context.getHitVec());
|
||||
@@ -164,7 +164,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler(upgrades);
|
||||
final InventoryAdaptor ad = new AdaptorFixedInv(upgrades);
|
||||
player.setHeldItem(hand, ad.addItems(player.getStackInHand(hand)));
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
try {
|
||||
eqi = droppedEntity.getConstructor(World.class, double.class, double.class, double.class, ItemStack.class)
|
||||
.newInstance(w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack);
|
||||
.newInstance(w, location.getX(), location.getY(), location.getZ(), itemstack);
|
||||
} catch (final Throwable t) {
|
||||
throw new IllegalStateException(t);
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
|
||||
@Override
|
||||
public Entity createEntity(final World world, final Entity location, final ItemStack itemstack) {
|
||||
final GrowingCrystalEntity egc = new GrowingCrystalEntity(world, location.getPosX(), location.getPosY(),
|
||||
location.getPosZ(), itemstack);
|
||||
final GrowingCrystalEntity egc = new GrowingCrystalEntity(world, location.getX(), location.getY(),
|
||||
location.getZ(), itemstack);
|
||||
|
||||
egc.setMotion(location.getMotion());
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ 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.TextFormatting;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -79,9 +79,9 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack(stack.getCount())
|
||||
.orElse(ItemStack.EMPTY);
|
||||
if (!is.isEmpty()) {
|
||||
for (int s = 0; s < player.inventory.getSizeInventory(); s++) {
|
||||
if (inv.getStackInSlot(s) == stack) {
|
||||
inv.setInventorySlotContents(s, is);
|
||||
for (int s = 0; s < player.inventory.size(); s++) {
|
||||
if (inv.getStack(s) == stack) {
|
||||
inv.setStack(s, is);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
return;
|
||||
}
|
||||
|
||||
stack.setDisplayName(GuiText.InvalidPattern.textComponent().applyTextStyle(TextFormatting.RED));
|
||||
stack.setDisplayName(GuiText.InvalidPattern.textComponent().formatted(Formatting.RED));
|
||||
|
||||
InvalidPatternHelper invalid = new InvalidPatternHelper(stack);
|
||||
|
||||
@@ -190,18 +190,13 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getOutput(final ItemStack item) {
|
||||
public ItemStack getOutput(World w, final ItemStack item) {
|
||||
ItemStack out = SIMPLE_CACHE.get(item);
|
||||
|
||||
if (out != null) {
|
||||
return out;
|
||||
}
|
||||
|
||||
final World w = AppEng.proxy.getWorld();
|
||||
if (w == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final ICraftingPatternDetails details = this.getPatternForItem(item, w);
|
||||
|
||||
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.items.storage;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -115,12 +115,12 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player);
|
||||
final IItemList<IAEItemStack> list = inv.getAvailableItems(this.getChannel().createList());
|
||||
if (list.isEmpty() && ia != null) {
|
||||
playerInventory.setInventorySlotContents(playerInventory.currentItem, ItemStack.EMPTY);
|
||||
playerInventory.setStack(playerInventory.currentItem, ItemStack.EMPTY);
|
||||
|
||||
// drop core
|
||||
final ItemStack extraB = ia.addItems(this.component.stack(1));
|
||||
@@ -167,9 +167,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
}
|
||||
|
||||
// drop upgrades
|
||||
final ItemTransferable upgradesInventory = this.getUpgradesInventory(stack);
|
||||
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++) {
|
||||
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
|
||||
final FixedItemInv upgradesInventory = this.getUpgradesInventory(stack);
|
||||
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlotCount(); upgradeIndex++) {
|
||||
final ItemStack upgradeStack = upgradesInventory.getInvStack(upgradeIndex);
|
||||
final ItemStack leftStack = ia.addItems(upgradeStack);
|
||||
if (!leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule) {
|
||||
player.dropItem(upgradeStack, false);
|
||||
@@ -199,14 +199,14 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
public ItemStack getRecipeRemainder(final ItemStack itemStack) {
|
||||
return AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1)
|
||||
.orElseThrow(() -> new MissingDefinitionException(
|
||||
"Tried to use empty storage cells while basic storage cells are defined."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
public boolean hasRecipeRemainder(final ItemStack stack) {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.items.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
@@ -49,12 +49,12 @@ public class CreativeStorageCellItem extends AEBaseItem implements ICellWorkbenc
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ 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.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -59,7 +59,7 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
|
||||
final TooltipContext advancedTooltips) {
|
||||
final DimensionType dimType = this.getStoredDimension(stack);
|
||||
if (dimType == null) {
|
||||
lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC));
|
||||
lines.add(GuiText.Unformatted.textComponent().formatted(Formatting.ITALIC));
|
||||
lines.add(GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion));
|
||||
} else {
|
||||
SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -59,15 +59,15 @@ public class ViewCellItem extends AEBaseItem implements ICellWorkbenchItem {
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem();
|
||||
final ItemTransferable upgrades = vc.getUpgradesInventory(currentViewCell);
|
||||
final ItemTransferable config = vc.getConfigInventory(currentViewCell);
|
||||
final FixedItemInv upgrades = vc.getUpgradesInventory(currentViewCell);
|
||||
final FixedItemInv config = vc.getConfigInventory(currentViewCell);
|
||||
final FuzzyMode fzMode = vc.getFuzzyMode(currentViewCell);
|
||||
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
|
||||
for (int x = 0; x < upgrades.getSlots(); x++) {
|
||||
final ItemStack is = upgrades.getStackInSlot(x);
|
||||
for (int x = 0; x < upgrades.getSlotCount(); x++) {
|
||||
final ItemStack is = upgrades.getInvStack(x);
|
||||
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
|
||||
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
|
||||
if (u != null) {
|
||||
@@ -84,8 +84,8 @@ public class ViewCellItem extends AEBaseItem implements ICellWorkbenchItem {
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < config.getSlots(); x++) {
|
||||
final ItemStack is = config.getStackInSlot(x);
|
||||
for (int x = 0; x < config.getSlotCount(); x++) {
|
||||
final ItemStack is = config.getInvStack(x);
|
||||
if (!is.isEmpty()) {
|
||||
priorityList.add(AEItemStack.fromItemStack(is));
|
||||
}
|
||||
@@ -112,12 +112,12 @@ public class ViewCellItem extends AEBaseItem implements ICellWorkbenchItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -73,7 +70,7 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
|
||||
if (data.contains("freq")) {
|
||||
final short freq = data.getShort("freq");
|
||||
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString(freq);
|
||||
final String freqTooltip = Formatting.BOLD + Platform.p2p().toHexString(freq);
|
||||
|
||||
lines.add(new TranslatableText("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
|
||||
}
|
||||
@@ -145,19 +142,19 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
|
||||
switch (msg) {
|
||||
case SETTINGS_CLEARED:
|
||||
player.sendMessage(PlayerMessages.SettingCleared.get());
|
||||
player.sendSystemMessage(PlayerMessages.SettingCleared.get(), Util.NIL_UUID);
|
||||
break;
|
||||
case INVALID_MACHINE:
|
||||
player.sendMessage(PlayerMessages.InvalidMachine.get());
|
||||
player.sendSystemMessage(PlayerMessages.InvalidMachine.get(), Util.NIL_UUID);
|
||||
break;
|
||||
case SETTINGS_LOADED:
|
||||
player.sendMessage(PlayerMessages.LoadedSettings.get());
|
||||
player.sendSystemMessage(PlayerMessages.LoadedSettings.get(), Util.NIL_UUID);
|
||||
break;
|
||||
case SETTINGS_SAVED:
|
||||
player.sendMessage(PlayerMessages.SavedSettings.get());
|
||||
player.sendSystemMessage(PlayerMessages.SavedSettings.get(), Util.NIL_UUID);
|
||||
break;
|
||||
case SETTINGS_RESET:
|
||||
player.sendMessage(PlayerMessages.ResetSettings.get());
|
||||
player.sendSystemMessage(PlayerMessages.ResetSettings.get(), Util.NIL_UUID);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.getHitVec());
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.getPos());
|
||||
|
||||
if (part.part != null || part.facade != null) {
|
||||
if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -46,6 +46,7 @@ import appeng.items.misc.PaintBallItem;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.tile.misc.PaintSplotchesBlockEntity;
|
||||
import appeng.util.FakePlayer;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -124,7 +125,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
Direction side = context.getSide();
|
||||
PlayerEntity p = context.getPlayer(); // This can be null
|
||||
if (p == null && w instanceof ServerWorld) {
|
||||
p = Platform.getPlayer((ServerWorld) w);
|
||||
p = FakePlayer.getOrCreate((ServerWorld) w);
|
||||
}
|
||||
|
||||
final Block blk = w.getBlockState(pos).getBlock();
|
||||
@@ -240,7 +241,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
final CompoundTag c = is.getTag();
|
||||
if (c != null && c.contains(TAG_COLOR)) {
|
||||
final CompoundTag color = c.getCompound(TAG_COLOR);
|
||||
final ItemStack oldColor = ItemStack.read(color);
|
||||
final ItemStack oldColor = ItemStack.fromTag(color);
|
||||
if (!oldColor.isEmpty()) {
|
||||
return oldColor;
|
||||
}
|
||||
@@ -314,7 +315,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
data.remove(TAG_COLOR);
|
||||
} else {
|
||||
final CompoundTag color = new CompoundTag();
|
||||
newColor.write(color);
|
||||
newColor.toTag(color);
|
||||
data.put(TAG_COLOR, color);
|
||||
}
|
||||
}
|
||||
@@ -433,12 +434,12 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.items.tools.powered;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import appeng.util.FakePlayer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -32,13 +33,13 @@ import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.crafting.FurnaceRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
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.RayTraceContext;
|
||||
import net.minecraft.world.RayTraceContext;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -203,7 +204,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
// considered for onItemUse
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
final HitResult target = rayTrace(w, p, RayTraceContext.FluidMode.ANY);
|
||||
final HitResult target = rayTrace(w, p, RayTraceContext.FluidHandling.ANY);
|
||||
|
||||
if (target.getType() != HitResult.Type.BLOCK) {
|
||||
return new TypedActionResult<>(ActionResult.FAIL, p.getStackInHand(hand));
|
||||
@@ -233,7 +234,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
if (w.isClient) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
p = Platform.getPlayer((ServerWorld) w);
|
||||
p = FakePlayer.getOrCreate((ServerWorld) w);
|
||||
// Fake players cannot crouch and we cannot communicate whether they want to
|
||||
// heat or cool
|
||||
tryBoth = true;
|
||||
@@ -280,11 +281,11 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
|
||||
for (final ItemStack i : stack) {
|
||||
CraftingInventory tempInv = new CraftingInventory(new ContainerNull(), 1, 1);
|
||||
tempInv.setInventorySlotContents(0, i);
|
||||
Optional<FurnaceRecipe> recipe = w.getRecipeManager().getRecipe(IRecipeType.SMELTING, tempInv, w);
|
||||
tempInv.setStack(0, i);
|
||||
Optional<FurnaceRecipe> recipe = w.getRecipeManager().getRecipe(RecipeType.SMELTING, tempInv, w);
|
||||
|
||||
if (recipe.isPresent()) {
|
||||
ItemStack result = recipe.get().getCraftingResult(tempInv);
|
||||
ItemStack result = recipe.get().craft(tempInv);
|
||||
if (result.getItem() instanceof BlockItem) {
|
||||
// Anti-Dupe-Bug I presume...
|
||||
if (Block.getBlockFromItem(result.getItem()) == block) {
|
||||
|
||||
@@ -22,14 +22,14 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.passive.SheepEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -37,14 +37,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.math.Box;
|
||||
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.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.world.RayTraceContext;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -165,7 +165,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
} else {
|
||||
if (Platform.isServer()) {
|
||||
p.sendMessage(PlayerMessages.AmmoDepleted.get());
|
||||
p.sendSystemMessage(PlayerMessages.AmmoDepleted.get(), Util.NIL_UUID);
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
@@ -178,11 +178,11 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2) {
|
||||
final Box bb = new Box(Math.min(Vec3d.x, Vec3d1.x), Math.min(Vec3d.y, Vec3d1.y),
|
||||
Math.min(Vec3d.z, Vec3d1.z), Math.max(Vec3d.x, Vec3d1.x), Math.max(Vec3d.y, Vec3d1.y),
|
||||
Math.max(Vec3d.z, Vec3d1.z)).grow(16, 16, 16);
|
||||
Math.max(Vec3d.z, Vec3d1.z)).expand(16, 16, 16);
|
||||
|
||||
Entity entity = null;
|
||||
Vec3d entityIntersection = null;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb);
|
||||
final List list = w.getEntities(p, bb);
|
||||
double closest = 9999999.0D;
|
||||
|
||||
for (int l = 0; l < list.size(); ++l) {
|
||||
@@ -191,17 +191,17 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
if (!entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) {
|
||||
if (entity1.isAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
if (entity1.isConnectedThroughVehicle(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final Box boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Box boundingBox = entity1.getBoundingBox().expand(f1, f1, f1);
|
||||
final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null);
|
||||
|
||||
if (intersection != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(intersection);
|
||||
final double nd = Vec3d.squaredDistanceTo(intersection);
|
||||
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
@@ -213,23 +213,23 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER,
|
||||
RayTraceContext.FluidMode.NONE, p);
|
||||
HitResult pos = w.rayTraceBlocks(rayTraceContext);
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.ShapeType.COLLIDER,
|
||||
RayTraceContext.FluidHandling.NONE, p);
|
||||
HitResult pos = w.rayTrace(rayTraceContext);
|
||||
|
||||
final Vec3d vec = new Vec3d(d0, d1, d2);
|
||||
if (entity != null && pos.getType() != HitResult.Type.MISS
|
||||
&& pos.getHitVec().squareDistanceTo(vec) > closest) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
&& pos.getPos().squaredDistanceTo(vec) > closest) {
|
||||
pos = new EntityHitResult(entity, entityIntersection);
|
||||
} else if (entity != null && pos.getType() == HitResult.Type.MISS) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
pos = new EntityHitResult(entity, entityIntersection);
|
||||
}
|
||||
|
||||
try {
|
||||
AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w,
|
||||
new MatterCannonPacket(d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z,
|
||||
(byte) (pos.getType() == HitResult.Type.MISS ? 32
|
||||
: pos.getHitVec().squareDistanceTo(vec) + 1)));
|
||||
: pos.getPos().squaredDistanceTo(vec) + 1)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
@@ -240,8 +240,8 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
final AEColor col = ipb.getColor();
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
|
||||
if (pos instanceof EntityRayTraceResult) {
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
if (pos instanceof EntityHitResult) {
|
||||
EntityHitResult entityResult = (EntityHitResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int id = entityHit.getEntityId();
|
||||
@@ -273,7 +273,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
|
||||
final BlockEntity te = w.getBlockEntity(hitPos);
|
||||
if (te instanceof PaintSplotchesBlockEntity) {
|
||||
final Vec3d hp = pos.getHitVec().subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ());
|
||||
final Vec3d hp = pos.getPos().subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ());
|
||||
((PaintSplotchesBlockEntity) te).addBlot(type, side.getOpposite(), hp);
|
||||
}
|
||||
}
|
||||
@@ -288,11 +288,11 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
|
||||
final Box bb = new Box(Math.min(Vec3d.x, Vec3d1.x), Math.min(Vec3d.y, Vec3d1.y),
|
||||
Math.min(Vec3d.z, Vec3d1.z), Math.max(Vec3d.x, Vec3d1.x), Math.max(Vec3d.y, Vec3d1.y),
|
||||
Math.max(Vec3d.z, Vec3d1.z)).grow(16, 16, 16);
|
||||
Math.max(Vec3d.z, Vec3d1.z)).expand(16, 16, 16);
|
||||
|
||||
Entity entity = null;
|
||||
Vec3d entityIntersection = null;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb);
|
||||
final List list = w.getEntities(p, bb);
|
||||
double closest = 9999999.0D;
|
||||
|
||||
for (int l = 0; l < list.size(); ++l) {
|
||||
@@ -301,17 +301,17 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
if (entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) {
|
||||
if (entity1.isAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
if (entity1.isConnectedThroughVehicle(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final Box boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Box boundingBox = entity1.getBoundingBox().expand(f1, f1, f1);
|
||||
final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null);
|
||||
|
||||
if (intersection != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(intersection);
|
||||
final double nd = Vec3d.squaredDistanceTo(intersection);
|
||||
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
@@ -323,22 +323,22 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER,
|
||||
RayTraceContext.FluidMode.NONE, p);
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.ShapeType.COLLIDER,
|
||||
RayTraceContext.FluidHandling.NONE, p);
|
||||
final Vec3d vec = new Vec3d(d0, d1, d2);
|
||||
HitResult pos = w.rayTraceBlocks(rayTraceContext);
|
||||
HitResult pos = w.rayTrace(rayTraceContext);
|
||||
if (entity != null && pos.getType() != HitResult.Type.MISS
|
||||
&& pos.getHitVec().squareDistanceTo(vec) > closest) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
&& pos.getPos().squaredDistanceTo(vec) > closest) {
|
||||
pos = new EntityHitResult(entity, entityIntersection);
|
||||
} else if (entity != null && pos.getType() == HitResult.Type.MISS) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
pos = new EntityHitResult(entity, entityIntersection);
|
||||
}
|
||||
|
||||
try {
|
||||
AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w,
|
||||
new MatterCannonPacket(d0, d1, d2, (float) direction.x, (float) direction.y,
|
||||
(float) direction.z, (byte) (pos.getType() == HitResult.Type.MISS ? 32
|
||||
: pos.getHitVec().squareDistanceTo(vec) + 1)));
|
||||
: pos.getPos().squaredDistanceTo(vec) + 1)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
@@ -346,8 +346,8 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
if (pos.getType() != HitResult.Type.MISS) {
|
||||
final DamageSource dmgSrc = new EntityDamageSource("matter_cannon", p);
|
||||
|
||||
if (pos instanceof EntityRayTraceResult) {
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
if (pos instanceof EntityHitResult) {
|
||||
EntityHitResult entityResult = (EntityHitResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int dmg = (int) Math.ceil(penetration / 20.0f);
|
||||
@@ -398,12 +398,12 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -129,12 +129,12 @@ public class PortableCellItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getUpgradesInventory(final ItemStack is) {
|
||||
public FixedItemInv getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getConfigInventory(final ItemStack is) {
|
||||
public FixedItemInv getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
public ItemStack getRecipeRemainder(final ItemStack itemStack) {
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setDamage(itemStack.getDamage() + 1);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
public boolean hasRecipeRemainder(final ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user