mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 07:13:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
395f258893 | ||
|
|
56a268bcda |
No files matched your search
@@ -11,6 +11,7 @@ import java.util.stream.IntStream;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,6 +35,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
@@ -106,7 +108,7 @@ public enum NewPacketHandler {
|
||||
World world = AlchemicalWizardry.proxy.getClientWorld();
|
||||
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
|
||||
if (te instanceof TEAltar altar) {
|
||||
altar.handlePacketData(msg.items, msg.fluids, msg.capacity);
|
||||
altar.handlePacketData(msg.itemStack, msg.fluids, msg.capacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,7 +319,7 @@ public enum NewPacketHandler {
|
||||
int y;
|
||||
int z;
|
||||
|
||||
int[] items;
|
||||
ItemStack itemStack;
|
||||
int[] fluids;
|
||||
int capacity;
|
||||
}
|
||||
@@ -482,11 +484,7 @@ public enum NewPacketHandler {
|
||||
target.writeInt(m.y);
|
||||
target.writeInt(m.z);
|
||||
|
||||
target.writeBoolean(m.items != null);
|
||||
if (m.items != null) {
|
||||
int[] items = m.items;
|
||||
Arrays.stream(items).forEach(target::writeInt);
|
||||
}
|
||||
ByteBufUtils.writeItemStack(target, m.itemStack);
|
||||
|
||||
target.writeBoolean(m.fluids != null);
|
||||
if (m.fluids != null) {
|
||||
@@ -658,13 +656,8 @@ public enum NewPacketHandler {
|
||||
m.x = dat.readInt();
|
||||
m.y = dat.readInt();
|
||||
m.z = dat.readInt();
|
||||
boolean hasStacks = dat.readBoolean();
|
||||
|
||||
m.items = new int[TEAltar.sizeInv * 3];
|
||||
if (hasStacks) {
|
||||
m.items = new int[TEAltar.sizeInv * 3];
|
||||
IntStream.range(0, m.items.length).forEach(i -> m.items[i] = dat.readInt());
|
||||
}
|
||||
m.itemStack = ByteBufUtils.readItemStack(dat);
|
||||
|
||||
boolean hasFluids = dat.readBoolean();
|
||||
m.fluids = new int[6];
|
||||
@@ -841,7 +834,7 @@ public enum NewPacketHandler {
|
||||
msg.x = tileAltar.xCoord;
|
||||
msg.y = tileAltar.yCoord;
|
||||
msg.z = tileAltar.zCoord;
|
||||
msg.items = tileAltar.buildIntDataList();
|
||||
msg.itemStack = tileAltar.getStackInSlot(0);
|
||||
msg.fluids = tileAltar.buildFluidList();
|
||||
msg.capacity = tileAltar.getCapacity();
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -72,34 +69,7 @@ public class SpectralBlock extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what,
|
||||
float these, float are) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack playerItem = player.getCurrentEquippedItem();
|
||||
|
||||
if (playerItem != null) {
|
||||
if (playerItem.getItem() instanceof ItemBlock) {
|
||||
world.setBlock(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
((ItemBlock) (playerItem.getItem())).field_150939_a,
|
||||
playerItem.getItemDamage(),
|
||||
3);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
playerItem.stackSize--;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -718,19 +717,8 @@ public class TEAltar extends TEInventory implements IFluidTank, IFluidHandler, I
|
||||
return NewPacketHandler.getPacket(this);
|
||||
}
|
||||
|
||||
public void handlePacketData(int[] intData, int[] fluidData, int capacity) {
|
||||
if (intData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (intData.length == 3) {
|
||||
if (intData[2] != 0) {
|
||||
ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]);
|
||||
inv[0] = is;
|
||||
} else {
|
||||
inv[0] = null;
|
||||
}
|
||||
}
|
||||
public void handlePacketData(ItemStack itemStack, int[] fluidData, int capacity) {
|
||||
inv[0] = itemStack == null ? null : itemStack.copy();
|
||||
|
||||
FluidStack flMain = new FluidStack(fluidData[0], fluidData[1]);
|
||||
FluidStack flIn = new FluidStack(fluidData[2], fluidData[3]);
|
||||
@@ -743,25 +731,6 @@ public class TEAltar extends TEInventory implements IFluidTank, IFluidHandler, I
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public int[] buildIntDataList() {
|
||||
int[] sortList = new int[3]; // 1 * 3
|
||||
int pos = 0;
|
||||
|
||||
for (ItemStack is : inv) {
|
||||
if (is != null) {
|
||||
sortList[pos++] = Item.getIdFromItem(is.getItem());
|
||||
sortList[pos++] = is.getItemDamage();
|
||||
sortList[pos++] = is.stackSize;
|
||||
} else {
|
||||
sortList[pos++] = 0;
|
||||
sortList[pos++] = 0;
|
||||
sortList[pos++] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return sortList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCycle() {
|
||||
if (worldObj != null) {
|
||||
|
||||
Reference in new issue
Block a user