Compiles again.

This commit is contained in:
Sebastian Hartte
2020-07-27 23:50:28 +02:00
parent 56ecda5173
commit 84e6aaa122
136 changed files with 1004 additions and 1108 deletions
@@ -29,12 +29,14 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.parts.AEBasePart;
import net.minecraft.world.World;
/**
* Describes how a container the player has opened was originally located. This
@@ -62,14 +64,18 @@ public final class ContainerLocator {
private final Type type;
private final int itemIndex;
private final int dimensionId;
private final ResourceLocation worldId;
private final BlockPos blockPos;
private final AEPartLocation side;
private ContainerLocator(Type type, int itemIndex, int dimensionId, BlockPos blockPos, AEPartLocation side) {
private ContainerLocator(Type type, int itemIndex, World world, BlockPos blockPos, AEPartLocation side) {
this(type, itemIndex, world.func_234923_W_().func_240901_a_(), blockPos, side);
}
private ContainerLocator(Type type, int itemIndex, ResourceLocation worldId, BlockPos blockPos, AEPartLocation side) {
this.type = type;
this.itemIndex = itemIndex;
this.dimensionId = dimensionId;
this.worldId = worldId;
this.blockPos = blockPos;
this.side = side;
}
@@ -78,16 +84,14 @@ public final class ContainerLocator {
if (te.getWorld() == null) {
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
}
int dimensionId = te.getWorld().getDimension().getType().getId();
return new ContainerLocator(Type.BLOCK, -1, dimensionId, te.getPos(), null);
return new ContainerLocator(Type.BLOCK, -1, te.getWorld(), te.getPos(), null);
}
public static ContainerLocator forTileEntitySide(TileEntity te, Direction side) {
if (te.getWorld() == null) {
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
}
int dimensionId = te.getWorld().getDimension().getType().getId();
return new ContainerLocator(Type.PART, -1, dimensionId, te.getPos(), AEPartLocation.fromFacing(side));
return new ContainerLocator(Type.PART, -1, te.getWorld(), te.getPos(), AEPartLocation.fromFacing(side));
}
/**
@@ -100,16 +104,15 @@ public final class ContainerLocator {
if (player == null) {
throw new IllegalArgumentException("Cannot open a container without a player");
}
int dimensionId = player.world.getDimension().getType().getId();
int slot = getPlayerInventorySlotFromHand(player, context.getHand());
AEPartLocation side = AEPartLocation.fromFacing(context.getFace());
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, dimensionId, context.getPos(),
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, player.world, context.getPos(),
side);
}
public static ContainerLocator forHand(PlayerEntity player, Hand hand) {
int slot = getPlayerInventorySlotFromHand(player, hand);
return new ContainerLocator(Type.PLAYER_INVENTORY, slot, -1, null, null);
return new ContainerLocator(Type.PLAYER_INVENTORY, slot, (ResourceLocation) null, null, null);
}
private static int getPlayerInventorySlotFromHand(PlayerEntity player, Hand hand) {
@@ -129,7 +132,7 @@ public final class ContainerLocator {
public static ContainerLocator forPart(AEBasePart part) {
IPartHost host = part.getHost();
DimensionalCoord pos = host.getLocation();
return new ContainerLocator(Type.PART, -1, pos.getWorld().getDimension().getType().getId(), pos.getBlockPos(),
return new ContainerLocator(Type.PART, -1, pos.getWorld().getWorld(), pos.getBlockPos(),
part.getSide());
}
@@ -142,8 +145,8 @@ public final class ContainerLocator {
return itemIndex;
}
public int getDimensionId() {
return dimensionId;
public ResourceLocation getWorldId() {
return worldId;
}
public boolean hasBlockPos() {
@@ -173,18 +176,18 @@ public final class ContainerLocator {
case PLAYER_INVENTORY_WITH_BLOCK_CONTEXT:
buf.writeByte(1);
buf.writeInt(itemIndex);
buf.writeInt(dimensionId);
buf.writeResourceLocation(worldId);
buf.writeBlockPos(blockPos);
buf.writeByte(side.ordinal());
break;
case BLOCK:
buf.writeByte(2);
buf.writeInt(dimensionId);
buf.writeResourceLocation(worldId);
buf.writeBlockPos(blockPos);
break;
case PART:
buf.writeByte(3);
buf.writeInt(dimensionId);
buf.writeResourceLocation(worldId);
buf.writeBlockPos(blockPos);
buf.writeByte(side.ordinal());
break;
@@ -197,14 +200,14 @@ public final class ContainerLocator {
byte type = buf.readByte();
switch (type) {
case 0:
return new ContainerLocator(Type.PLAYER_INVENTORY, buf.readInt(), -1, null, null);
return new ContainerLocator(Type.PLAYER_INVENTORY, buf.readInt(), (ResourceLocation) null, null, null);
case 1:
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, buf.readInt(), buf.readInt(),
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, buf.readInt(), buf.readResourceLocation(),
buf.readBlockPos(), AEPartLocation.values()[buf.readByte()]);
case 2:
return new ContainerLocator(Type.BLOCK, -1, buf.readInt(), buf.readBlockPos(), null);
return new ContainerLocator(Type.BLOCK, -1, buf.readResourceLocation(), buf.readBlockPos(), null);
case 3:
return new ContainerLocator(Type.PART, -1, buf.readInt(), buf.readBlockPos(),
return new ContainerLocator(Type.PART, -1, buf.readResourceLocation(), buf.readBlockPos(),
AEPartLocation.values()[buf.readByte()]);
default:
throw new DecoderException("ContainerLocator type out of range: " + type);
@@ -219,7 +222,7 @@ public final class ContainerLocator {
result.append("slot=").append(itemIndex).append(',');
}
if (hasBlockPos()) {
result.append("dim=").append(dimensionId).append(',');
result.append("dim=").append(worldId).append(',');
result.append("pos=").append(blockPos).append(',');
}
if (hasSide()) {