feat: implement void interface

This commit is contained in:
LordMZTE 2023-05-19 19:00:16 +02:00
parent e3169b2067
commit b1fdb881e0
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
20 changed files with 676 additions and 55 deletions

View File

@ -6,6 +6,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.entities.EntitySingularity;
import net.anvilcraft.thaummach.gui.GuiBore;
import net.anvilcraft.thaummach.gui.GuiVoidChest;
import net.anvilcraft.thaummach.gui.GuiVoidInterface;
import net.anvilcraft.thaummach.render.BlockApparatusRenderer;
import net.anvilcraft.thaummach.render.TileSealRenderer;
import net.anvilcraft.thaummach.render.entity.EntitySingularityRenderer;
@ -87,6 +89,12 @@ public class ClientProxy extends CommonProxy {
case BORE:
return new GuiBore(player.inventory, (TileBore) te);
case VOID_CHEST:
return new GuiVoidChest(player.inventory, (TileVoidChest) te);
case VOID_INTERFACE:
return new GuiVoidInterface(player.inventory, (TileVoidInterface) te);
default:
throw new IllegalArgumentException("ALEC");
}

View File

@ -3,6 +3,8 @@ package net.anvilcraft.thaummach;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.container.ContainerBore;
import net.anvilcraft.thaummach.container.ContainerVoidChest;
import net.anvilcraft.thaummach.container.ContainerVoidInterface;
import net.anvilcraft.thaummach.tiles.TileBore;
import net.anvilcraft.thaummach.tiles.TileConduit;
import net.anvilcraft.thaummach.tiles.TileConduitPump;
@ -53,6 +55,14 @@ public class CommonProxy implements IGuiHandler {
case BORE:
return new ContainerBore(player.inventory, (TileBore) te);
case VOID_CHEST:
return new ContainerVoidChest(player.inventory, (TileVoidChest) te);
case VOID_INTERFACE:
return new ContainerVoidInterface(
player.inventory, (TileVoidInterface) te
);
default:
throw new IllegalArgumentException("ALEC");
}

View File

@ -1,7 +1,9 @@
package net.anvilcraft.thaummach;
public enum GuiID {
BORE;
BORE,
VOID_CHEST,
VOID_INTERFACE;
public static GuiID get(int id) {
if (id >= 0 && id < GuiID.values().length) {

View File

@ -4,6 +4,7 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
@ -12,8 +13,12 @@ import cpw.mods.fml.relauncher.Side;
import dev.tilera.auracore.api.HelperLocation;
import net.anvilcraft.thaummach.entities.EntitySingularity;
import net.anvilcraft.thaummach.packets.IPacketFX;
import net.anvilcraft.thaummach.packets.PacketChangeVoidInterfaceChannel;
import net.anvilcraft.thaummach.packets.PacketChangeVoidInterfaceContainerPage;
import net.anvilcraft.thaummach.packets.PacketFXSparkle;
import net.anvilcraft.thaummach.packets.PacketFXWisp;
import net.anvilcraft.thaummach.tiles.TileSeal;
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
import net.minecraft.world.World;
@Mod(modid = "thaummach")
@ -40,6 +45,18 @@ public class ThaumicMachinery {
channel.registerMessage(
new PacketFXSparkle.Handler(), PacketFXSparkle.class, pktid++, Side.CLIENT
);
channel.registerMessage(
new PacketChangeVoidInterfaceChannel.Handler(),
PacketChangeVoidInterfaceChannel.class,
pktid++,
Side.SERVER
);
channel.registerMessage(
new PacketChangeVoidInterfaceContainerPage.Handler(),
PacketChangeVoidInterfaceContainerPage.class,
pktid++,
Side.SERVER
);
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
@ -58,6 +75,12 @@ public class ThaumicMachinery {
proxy.init();
}
@Mod.EventHandler
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
TileVoidInterface.VOID_INTERFACES.clear();
TileSeal.SEALS.clear();
}
public static void sendFXPacket(World worldObj, IPacketFX pkt) {
HelperLocation loc = pkt.getLocation();
channel.sendToAllAround(

View File

@ -696,7 +696,7 @@ public class BlockApparatusMetal extends BlockApparatus {
if (meta == MetaVals.VOID_INTERFACE) {
TileVoidInterface tvi = (TileVoidInterface) w.getTileEntity(i, j, k);
if (tvi != null && tvi.linked && w.rand.nextInt(10) == 0) {
if (tvi != null && tvi.getLinkedSize() > 1 && w.rand.nextInt(10) == 0) {
FXLightningBolt bolt = new FXLightningBolt(
w,
new WRVector3((double) i + 0.5, (double) j + 0.75, (double) k + 0.5),

View File

@ -0,0 +1,82 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.tiles.TileVoidChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerVoidChest extends Container {
private TileVoidChest vchest;
public ContainerVoidChest(InventoryPlayer inventoryplayer, TileVoidChest vc) {
this.vchest = vc;
vc.openInventory();
int j;
int k;
for (j = 0; j < 8; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(new Slot(vc, k + j * 9, 8 + k * 18, 9 + j * 18));
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 158 + j * 18)
);
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 216));
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 72) {
if (!this.mergeItemStack(itemstack1, 72, 108, true)) {
return null;
}
} else if (i >= 72 && i <= 108) {
if (!this.mergeItemStack(itemstack1, 0, 72, false)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 72, 108, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
}
return itemstack;
}
@Override
public void onContainerClosed(EntityPlayer player) {
super.onContainerClosed(player);
this.vchest.closeInventory();
}
}

View File

@ -0,0 +1,135 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerVoidInterface extends Container {
public TileVoidInterface vinter;
public ItemStack[] clientItems = new ItemStack[72];
public ContainerVoidInterface(InventoryPlayer inventoryplayer, TileVoidInterface vc) {
this.vinter = vc;
int j;
int k;
for (j = 0; j < 8; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(
new SlotVoidInterface(vc, 72 + k + j * 9, 8 + k * 18, 9 + j * 18)
);
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 158 + j * 18)
);
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 216));
}
this.vinter.openInventory();
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 72) {
if (!this.mergeItemStack(itemstack1, 72, 108, true)) {
return null;
}
} else if (i >= 72 && i <= 108) {
if (!this.mergeItemStack(itemstack1, 0, 72, false)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 72, 108, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
}
return itemstack;
}
@Override
public void onContainerClosed(EntityPlayer player) {
super.onContainerClosed(player);
this.vinter.closeInventory();
}
public class SlotVoidInterface extends Slot {
public SlotVoidInterface(
IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_
) {
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
}
@Override
public ItemStack getStack() {
if (ContainerVoidInterface.this.vinter.getWorldObj().isRemote)
return ContainerVoidInterface.this.clientItems[this.slotNumber];
return ((TileVoidInterface) this.inventory)
.getStackInSlotForCurrentLink(this.slotNumber);
}
@Override
public ItemStack decrStackSize(int i) {
if (ContainerVoidInterface.this.vinter.getWorldObj().isRemote) {
ItemStack stack
= ContainerVoidInterface.this.clientItems[this.slotNumber];
if (stack == null)
return null;
if (stack.stackSize <= i) {
ContainerVoidInterface.this.clientItems[this.slotNumber] = null;
return stack;
}
return stack.splitStack(i);
}
return ((TileVoidInterface) this.inventory)
.decrStackSizeForCurrentLink(this.slotNumber, i);
}
@Override
public void putStack(ItemStack stack) {
if (ContainerVoidInterface.this.vinter.getWorldObj().isRemote) {
ContainerVoidInterface.this.clientItems[this.slotNumber] = stack;
return;
}
((TileVoidInterface) this.inventory)
.setInventorySlotContentsForCurrentLink(this.slotNumber, stack);
this.onSlotChanged();
}
}
}

View File

@ -0,0 +1,27 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.container.ContainerVoidChest;
import net.anvilcraft.thaummach.tiles.TileVoidChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiVoidChest extends GuiContainer {
public GuiVoidChest(InventoryPlayer inventoryplayer, TileVoidChest vc) {
super(new ContainerVoidChest(inventoryplayer, vc));
super.ySize = 239;
}
protected void drawGuiContainerForegroundLayer() {}
protected void drawGuiContainerBackgroundLayer(float f, int qq, int ww) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("thaummach", "textures/guis/voidchest.png")
);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
}
}

View File

@ -0,0 +1,121 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.ThaumicMachinery;
import net.anvilcraft.thaummach.container.ContainerVoidInterface;
import net.anvilcraft.thaummach.packets.PacketChangeVoidInterfaceChannel;
import net.anvilcraft.thaummach.packets.PacketChangeVoidInterfaceContainerPage;
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiVoidInterface extends GuiContainer {
TileVoidInterface voidInventory;
public GuiVoidInterface(InventoryPlayer inventoryplayer, TileVoidInterface vc) {
super(new ContainerVoidInterface(inventoryplayer, vc));
this.voidInventory = vc;
super.ySize = 239;
super.xSize = 219;
vc.openInventory();
}
@Override
protected void drawGuiContainerForegroundLayer(int alec1, int alec2) {
if (this.voidInventory.getLinkedSize() > 1) {
super.fontRendererObj.drawStringWithShadow(
this.voidInventory.current + 1 + "/" + this.voidInventory.getLinkedSize(),
195,
88,
0x704070
);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int qq, int ww) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("thaummach", "textures/guis/void_interface.png")
);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
this.drawTexturedModalRect(
j + 178, k + 24, 224, this.voidInventory.network * 32, 32, 32
);
}
@Override
protected void mouseClicked(int i, int j, int k) {
super.mouseClicked(i, j, k);
int sx = (super.width - super.xSize) / 2;
int sy = (super.height - super.ySize) / 2;
int k1 = i - (sx + 178);
int l1 = j - (sy + 64);
if (k1 >= 0 && l1 >= 0 && k1 < 14 && l1 <= 28) {
this.voidInventory.getWorldObj().playSoundEffect(
(double) this.voidInventory.xCoord + 0.5,
(double) this.voidInventory.yCoord + 0.5,
(double) this.voidInventory.zCoord + 0.5,
"random.click",
0.1F,
0.6F
);
if (this.voidInventory.current > 0) {
--this.voidInventory.current;
ThaumicMachinery.channel.sendToServer(
new PacketChangeVoidInterfaceContainerPage(this.voidInventory.current)
);
}
}
k1 = i - (sx + 178);
l1 = j - (sy + 92);
if (k1 >= 0 && l1 >= 0 && k1 < 14 && l1 <= 28) {
this.voidInventory.getWorldObj().playSoundEffect(
(double) this.voidInventory.xCoord + 0.5,
(double) this.voidInventory.yCoord + 0.5,
(double) this.voidInventory.zCoord + 0.5,
"random.click",
0.1F,
0.8F
);
if (this.voidInventory.current < this.voidInventory.getLinkedSize() - 1) {
++this.voidInventory.current;
ThaumicMachinery.channel.sendToServer(
new PacketChangeVoidInterfaceContainerPage(this.voidInventory.current)
);
}
}
k1 = i - (sx + 178);
l1 = j - (sy + 24);
if (k1 >= 0 && l1 >= 0 && k1 < 32 && l1 <= 32) {
this.voidInventory.getWorldObj().playSoundEffect(
(double) this.voidInventory.xCoord + 0.5,
(double) this.voidInventory.yCoord + 0.5,
(double) this.voidInventory.zCoord + 0.5,
"random.click",
0.1F,
0.8F
);
byte newChannel = (byte) (this.voidInventory.network + (k == 0 ? 1 : -1));
if (newChannel < 0)
newChannel = 5;
else if (newChannel >= 6)
newChannel = 0;
ThaumicMachinery.channel.sendToServer(new PacketChangeVoidInterfaceChannel(
this.voidInventory.xCoord,
this.voidInventory.yCoord,
this.voidInventory.zCoord,
newChannel
));
}
}
}

View File

@ -0,0 +1,74 @@
package net.anvilcraft.thaummach.packets;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.anvilcraft.thaummach.RuneTileData;
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PacketChangeVoidInterfaceChannel implements IMessage {
int x;
int y;
int z;
byte channel;
public PacketChangeVoidInterfaceChannel() {}
public PacketChangeVoidInterfaceChannel(int x, int y, int z, byte channel) {
this.x = x;
this.y = y;
this.z = z;
this.channel = channel;
}
@Override
public void fromBytes(ByteBuf buf) {
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.channel = buf.readByte();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeByte(this.channel);
}
public static class Handler
implements IMessageHandler<PacketChangeVoidInterfaceChannel, IMessage> {
@Override
public IMessage
onMessage(PacketChangeVoidInterfaceChannel msg, MessageContext ctx) {
World world = ctx.getServerHandler().playerEntity.worldObj;
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (!(te instanceof TileVoidInterface))
return null;
TileVoidInterface vi = (TileVoidInterface) te;
if (msg.channel >= 0 && msg.channel < 6) {
for (RuneTileData rtd : TileVoidInterface.VOID_INTERFACES) {
if (rtd.x == vi.xCoord && rtd.y == vi.yCoord && rtd.z == vi.zCoord
&& rtd.dim == vi.getWorldObj().provider.dimensionId) {
rtd.rune = msg.channel;
break;
}
}
vi.network = msg.channel;
vi.invalidateLinks();
}
world.markBlockForUpdate(msg.x, msg.y, msg.z);
return null;
}
}
}

View File

@ -0,0 +1,53 @@
package net.anvilcraft.thaummach.packets;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.anvilcraft.thaummach.container.ContainerVoidInterface;
import net.minecraft.inventory.Container;
public class PacketChangeVoidInterfaceContainerPage implements IMessage {
int page;
public PacketChangeVoidInterfaceContainerPage() {}
public PacketChangeVoidInterfaceContainerPage(int page) {
this.page = page;
}
@Override
public void fromBytes(ByteBuf buf) {
this.page = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.page);
}
public static class Handler
implements IMessageHandler<PacketChangeVoidInterfaceContainerPage, IMessage> {
@Override
public IMessage
onMessage(PacketChangeVoidInterfaceContainerPage msg, MessageContext ctx) {
Container container = ctx.getServerHandler().playerEntity.openContainer;
if (!(container instanceof ContainerVoidInterface))
return null;
ContainerVoidInterface cvi = (ContainerVoidInterface) container;
if (msg.page >= 0 && msg.page < cvi.vinter.getLinkedSize()) {
cvi.vinter.current = msg.page;
cvi.detectAndSendChanges();
}
ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(
cvi.vinter.xCoord, cvi.vinter.yCoord, cvi.vinter.zCoord
);
return null;
}
}
}

View File

@ -135,7 +135,7 @@ public class TileBore extends TileEntity implements ISidedInventory, ITileGui {
(double) super.xCoord,
(double) super.yCoord,
(double) super.zCoord,
"mob.slimeattack",
"mob.slime.attack",
0.3F,
0.1F + super.worldObj.rand.nextFloat() * 0.3F
);

View File

@ -2,22 +2,22 @@ package net.anvilcraft.thaummach.tiles;
import java.util.stream.IntStream;
import net.minecraft.client.gui.GuiScreen;
import net.anvilcraft.thaummach.GuiID;
import net.anvilcraft.thaummach.ITileGui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
public class TileVoidChest extends TileEntity implements ISidedInventory {
private ItemStack[] vcItemStacks = new ItemStack[72];
public class TileVoidChest extends TileEntity implements ISidedInventory, ITileGui {
public ItemStack[] vcItemStacks = new ItemStack[72];
// TODO: GUIs
//public GuiScreen getGui(EntityPlayer player) {
// return new GuiVoidChest(player.inventory, this);
//}
@Override
public GuiID getGuiID() {
return GuiID.VOID_CHEST;
}
@Override
public void invalidate() {
@ -129,7 +129,16 @@ public class TileVoidChest extends TileEntity implements ISidedInventory {
}
@Override
public void openInventory() {}
public void openInventory() {
super.worldObj.playSoundEffect(
(double) ((float) super.xCoord + 0.5F),
(double) ((float) super.yCoord + 0.5F),
(double) ((float) super.zCoord + 0.5F),
"thaummach:stoneopen",
1.0F,
1.0F
);
}
@Override
public boolean hasCustomInventoryName() {

View File

@ -2,29 +2,41 @@ package net.anvilcraft.thaummach.tiles;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.stream.IntStream;
import dev.tilera.auracore.api.HelperLocation;
import net.anvilcraft.thaummach.GuiID;
import net.anvilcraft.thaummach.ITileGui;
import net.anvilcraft.thaummach.RuneTileData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
public class TileVoidInterface extends TileEntity implements ISidedInventory {
public class TileVoidInterface extends TileEntity implements ISidedInventory, ITileGui {
// TODO: WTF
public static Set<RuneTileData> VOID_INTERFACES = new HashSet<>();
public byte network = 0;
public ArrayList<HelperLocation> links = new ArrayList<>();
public boolean linked = false;
public int current = 0;
public boolean init = false;
private int linkSize;
@Override
public GuiID getGuiID() {
return GuiID.VOID_INTERFACE;
}
public int getLinkedSize() {
return this.links.size();
return this.worldObj.isRemote ? this.linkSize : this.links.size();
}
@Override
@ -74,34 +86,17 @@ public class TileVoidInterface extends TileEntity implements ISidedInventory {
} catch (Exception var6) {}
}
// TODO: WTF
//@Override
//public ItemStack getStackInSlotVirtual(int i) {
// try {
// return this.getInventory(this.links.get(this.current)).getStackInSlot(i %
// 72);
// } catch (Exception var3) {
// return null;
// }
//}
public ItemStack getStackInSlotForCurrentLink(int i) {
return this.getStackInSlot(i + this.current * 72);
}
//@Override
//public ItemStack decrStackSizeVirtual(int i, int j) {
// try {
// return this.getInventory(this.links.get(this.current))
// .decrStackSize(i % 72, j);
// } catch (Exception var4) {
// return null;
// }
//}
public ItemStack decrStackSizeForCurrentLink(int i, int j) {
return this.decrStackSize(i + this.current * 72, j);
}
//@Override
//public void setInventorySlotContentsVirtual(int i, ItemStack itemstack) {
// try {
// this.getInventory(this.links.get(this.current))
// .setInventorySlotContents(i % 72, itemstack);
// } catch (Exception var4) {}
//}
public void setInventorySlotContentsForCurrentLink(int i, ItemStack stack) {
this.setInventorySlotContents(i + this.current * 72, stack);
}
public void establishLinks() {
this.current = 0;
@ -130,30 +125,50 @@ public class TileVoidInterface extends TileEntity implements ISidedInventory {
}
}
this.linked = this.links.size() > 1;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
public void invalidateLinks() {
for (RuneTileData rtd : VOID_INTERFACES) {
if (rtd.rune != this.network)
Iterator<RuneTileData> iter = VOID_INTERFACES.iterator();
while (iter.hasNext()) {
RuneTileData rtd = iter.next();
if (rtd.dim != this.worldObj.provider.dimensionId)
continue;
TileEntity te = this.worldObj.getTileEntity(rtd.x, rtd.y, rtd.z);
if (!(te instanceof TileVoidInterface)) {
VOID_INTERFACES.remove(rtd);
// TODO: WTF WTF WTF WTF
this.invalidateLinks();
break;
}
if (te != null) {
iter.remove();
} else {
TileVoidInterface tvi = (TileVoidInterface) te;
tvi.markDirty();
tvi.clearLinks();
this.worldObj.markBlockForUpdate(tvi.xCoord, tvi.yCoord, tvi.zCoord);
}
}
}
//public void invalidateLinks() {
// for (RuneTileData rtd : VOID_INTERFACES) {
// if (rtd.rune != this.network)
// continue;
// TileEntity te = this.worldObj.getTileEntity(rtd.x, rtd.y, rtd.z);
// if (!(te instanceof TileVoidInterface)) {
// VOID_INTERFACES.remove(rtd);
// // TODO: WTF WTF WTF WTF
// this.invalidateLinks();
// break;
// }
// if (te != null) {
// TileVoidInterface tvi = (TileVoidInterface) te;
// tvi.markDirty();
// tvi.clearLinks();
// this.worldObj.markBlockForUpdate(tvi.xCoord, tvi.yCoord, tvi.zCoord);
// }
// }
// this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
//}
public void clearLinks() {
this.current = 0;
this.links.clear();
@ -179,10 +194,14 @@ public class TileVoidInterface extends TileEntity implements ISidedInventory {
@Override
public void updateEntity() {
super.updateEntity();
if (this.worldObj.isRemote)
return;
if (!this.init) {
this.init = true;
VOID_INTERFACES.add(new RuneTileData(this, this.network));
this.invalidateLinks();
}
if (this.links.size() == 0) {
@ -206,7 +225,16 @@ public class TileVoidInterface extends TileEntity implements ISidedInventory {
}
@Override
public void openInventory() {}
public void openInventory() {
this.worldObj.playSoundEffect(
(double) ((float) this.xCoord + 0.5F),
(double) ((float) this.yCoord + 0.5F),
(double) ((float) this.zCoord + 0.5F),
"thaummach:heal",
1.0F,
1.4F
);
}
@Override
public void closeInventory() {}
@ -237,4 +265,26 @@ public class TileVoidInterface extends TileEntity implements ISidedInventory {
return thisStack != null && thisStack.isItemEqual(otherStack)
&& thisStack.stackSize >= otherStack.stackSize;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("network", this.network);
nbt.setInteger("linkSize", this.getLinkedSize());
nbt.setInteger("current", this.current);
return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.network = nbt.getByte("network");
this.linkSize = nbt.getInteger("linkSize");
this.current = nbt.getInteger("current");
}
}

View File

@ -1,6 +1,6 @@
{
"popen": {
"category": "master",
"category": "block",
"sounds": [
{
"name": "popen",
@ -9,12 +9,39 @@
]
},
"pclose": {
"category": "master",
"category": "block",
"sounds": [
{
"name": "pclose",
"stream": false
}
]
},
"stoneopen": {
"category": "block",
"sounds": [
{
"name": "stoneopen",
"stream": false
}
]
},
"stoneclose": {
"category": "block",
"sounds": [
{
"name": "stoneclose",
"stream": false
}
]
},
"heal": {
"category": "master",
"sounds": [
{
"name": "heal",
"stream": false
}
]
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB