generated from tilera/1710mod
feat: implement arcane bore
This commit is contained in:
parent
4a1289e3d1
commit
3b5dc79af2
|
@ -5,6 +5,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
|
|||
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.render.BlockApparatusRenderer;
|
||||
import net.anvilcraft.thaummach.render.TileSealRenderer;
|
||||
import net.anvilcraft.thaummach.render.entity.EntitySingularityRenderer;
|
||||
|
@ -27,6 +28,9 @@ import net.anvilcraft.thaummach.tiles.TileSeal;
|
|||
import net.anvilcraft.thaummach.tiles.TileSoulBrazier;
|
||||
import net.anvilcraft.thaummach.tiles.TileVoidChest;
|
||||
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
|
@ -74,4 +78,17 @@ public class ClientProxy extends CommonProxy {
|
|||
TileVoidInterface.class, "voidInterface", new TileVoidInterfaceRenderer()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object
|
||||
getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
switch (GuiID.get(id)) {
|
||||
case BORE:
|
||||
return new GuiBore(player.inventory, (TileBore) te);
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("ALEC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,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.tiles.TileBore;
|
||||
import net.anvilcraft.thaummach.tiles.TileConduit;
|
||||
import net.anvilcraft.thaummach.tiles.TileConduitPump;
|
||||
|
@ -15,8 +17,11 @@ import net.anvilcraft.thaummach.tiles.TileSeal;
|
|||
import net.anvilcraft.thaummach.tiles.TileSoulBrazier;
|
||||
import net.anvilcraft.thaummach.tiles.TileVoidChest;
|
||||
import net.anvilcraft.thaummach.tiles.TileVoidInterface;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CommonProxy {
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
public void preInit() {}
|
||||
|
||||
public void init() {}
|
||||
|
@ -39,4 +44,23 @@ public class CommonProxy {
|
|||
GameRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface");
|
||||
GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object
|
||||
getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
switch (GuiID.get(id)) {
|
||||
case BORE:
|
||||
return new ContainerBore(player.inventory, (TileBore) te);
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("ALEC");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object
|
||||
getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package net.anvilcraft.thaummach;
|
||||
|
||||
public enum GuiID {
|
||||
BORE;
|
||||
|
||||
public static GuiID get(int id) {
|
||||
if (id >= 0 && id < GuiID.values().length) {
|
||||
return GuiID.values()[id];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package net.anvilcraft.thaummach;
|
||||
|
||||
public interface ITileGui {
|
||||
public GuiID getGuiID();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package net.anvilcraft.thaummach;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotInventory extends Slot {
|
||||
public SlotInventory(IInventory inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return this.inventory.isItemValidForSlot(this.slotNumber, stack);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,9 @@ import net.minecraft.world.World;
|
|||
|
||||
@Mod(modid = "thaummach")
|
||||
public class ThaumicMachinery {
|
||||
@Mod.Instance("thaummach")
|
||||
public static ThaumicMachinery INSTANCE;
|
||||
|
||||
@SidedProxy(
|
||||
modId = "thaummach",
|
||||
serverSide = "net.anvilcraft.thaummach.CommonProxy",
|
||||
|
@ -38,6 +41,8 @@ public class ThaumicMachinery {
|
|||
new PacketFXSparkle.Handler(), PacketFXSparkle.class, pktid++, Side.CLIENT
|
||||
);
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
|
||||
|
||||
proxy.registerTileEntities();
|
||||
TMBlocks.init();
|
||||
TMItems.init();
|
||||
|
|
|
@ -2,7 +2,10 @@ package net.anvilcraft.thaummach.blocks;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.anvilcraft.thaummach.GuiID;
|
||||
import net.anvilcraft.thaummach.ITileGui;
|
||||
import net.anvilcraft.thaummach.TMTab;
|
||||
import net.anvilcraft.thaummach.ThaumicMachinery;
|
||||
import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
@ -55,9 +58,9 @@ public abstract class BlockApparatus extends BlockContainer {
|
|||
@Override
|
||||
public boolean onBlockActivated(
|
||||
World world,
|
||||
int i,
|
||||
int j,
|
||||
int k,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
EntityPlayer entityplayer,
|
||||
// useless parameters
|
||||
int alec1,
|
||||
|
@ -65,20 +68,21 @@ public abstract class BlockApparatus extends BlockContainer {
|
|||
float alec3,
|
||||
float alec4
|
||||
) {
|
||||
if (!world.isRemote && !entityplayer.isSneaking()) {
|
||||
// TODO: WTF
|
||||
//TileEntity te = world.getTileEntity(i, j, k);
|
||||
//if (te != null && te instanceof ITileGui) {
|
||||
// ModLoader.openGUI(entityplayer, ((ITileGui) te).getGui(entityplayer));
|
||||
// return true;
|
||||
//} else {
|
||||
// return false;
|
||||
//}
|
||||
if (!entityplayer.isSneaking()) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof ITileGui) {
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
GuiID id = ((ITileGui) te).getGuiID();
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
entityplayer.openGui(
|
||||
ThaumicMachinery.INSTANCE, id.ordinal(), world, x, y, z
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,4 +143,10 @@ public abstract class BlockApparatus extends BlockContainer {
|
|||
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
super.onPostBlockPlaced(world, x, y, z, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
|
||||
super.onNeighborBlockChange(world, x, y, z, neighbor);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package net.anvilcraft.thaummach.container;
|
||||
|
||||
import net.anvilcraft.thaummach.SlotInventory;
|
||||
import net.anvilcraft.thaummach.items.ItemFocus;
|
||||
import net.anvilcraft.thaummach.items.ItemSingularity;
|
||||
import net.anvilcraft.thaummach.tiles.TileBore;
|
||||
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 ContainerBore extends Container {
|
||||
private TileBore arcaneBore;
|
||||
|
||||
public ContainerBore(InventoryPlayer inventoryplayer, TileBore tileBore) {
|
||||
this.arcaneBore = tileBore;
|
||||
this.addSlotToContainer(new SlotInventory(tileBore, 0, 65, 17));
|
||||
this.addSlotToContainer(new SlotInventory(tileBore, 1, 65, 55));
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 9; ++k) {
|
||||
this.addSlotToContainer(
|
||||
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 84 + j * 18)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return this.arcaneBore.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@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 < 2) {
|
||||
if (!this.mergeItemStack(itemstack1, 2, 38, true)) {
|
||||
return null;
|
||||
}
|
||||
} else if (i >= 2 && i < 38) {
|
||||
if (itemstack.getItem() instanceof ItemFocus) {
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
return null;
|
||||
} else if (itemstack.getItem() instanceof ItemSingularity) {
|
||||
if (!this.mergeItemStack(itemstack1, 1, 2, false))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: WTF
|
||||
//slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -75,9 +75,6 @@ public class EntitySingularity extends Entity {
|
|||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
System.out.println(
|
||||
"AAALEC: " + this.motionX + " " + this.motionY + " " + this.motionZ
|
||||
);
|
||||
if (this.fuse-- == 0) {
|
||||
this.explode();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package net.anvilcraft.thaummach.gui;
|
||||
|
||||
import net.anvilcraft.thaummach.container.ContainerBore;
|
||||
import net.anvilcraft.thaummach.tiles.TileBore;
|
||||
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 GuiBore extends GuiContainer {
|
||||
private TileBore arcaneBore;
|
||||
|
||||
public GuiBore(InventoryPlayer inventoryplayer, TileBore tileBore) {
|
||||
super(new ContainerBore(inventoryplayer, tileBore));
|
||||
this.arcaneBore = tileBore;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int alec1, int alec2) {
|
||||
super.fontRendererObj.drawString("Arcane Bore", 54, 5, 0x404040);
|
||||
}
|
||||
|
||||
@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/bore.png")
|
||||
);
|
||||
int l = (super.width - super.xSize) / 2;
|
||||
int i1 = (super.height - super.ySize) / 2;
|
||||
this.drawTexturedModalRect(l, i1, 0, 0, super.xSize, super.ySize);
|
||||
if (this.arcaneBore.duration > 0) {
|
||||
int q = (int
|
||||
) ((float) this.arcaneBore.duration / (float) this.arcaneBore.maxDuration
|
||||
* 46.0F);
|
||||
this.drawTexturedModalRect(l + 103, i1 + 66 - q, 176, 46 - q, 9, q + 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,11 @@ public class PacketFXWisp implements IPacketFX {
|
|||
double x;
|
||||
double y;
|
||||
double z;
|
||||
|
||||
double mx;
|
||||
double my;
|
||||
double mz;
|
||||
|
||||
float f;
|
||||
int type;
|
||||
boolean shrink;
|
||||
|
@ -29,6 +34,34 @@ public class PacketFXWisp implements IPacketFX {
|
|||
this.type = type;
|
||||
this.shrink = shrink;
|
||||
this.gravity = gravity;
|
||||
|
||||
this.mx = x;
|
||||
this.my = y;
|
||||
this.mz = z;
|
||||
}
|
||||
|
||||
public PacketFXWisp(
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double mx,
|
||||
double my,
|
||||
double mz,
|
||||
float f,
|
||||
int type,
|
||||
boolean shrink,
|
||||
float gravity
|
||||
) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.mx = mx;
|
||||
this.my = my;
|
||||
this.mz = mz;
|
||||
this.f = f;
|
||||
this.type = type;
|
||||
this.shrink = shrink;
|
||||
this.gravity = gravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,6 +69,9 @@ public class PacketFXWisp implements IPacketFX {
|
|||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
this.mx = buf.readDouble();
|
||||
this.my = buf.readDouble();
|
||||
this.mz = buf.readDouble();
|
||||
this.f = buf.readFloat();
|
||||
this.type = buf.readInt();
|
||||
this.shrink = buf.readBoolean();
|
||||
|
@ -47,6 +83,9 @@ public class PacketFXWisp implements IPacketFX {
|
|||
buf.writeDouble(this.x);
|
||||
buf.writeDouble(this.y);
|
||||
buf.writeDouble(this.z);
|
||||
buf.writeDouble(this.mx);
|
||||
buf.writeDouble(this.my);
|
||||
buf.writeDouble(this.mz);
|
||||
buf.writeFloat(this.f);
|
||||
buf.writeInt(this.type);
|
||||
buf.writeBoolean(this.shrink);
|
||||
|
@ -58,7 +97,15 @@ public class PacketFXWisp implements IPacketFX {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public EntityFX readFX(PacketFXWisp msg) {
|
||||
FXWisp fx = new FXWisp(
|
||||
Minecraft.getMinecraft().theWorld, msg.x, msg.y, msg.z, msg.f, msg.type
|
||||
Minecraft.getMinecraft().theWorld,
|
||||
msg.x,
|
||||
msg.y,
|
||||
msg.z,
|
||||
msg.mx,
|
||||
msg.my,
|
||||
msg.mz,
|
||||
msg.f,
|
||||
msg.type
|
||||
);
|
||||
|
||||
fx.shrink = msg.shrink;
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package net.anvilcraft.thaummach.render.tile;
|
||||
|
||||
import net.anvilcraft.thaummach.TMBlocks;
|
||||
import net.anvilcraft.thaummach.blocks.BlockApparatusMetal;
|
||||
import net.anvilcraft.thaummach.render.apparatus.ApparatusRenderingHelper;
|
||||
import net.anvilcraft.thaummach.tiles.TileBore;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemEnderPearl;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -19,41 +15,41 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
|
|||
private ModelCrystal model = new ModelCrystal();
|
||||
|
||||
public void renderEntityAt(TileBore cr, double x, double y, double z, float fq) {
|
||||
if (true || cr.focus != -1) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int count = mc.thePlayer.ticksExisted;
|
||||
float bob = 0.0F;
|
||||
float angleS = (float) cr.rotation;
|
||||
float jitter = 0.0F;
|
||||
if (cr.duration > 0 && cr.gettingPower()) {
|
||||
jitter = (cr.getWorldObj().rand.nextFloat()
|
||||
- cr.getWorldObj().rand.nextFloat())
|
||||
* 0.1F;
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int count = mc.thePlayer.ticksExisted;
|
||||
float bob = 0.0F;
|
||||
float angleS = (float) cr.rotation;
|
||||
float jitter = 0.0F;
|
||||
if (cr.duration > 0 && cr.gettingPower()) {
|
||||
jitter
|
||||
= (cr.getWorldObj().rand.nextFloat() - cr.getWorldObj().rand.nextFloat())
|
||||
* 0.1F;
|
||||
}
|
||||
|
||||
this.translateFromOrientation(x, y, z, cr.orientation);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.0F);
|
||||
GL11.glRotatef(angleS, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.25f, 0.25f, 0.0F);
|
||||
GL11.glScalef(-0.5f, -0.5f, 1f);
|
||||
// TODO: rüssel
|
||||
//ThaumCraftRenderer.renderItemFromTexture(
|
||||
// mc,
|
||||
// "/thaumcraft/resources/items.png",
|
||||
// 16,
|
||||
// 43 + cr.focus,
|
||||
// 0.4F,
|
||||
// 1.5F + jitter,
|
||||
// true,
|
||||
// 1.0F,
|
||||
// 1.0F,
|
||||
// 1.0F,
|
||||
// 220,
|
||||
// 771
|
||||
//);
|
||||
this.translateFromOrientation(x, y, z, cr.orientation);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.0F);
|
||||
GL11.glRotatef(angleS, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.25f, 0.25f, 0.0F);
|
||||
GL11.glScalef(-0.5f, -0.5f, 1f);
|
||||
// TODO: rüssel
|
||||
//ThaumCraftRenderer.renderItemFromTexture(
|
||||
// mc,
|
||||
// "/thaumcraft/resources/items.png",
|
||||
// 16,
|
||||
// 43 + cr.focus,
|
||||
// 0.4F,
|
||||
// 1.5F + jitter,
|
||||
// true,
|
||||
// 1.0F,
|
||||
// 1.0F,
|
||||
// 1.0F,
|
||||
// 220,
|
||||
// 771
|
||||
//);
|
||||
|
||||
if (cr.boreItemStacks[0] != null) {
|
||||
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
IIcon icon = Items.ender_eye.getIconFromDamage(0);
|
||||
IIcon icon = cr.boreItemStacks[0].getIconIndex();
|
||||
ApparatusRenderingHelper.renderItemIn2D(
|
||||
Tessellator.instance,
|
||||
icon.getMaxU(),
|
||||
|
@ -62,13 +58,13 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
|
|||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
1.0f,
|
||||
0.6f + jitter,
|
||||
128
|
||||
);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void translateFromOrientation(double x, double y, double z, int orientation) {
|
||||
|
|
|
@ -6,10 +6,14 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import dev.tilera.auracore.api.HelperLocation;
|
||||
import net.anvilcraft.thaummach.GuiID;
|
||||
import net.anvilcraft.thaummach.ITileGui;
|
||||
import net.anvilcraft.thaummach.TMItems;
|
||||
import net.anvilcraft.thaummach.ThaumicMachinery;
|
||||
import net.anvilcraft.thaummach.items.ItemFocus;
|
||||
import net.anvilcraft.thaummach.items.ItemSingularity;
|
||||
import net.anvilcraft.thaummach.packets.PacketFXWisp;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -25,9 +29,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.client.fx.particles.FXWisp;
|
||||
|
||||
public class TileBore extends TileEntity implements ISidedInventory {
|
||||
public class TileBore extends TileEntity implements ISidedInventory, ITileGui {
|
||||
public int orientation = 0;
|
||||
public int duration;
|
||||
public int maxDuration;
|
||||
|
@ -38,8 +41,9 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
private int area = 2;
|
||||
private int delay = 4;
|
||||
private boolean conserve = false;
|
||||
private ItemStack[] boreItemStacks;
|
||||
public ItemStack[] boreItemStacks;
|
||||
private Map<Integer, EntityItem> entities;
|
||||
private boolean isActive;
|
||||
|
||||
public TileBore() {
|
||||
this.orientation = 0;
|
||||
|
@ -47,11 +51,6 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
this.entities = new HashMap<>();
|
||||
}
|
||||
|
||||
// TODO: GUIs
|
||||
//public GuiScreen getGui(EntityPlayer player) {
|
||||
// return new GuiBore(player.inventory, this);
|
||||
//}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
@ -65,31 +64,6 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
|
||||
if (!super.worldObj.isRemote) {
|
||||
int a;
|
||||
if (this.boreItemStacks[0] != null
|
||||
&& this.boreItemStacks[0].getItem() instanceof ItemFocus) {
|
||||
if (this.boreItemStacks[0] != null) {
|
||||
float f = super.worldObj.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = super.worldObj.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = super.worldObj.rand.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityitem = new EntityItem(
|
||||
super.worldObj,
|
||||
(double) ((float) super.xCoord + f),
|
||||
(double) ((float) super.yCoord + f1),
|
||||
(double) ((float) super.zCoord + f2),
|
||||
ItemStack.copyItemStack(this.boreItemStacks[0])
|
||||
);
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX
|
||||
= (double) ((float) super.worldObj.rand.nextGaussian() * f3);
|
||||
entityitem.motionY = (double
|
||||
) ((float) super.worldObj.rand.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motionZ
|
||||
= (double) ((float) super.worldObj.rand.nextGaussian() * f3);
|
||||
super.worldObj.spawnEntityInWorld(entityitem);
|
||||
this.boreItemStacks[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.focus = -1;
|
||||
if (this.boreItemStacks[0] != null
|
||||
&& this.boreItemStacks[0].getItem() == TMItems.focus0) {
|
||||
|
@ -151,6 +125,7 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
if (this.boreItemStacks[0].getItemDamage()
|
||||
> this.boreItemStacks[0].getMaxDamage()) {
|
||||
this.boreItemStacks[0] = null;
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -169,20 +144,23 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
HelperLocation hl2 = new HelperLocation(this, this.orientation);
|
||||
hl.moveForwards(1.0);
|
||||
hl2.moveForwards(5.0);
|
||||
FXWisp ef = new FXWisp(
|
||||
super.worldObj,
|
||||
hl.x + 0.5,
|
||||
hl.y + 0.5,
|
||||
hl.z + 0.5,
|
||||
hl2.x + 0.5,
|
||||
hl2.y + 0.5,
|
||||
hl2.z + 0.5,
|
||||
0.6F,
|
||||
this.focus == 0 ? 5 : this.focus
|
||||
|
||||
ThaumicMachinery.sendFXPacket(
|
||||
this.worldObj,
|
||||
new PacketFXWisp(
|
||||
hl.x + 0.5,
|
||||
hl.y + 0.5,
|
||||
hl.z + 0.5,
|
||||
hl2.x + 0.5,
|
||||
hl2.y + 0.5,
|
||||
hl2.z + 0.5,
|
||||
0.6f,
|
||||
this.focus == 0 ? 5 : this.focus,
|
||||
true,
|
||||
0.0f
|
||||
)
|
||||
);
|
||||
ef.shrink = true;
|
||||
ef.blendmode = 1;
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
|
||||
//ef.blendmode = 1;
|
||||
}
|
||||
|
||||
Collection<EntityItem> c = this.entities.values();
|
||||
|
@ -212,12 +190,10 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
}
|
||||
|
||||
public boolean gettingPower() {
|
||||
return super.worldObj.isBlockIndirectlyGettingPowered(
|
||||
super.xCoord, super.yCoord, super.zCoord
|
||||
)
|
||||
|| super.worldObj.isBlockIndirectlyGettingPowered(
|
||||
super.xCoord, super.yCoord + 1, super.zCoord
|
||||
);
|
||||
return this.worldObj.isRemote ? this.isActive
|
||||
: super.worldObj.isBlockIndirectlyGettingPowered(
|
||||
super.xCoord, super.yCoord, super.zCoord
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -319,21 +295,20 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
entity.delayBeforeCanPickup = 2;
|
||||
entity.fireResistance = 50;
|
||||
entity.noClip = true;
|
||||
boolean dp = true;
|
||||
|
||||
if (dp) {
|
||||
FXWisp ef = new FXWisp(
|
||||
super.worldObj,
|
||||
ThaumicMachinery.sendFXPacket(
|
||||
this.worldObj,
|
||||
new PacketFXWisp(
|
||||
(double) ((float) entity.prevPosX),
|
||||
(double) ((float) entity.prevPosY + 0.1F),
|
||||
(double) ((float) entity.prevPosZ),
|
||||
0.4F,
|
||||
this.focus == 0 ? 5 : this.focus
|
||||
);
|
||||
ef.shrink = true;
|
||||
ef.blendmode = 1;
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
|
||||
}
|
||||
this.focus == 0 ? 5 : this.focus,
|
||||
true,
|
||||
0.0f
|
||||
)
|
||||
);
|
||||
//ef.blendmode = 1;
|
||||
|
||||
if (this.entities.get(entity.getEntityId()) == null) {
|
||||
this.entities.put(entity.getEntityId(), entity);
|
||||
|
@ -356,16 +331,18 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
entity.motionZ = 0.0;
|
||||
entity.noClip = false;
|
||||
entity.fireResistance = 1;
|
||||
FXWisp ef = new FXWisp(
|
||||
super.worldObj,
|
||||
(double) ((float) entity.prevPosX),
|
||||
(double) ((float) entity.prevPosY + 0.1F),
|
||||
(double) ((float) entity.prevPosZ),
|
||||
1.0F,
|
||||
this.focus == 0 ? 5 : this.focus
|
||||
ThaumicMachinery.sendFXPacket(
|
||||
this.worldObj,
|
||||
new PacketFXWisp(
|
||||
(double) ((float) entity.prevPosX),
|
||||
(double) ((float) entity.prevPosY + 0.1F),
|
||||
(double) ((float) entity.prevPosZ),
|
||||
1.0F,
|
||||
this.focus == 0 ? 5 : this.focus,
|
||||
true,
|
||||
0.0f
|
||||
)
|
||||
);
|
||||
ef.shrink = true;
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
|
||||
|
||||
switch (this.orientation) {
|
||||
case 0:
|
||||
|
@ -679,6 +656,7 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.boreItemStacks[i] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
|
||||
itemstack.stackSize = this.getInventoryStackLimit();
|
||||
|
@ -862,8 +840,12 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
// TODO: filtering
|
||||
return true;
|
||||
if (slot == 0) {
|
||||
return stack.getItem() instanceof ItemFocus;
|
||||
} else if (slot == 1) {
|
||||
return stack.getItem() instanceof ItemSingularity;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -892,6 +874,13 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
nbt.setShort("orientation", (short) this.orientation);
|
||||
nbt.setShort("duration", (short) this.duration);
|
||||
nbt.setShort("maxDuration", (short) this.maxDuration);
|
||||
nbt.setBoolean("isActive", this.gettingPower());
|
||||
|
||||
if (this.boreItemStacks[0] != null) {
|
||||
NBTTagCompound focus = new NBTTagCompound();
|
||||
this.boreItemStacks[0].writeToNBT(focus);
|
||||
nbt.setTag("focus", focus);
|
||||
}
|
||||
|
||||
return new S35PacketUpdateTileEntity(
|
||||
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
|
||||
|
@ -905,5 +894,16 @@ public class TileBore extends TileEntity implements ISidedInventory {
|
|||
this.orientation = nbt.getShort("orientation");
|
||||
this.duration = nbt.getShort("duration");
|
||||
this.maxDuration = nbt.getShort("maxDuration");
|
||||
this.isActive = nbt.getBoolean("isActive");
|
||||
|
||||
if (nbt.hasKey("focus")) {
|
||||
this.boreItemStacks[0]
|
||||
= ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("focus"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiID getGuiID() {
|
||||
return GuiID.BORE;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue