Utils ported
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -106,7 +106,7 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.InvOperation;
|
||||
@@ -169,7 +169,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc,
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.isWorking == slot) {
|
||||
return;
|
||||
@@ -213,7 +213,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
if (this.waitingToSend != null) {
|
||||
for (final ItemStack is : this.waitingToSend) {
|
||||
final CompoundTag item = new CompoundTag();
|
||||
is.write(item);
|
||||
is.toTag(item);
|
||||
waitingToSend.add(item);
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
for (int x = 0; x < waitingList.size(); x++) {
|
||||
final CompoundTag c = waitingList.getCompound(x);
|
||||
if (c != null) {
|
||||
final ItemStack is = ItemStack.read(c);
|
||||
final ItemStack is = ItemStack.fromTag(c);
|
||||
this.addToSendList(is);
|
||||
}
|
||||
}
|
||||
@@ -445,11 +445,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
// return after.stackSize != stack.stackSize;
|
||||
}
|
||||
|
||||
public ItemTransferable getConfig() {
|
||||
public FixedItemInv getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public ItemTransferable getPatterns() {
|
||||
public FixedItemInv getPatterns() {
|
||||
return this.patterns;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return new DimensionalCoord(this.iHost.getBlockEntity());
|
||||
}
|
||||
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
private InventoryAdaptor getAdaptor(final int slot) {
|
||||
return new AdaptorItemHandler(new RangedWrapper(this.storage, slot, slot + 1));
|
||||
return new AdaptorFixedInv(new RangedWrapper(this.storage, slot, slot + 1));
|
||||
}
|
||||
|
||||
private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) {
|
||||
@@ -685,7 +685,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("storage")) {
|
||||
return this.storage;
|
||||
}
|
||||
@@ -705,7 +705,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemTransferable getStorage() {
|
||||
public FixedItemInv getStorage() {
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
@@ -786,8 +786,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
if (this.acceptsItems(ad, table)) {
|
||||
for (int x = 0; x < table.getSizeInventory(); x++) {
|
||||
final ItemStack is = table.getStackInSlot(x);
|
||||
for (int x = 0; x < table.size(); x++) {
|
||||
final ItemStack is = table.getStack(x);
|
||||
if (!is.isEmpty()) {
|
||||
final ItemStack added = ad.addItems(is);
|
||||
this.addToSendList(added);
|
||||
@@ -844,8 +844,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
private boolean acceptsItems(final InventoryAdaptor ad, final CraftingInventory table) {
|
||||
for (int x = 0; x < table.getSizeInventory(); x++) {
|
||||
final ItemStack is = table.getStackInSlot(x);
|
||||
for (int x = 0; x < table.size(); x++) {
|
||||
final ItemStack is = table.getStack(x);
|
||||
if (is.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private class InterfaceInventory extends MEMonitorIInventory {
|
||||
|
||||
public InterfaceInventory(final DualityInterface tileInterface) {
|
||||
super(new AdaptorItemHandler(tileInterface.storage));
|
||||
super(new AdaptorFixedInv(tileInterface.storage));
|
||||
this.setActionSource(new MachineSource(DualityInterface.this.iHost));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.helpers;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -36,7 +36,7 @@ public interface IContainerCraftingPacket {
|
||||
*
|
||||
* @return the inventory of the part/tile by name.
|
||||
*/
|
||||
ItemTransferable getInventoryByName(String string);
|
||||
FixedItemInv getInventoryByName(String string);
|
||||
|
||||
/**
|
||||
* @return who are we?
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class InvalidPatternHelper {
|
||||
private ItemStack stack;
|
||||
|
||||
public PatternIngredient(CompoundTag tag) {
|
||||
this.stack = ItemStack.read(tag);
|
||||
this.stack = ItemStack.fromTag(tag);
|
||||
|
||||
if (this.stack.isEmpty()) {
|
||||
this.id = tag.getString("id");
|
||||
@@ -128,7 +128,7 @@ public class InvalidPatternHelper {
|
||||
Text result = new LiteralText(this.getCount() + " ").append(this.getName());
|
||||
|
||||
if (!this.isValid()) {
|
||||
result.applyTextStyle(TextFormatting.RED);
|
||||
result.formatted(Formatting.RED);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
@@ -80,27 +80,27 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < inTag.size(); x++) {
|
||||
CompoundTag ingredient = inTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.read(ingredient);
|
||||
final ItemStack gs = ItemStack.fromTag(ingredient);
|
||||
|
||||
if (!ingredient.isEmpty() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
}
|
||||
|
||||
this.crafting.setInventorySlotContents(x, gs);
|
||||
this.crafting.setStack(x, gs);
|
||||
|
||||
if (!gs.isEmpty() && (!this.isCrafting || !gs.hasTag())) {
|
||||
this.markItemAs(x, gs, TestStatus.ACCEPT);
|
||||
}
|
||||
|
||||
in.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
|
||||
this.testFrame.setInventorySlotContents(x, gs);
|
||||
this.testFrame.setStack(x, gs);
|
||||
}
|
||||
|
||||
if (this.isCrafting) {
|
||||
this.standardRecipe = w.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, w).orElse(null);
|
||||
this.standardRecipe = w.getRecipeManager().getRecipe(RecipeType.CRAFTING, this.crafting, w).orElse(null);
|
||||
|
||||
if (this.standardRecipe != null) {
|
||||
this.correctOutput = this.standardRecipe.getCraftingResult(this.crafting);
|
||||
this.correctOutput = this.standardRecipe.craft(this.crafting);
|
||||
out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(this.correctOutput));
|
||||
} else {
|
||||
@@ -112,7 +112,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < outTag.size(); x++) {
|
||||
CompoundTag resultItemTag = outTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.read(resultItemTag);
|
||||
final ItemStack gs = ItemStack.fromTag(resultItemTag);
|
||||
|
||||
if (!resultItemTag.isEmpty() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
@@ -211,11 +211,11 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
break;
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
this.testFrame.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
for (int x = 0; x < this.crafting.size(); x++) {
|
||||
this.testFrame.setStack(x, this.crafting.getStack(x));
|
||||
}
|
||||
|
||||
this.testFrame.setInventorySlotContents(slotIndex, i);
|
||||
this.testFrame.setStack(slotIndex, i);
|
||||
|
||||
// If we cannot substitute, the items must match exactly
|
||||
if (!canSubstitute && slotIndex < inputs.length) {
|
||||
@@ -226,10 +226,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
}
|
||||
|
||||
if (this.standardRecipe.matches(this.testFrame, w)) {
|
||||
final ItemStack testOutput = this.standardRecipe.getCraftingResult(this.testFrame);
|
||||
final ItemStack testOutput = this.standardRecipe.craft(this.testFrame);
|
||||
|
||||
if (Platform.itemComparisons().isSameItem(this.correctOutput, testOutput)) {
|
||||
this.testFrame.setInventorySlotContents(slotIndex, this.crafting.getStackInSlot(slotIndex));
|
||||
this.testFrame.setStack(slotIndex, this.crafting.getStack(slotIndex));
|
||||
this.markItemAs(slotIndex, i, TestStatus.ACCEPT);
|
||||
return true;
|
||||
}
|
||||
@@ -275,8 +275,8 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
throw new IllegalStateException("Only crafting recipes supported.");
|
||||
}
|
||||
|
||||
for (int x = 0; x < craftingInv.getSizeInventory(); x++) {
|
||||
if (!this.isValidItemForSlot(x, craftingInv.getStackInSlot(x), w)) {
|
||||
for (int x = 0; x < craftingInv.size(); x++) {
|
||||
if (!this.isValidItemForSlot(x, craftingInv.getStack(x), w)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
}
|
||||
|
||||
private TestStatus getStatus(final int slotIndex, final ItemStack i) {
|
||||
if (this.crafting.getStackInSlot(slotIndex).isEmpty()) {
|
||||
if (this.crafting.getStack(slotIndex).isEmpty()) {
|
||||
return i.isEmpty() ? TestStatus.ACCEPT : TestStatus.DECLINE;
|
||||
}
|
||||
|
||||
|
||||
@@ -267,9 +267,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
final DimensionalCoord dc = wap.getLocation();
|
||||
|
||||
if (dc.getWorld() == this.myPlayer.world) {
|
||||
final double offX = dc.x - this.myPlayer.getPosX();
|
||||
final double offY = dc.y - this.myPlayer.getPosY();
|
||||
final double offZ = dc.z - this.myPlayer.getPosZ();
|
||||
final double offX = dc.x - this.myPlayer.getX();
|
||||
final double offY = dc.y - this.myPlayer.getY();
|
||||
final double offZ = dc.z - this.myPlayer.getZ();
|
||||
|
||||
final double r = offX * offX + offY * offY + offZ * offZ;
|
||||
if (r < rangeLimit && this.sqRange > r) {
|
||||
|
||||
Reference in New Issue
Block a user