Utils ported

This commit is contained in:
Sebastian Hartte
2020-06-28 03:41:44 +02:00
parent 7c28a71e10
commit fee5b7fdfc
204 changed files with 1371 additions and 1737 deletions
+1 -1
View File
@@ -425,7 +425,7 @@ public class GridNode implements IGridNode, IPathItem {
private IGridHost findGridHost(final WorldAccess world, final int x, final int y, final int z) {
final BlockPos pos = new BlockPos(x, y, z);
if (world.isBlockLoaded(pos)) {
if (world.isChunkLoaded(pos)) {
final BlockEntity te = world.getBlockEntity(pos);
if (te instanceof IGridHost) {
return (IGridHost) te;
@@ -26,8 +26,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import appeng.util.FakePlayer;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@@ -612,7 +614,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
if (!is.isEmpty()) {
this.postChange(AEItemStack.fromItemStack(is), this.machineSrc);
ic.setInventorySlotContents(x, is);
ic.setStack(x, is);
found = true;
break;
}
@@ -625,7 +627,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
if (!is.isEmpty()) {
this.postChange(input[x], this.machineSrc);
ic.setInventorySlotContents(x, is);
ic.setStack(x, is);
if (is.getCount() == input[x].getStackSize()) {
found = true;
continue;
@@ -641,8 +643,8 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
if (!found) {
// put stuff back..
for (int x = 0; x < ic.getSizeInventory(); x++) {
final ItemStack is = ic.getStackInSlot(x);
for (int x = 0; x < ic.size(); x++) {
final ItemStack is = ic.getStack(x);
if (!is.isEmpty()) {
this.inventory.injectItems(AEItemStack.fromItemStack(is), Actionable.MODULATE,
this.machineSrc);
@@ -664,11 +666,11 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
}
if (details.isCraftable()) {
BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) getWorld()),
BasicEventHooks.firePlayerCraftingEvent((PlayerEntity) FakePlayer.getOrCreate((ServerWorld) getWorld()),
details.getOutput(ic, this.getWorld()), ic);
for (int x = 0; x < ic.getSizeInventory(); x++) {
final ItemStack output = Platform.getContainerItem(ic.getStackInSlot(x));
for (int x = 0; x < ic.size(); x++) {
final ItemStack output = Platform.getRecipeRemainder(ic.getStack(x));
if (!output.isEmpty()) {
final IAEItemStack cItem = AEItemStack.fromItemStack(output);
this.postChange(cItem, this.machineSrc);
@@ -695,8 +697,8 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
if (ic != null) {
// put stuff back..
for (int x = 0; x < ic.getSizeInventory(); x++) {
final ItemStack is = ic.getStackInSlot(x);
for (int x = 0; x < ic.size(); x++) {
final ItemStack is = ic.getStack(x);
if (!is.isEmpty()) {
this.inventory.injectItems(AEItemStack.fromItemStack(is), Actionable.MODULATE,
this.machineSrc);
@@ -18,7 +18,7 @@
package appeng.me.storage;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@@ -212,12 +212,12 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
}
@Override
public ItemTransferable getConfigInventory() {
public FixedItemInv getConfigInventory() {
return this.cellType.getConfigInventory(this.i);
}
@Override
public ItemTransferable getUpgradesInventory() {
public FixedItemInv getUpgradesInventory() {
return this.cellType.getUpgradesInventory(this.i);
}
@@ -18,7 +18,7 @@
package appeng.me.storage;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@@ -49,15 +49,15 @@ public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventor
if (ci != null) {
final IItemList<T> priorityList = channel.createList();
final ItemTransferable upgrades = ci.getUpgradesInventory();
final ItemTransferable config = ci.getConfigInventory();
final FixedItemInv upgrades = ci.getUpgradesInventory();
final FixedItemInv config = ci.getConfigInventory();
final FuzzyMode fzMode = ci.getFuzzyMode();
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) {
@@ -74,8 +74,8 @@ public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventor
}
}
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()) {
final T configItem = channel.createStack(is);
if (configItem != null) {