feat: implement arcane bore

This commit is contained in:
LordMZTE 2023-05-18 22:41:38 +02:00
parent 4a1289e3d1
commit 3b5dc79af2
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
14 changed files with 380 additions and 134 deletions

View file

@ -5,6 +5,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.entities.EntitySingularity; import net.anvilcraft.thaummach.entities.EntitySingularity;
import net.anvilcraft.thaummach.gui.GuiBore;
import net.anvilcraft.thaummach.render.BlockApparatusRenderer; import net.anvilcraft.thaummach.render.BlockApparatusRenderer;
import net.anvilcraft.thaummach.render.TileSealRenderer; import net.anvilcraft.thaummach.render.TileSealRenderer;
import net.anvilcraft.thaummach.render.entity.EntitySingularityRenderer; 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.TileSoulBrazier;
import net.anvilcraft.thaummach.tiles.TileVoidChest; import net.anvilcraft.thaummach.tiles.TileVoidChest;
import net.anvilcraft.thaummach.tiles.TileVoidInterface; 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 { public class ClientProxy extends CommonProxy {
@Override @Override
@ -74,4 +78,17 @@ public class ClientProxy extends CommonProxy {
TileVoidInterface.class, "voidInterface", new TileVoidInterfaceRenderer() 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");
}
}
} }

View file

@ -1,6 +1,8 @@
package net.anvilcraft.thaummach; package net.anvilcraft.thaummach;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.container.ContainerBore;
import net.anvilcraft.thaummach.tiles.TileBore; import net.anvilcraft.thaummach.tiles.TileBore;
import net.anvilcraft.thaummach.tiles.TileConduit; import net.anvilcraft.thaummach.tiles.TileConduit;
import net.anvilcraft.thaummach.tiles.TileConduitPump; 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.TileSoulBrazier;
import net.anvilcraft.thaummach.tiles.TileVoidChest; import net.anvilcraft.thaummach.tiles.TileVoidChest;
import net.anvilcraft.thaummach.tiles.TileVoidInterface; 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 preInit() {}
public void init() {} public void init() {}
@ -39,4 +44,23 @@ public class CommonProxy {
GameRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface"); GameRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface");
GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier"); 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;
}
} }

View file

@ -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;
}
}

View file

@ -0,0 +1,5 @@
package net.anvilcraft.thaummach;
public interface ITileGui {
public GuiID getGuiID();
}

View file

@ -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);
}
}

View file

@ -18,6 +18,9 @@ import net.minecraft.world.World;
@Mod(modid = "thaummach") @Mod(modid = "thaummach")
public class ThaumicMachinery { public class ThaumicMachinery {
@Mod.Instance("thaummach")
public static ThaumicMachinery INSTANCE;
@SidedProxy( @SidedProxy(
modId = "thaummach", modId = "thaummach",
serverSide = "net.anvilcraft.thaummach.CommonProxy", serverSide = "net.anvilcraft.thaummach.CommonProxy",
@ -38,6 +41,8 @@ public class ThaumicMachinery {
new PacketFXSparkle.Handler(), PacketFXSparkle.class, pktid++, Side.CLIENT new PacketFXSparkle.Handler(), PacketFXSparkle.class, pktid++, Side.CLIENT
); );
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
proxy.registerTileEntities(); proxy.registerTileEntities();
TMBlocks.init(); TMBlocks.init();
TMItems.init(); TMItems.init();

View file

@ -2,7 +2,10 @@ package net.anvilcraft.thaummach.blocks;
import java.util.Random; import java.util.Random;
import net.anvilcraft.thaummach.GuiID;
import net.anvilcraft.thaummach.ITileGui;
import net.anvilcraft.thaummach.TMTab; import net.anvilcraft.thaummach.TMTab;
import net.anvilcraft.thaummach.ThaumicMachinery;
import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer; import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@ -55,9 +58,9 @@ public abstract class BlockApparatus extends BlockContainer {
@Override @Override
public boolean onBlockActivated( public boolean onBlockActivated(
World world, World world,
int i, int x,
int j, int y,
int k, int z,
EntityPlayer entityplayer, EntityPlayer entityplayer,
// useless parameters // useless parameters
int alec1, int alec1,
@ -65,20 +68,21 @@ public abstract class BlockApparatus extends BlockContainer {
float alec3, float alec3,
float alec4 float alec4
) { ) {
if (!world.isRemote && !entityplayer.isSneaking()) { if (!entityplayer.isSneaking()) {
// TODO: WTF TileEntity te = world.getTileEntity(x, y, z);
//TileEntity te = world.getTileEntity(i, j, k); if (te instanceof ITileGui) {
//if (te != null && te instanceof ITileGui) { if (world.isRemote)
// ModLoader.openGUI(entityplayer, ((ITileGui) te).getGui(entityplayer)); return true;
// return true; GuiID id = ((ITileGui) te).getGuiID();
//} else {
// return false;
//}
return false; entityplayer.openGui(
} else { ThaumicMachinery.INSTANCE, id.ordinal(), world, x, y, z
return false; );
return true;
}
} }
return false;
} }
@Override @Override
@ -139,4 +143,10 @@ public abstract class BlockApparatus extends BlockContainer {
world.setBlockMetadataWithNotify(x, y, z, meta, 3); world.setBlockMetadataWithNotify(x, y, z, meta, 3);
super.onPostBlockPlaced(world, x, y, z, meta); 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);
}
} }

View file

@ -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;
}
}

View file

@ -75,9 +75,6 @@ public class EntitySingularity extends Entity {
@Override @Override
public void onUpdate() { public void onUpdate() {
System.out.println(
"AAALEC: " + this.motionX + " " + this.motionY + " " + this.motionZ
);
if (this.fuse-- == 0) { if (this.fuse-- == 0) {
this.explode(); this.explode();
} }

View file

@ -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);
}
}
}

View file

@ -12,6 +12,11 @@ public class PacketFXWisp implements IPacketFX {
double x; double x;
double y; double y;
double z; double z;
double mx;
double my;
double mz;
float f; float f;
int type; int type;
boolean shrink; boolean shrink;
@ -29,6 +34,34 @@ public class PacketFXWisp implements IPacketFX {
this.type = type; this.type = type;
this.shrink = shrink; this.shrink = shrink;
this.gravity = gravity; 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 @Override
@ -36,6 +69,9 @@ public class PacketFXWisp implements IPacketFX {
this.x = buf.readDouble(); this.x = buf.readDouble();
this.y = buf.readDouble(); this.y = buf.readDouble();
this.z = buf.readDouble(); this.z = buf.readDouble();
this.mx = buf.readDouble();
this.my = buf.readDouble();
this.mz = buf.readDouble();
this.f = buf.readFloat(); this.f = buf.readFloat();
this.type = buf.readInt(); this.type = buf.readInt();
this.shrink = buf.readBoolean(); this.shrink = buf.readBoolean();
@ -47,6 +83,9 @@ public class PacketFXWisp implements IPacketFX {
buf.writeDouble(this.x); buf.writeDouble(this.x);
buf.writeDouble(this.y); buf.writeDouble(this.y);
buf.writeDouble(this.z); buf.writeDouble(this.z);
buf.writeDouble(this.mx);
buf.writeDouble(this.my);
buf.writeDouble(this.mz);
buf.writeFloat(this.f); buf.writeFloat(this.f);
buf.writeInt(this.type); buf.writeInt(this.type);
buf.writeBoolean(this.shrink); buf.writeBoolean(this.shrink);
@ -58,7 +97,15 @@ public class PacketFXWisp implements IPacketFX {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public EntityFX readFX(PacketFXWisp msg) { public EntityFX readFX(PacketFXWisp msg) {
FXWisp fx = new FXWisp( 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; fx.shrink = msg.shrink;

View file

@ -1,15 +1,11 @@
package net.anvilcraft.thaummach.render.tile; 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.render.apparatus.ApparatusRenderingHelper;
import net.anvilcraft.thaummach.tiles.TileBore; import net.anvilcraft.thaummach.tiles.TileBore;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; 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.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -19,41 +15,41 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
private ModelCrystal model = new ModelCrystal(); private ModelCrystal model = new ModelCrystal();
public void renderEntityAt(TileBore cr, double x, double y, double z, float fq) { public void renderEntityAt(TileBore cr, double x, double y, double z, float fq) {
if (true || cr.focus != -1) { Minecraft mc = Minecraft.getMinecraft();
Minecraft mc = Minecraft.getMinecraft(); int count = mc.thePlayer.ticksExisted;
int count = mc.thePlayer.ticksExisted; float bob = 0.0F;
float bob = 0.0F; float angleS = (float) cr.rotation;
float angleS = (float) cr.rotation; float jitter = 0.0F;
float jitter = 0.0F; if (cr.duration > 0 && cr.gettingPower()) {
if (cr.duration > 0 && cr.gettingPower()) { jitter
jitter = (cr.getWorldObj().rand.nextFloat() = (cr.getWorldObj().rand.nextFloat() - cr.getWorldObj().rand.nextFloat())
- cr.getWorldObj().rand.nextFloat()) * 0.1F;
* 0.1F; }
}
this.translateFromOrientation(x, y, z, cr.orientation); this.translateFromOrientation(x, y, z, cr.orientation);
GL11.glTranslatef(0.5F, 0.5F, 0.0F); GL11.glTranslatef(0.5F, 0.5F, 0.0F);
GL11.glRotatef(angleS, 0.0F, 0.0F, 1.0F); GL11.glRotatef(angleS, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.25f, 0.25f, 0.0F); GL11.glTranslatef(0.25f, 0.25f, 0.0F);
GL11.glScalef(-0.5f, -0.5f, 1f); GL11.glScalef(-0.5f, -0.5f, 1f);
// TODO: rüssel // TODO: rüssel
//ThaumCraftRenderer.renderItemFromTexture( //ThaumCraftRenderer.renderItemFromTexture(
// mc, // mc,
// "/thaumcraft/resources/items.png", // "/thaumcraft/resources/items.png",
// 16, // 16,
// 43 + cr.focus, // 43 + cr.focus,
// 0.4F, // 0.4F,
// 1.5F + jitter, // 1.5F + jitter,
// true, // true,
// 1.0F, // 1.0F,
// 1.0F, // 1.0F,
// 1.0F, // 1.0F,
// 220, // 220,
// 771 // 771
//); //);
if (cr.boreItemStacks[0] != null) {
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
IIcon icon = Items.ender_eye.getIconFromDamage(0); IIcon icon = cr.boreItemStacks[0].getIconIndex();
ApparatusRenderingHelper.renderItemIn2D( ApparatusRenderingHelper.renderItemIn2D(
Tessellator.instance, Tessellator.instance,
icon.getMaxU(), icon.getMaxU(),
@ -62,13 +58,13 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
icon.getMaxV(), icon.getMaxV(),
icon.getIconWidth(), icon.getIconWidth(),
icon.getIconHeight(), icon.getIconHeight(),
1.0f, 0.6f + jitter,
128 128
); );
GL11.glPopMatrix();
GL11.glPopMatrix();
} }
GL11.glPopMatrix();
GL11.glPopMatrix();
} }
private void translateFromOrientation(double x, double y, double z, int orientation) { private void translateFromOrientation(double x, double y, double z, int orientation) {

View file

@ -6,10 +6,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import dev.tilera.auracore.api.HelperLocation; 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.TMItems;
import net.anvilcraft.thaummach.ThaumicMachinery;
import net.anvilcraft.thaummach.items.ItemFocus; 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.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -25,9 +29,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; 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 orientation = 0;
public int duration; public int duration;
public int maxDuration; public int maxDuration;
@ -38,8 +41,9 @@ public class TileBore extends TileEntity implements ISidedInventory {
private int area = 2; private int area = 2;
private int delay = 4; private int delay = 4;
private boolean conserve = false; private boolean conserve = false;
private ItemStack[] boreItemStacks; public ItemStack[] boreItemStacks;
private Map<Integer, EntityItem> entities; private Map<Integer, EntityItem> entities;
private boolean isActive;
public TileBore() { public TileBore() {
this.orientation = 0; this.orientation = 0;
@ -47,11 +51,6 @@ public class TileBore extends TileEntity implements ISidedInventory {
this.entities = new HashMap<>(); this.entities = new HashMap<>();
} }
// TODO: GUIs
//public GuiScreen getGui(EntityPlayer player) {
// return new GuiBore(player.inventory, this);
//}
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
@ -65,31 +64,6 @@ public class TileBore extends TileEntity implements ISidedInventory {
if (!super.worldObj.isRemote) { if (!super.worldObj.isRemote) {
int a; 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; this.focus = -1;
if (this.boreItemStacks[0] != null if (this.boreItemStacks[0] != null
&& this.boreItemStacks[0].getItem() == TMItems.focus0) { && this.boreItemStacks[0].getItem() == TMItems.focus0) {
@ -151,6 +125,7 @@ public class TileBore extends TileEntity implements ISidedInventory {
if (this.boreItemStacks[0].getItemDamage() if (this.boreItemStacks[0].getItemDamage()
> this.boreItemStacks[0].getMaxDamage()) { > this.boreItemStacks[0].getMaxDamage()) {
this.boreItemStacks[0] = null; this.boreItemStacks[0] = null;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} }
break; break;
} }
@ -169,20 +144,23 @@ public class TileBore extends TileEntity implements ISidedInventory {
HelperLocation hl2 = new HelperLocation(this, this.orientation); HelperLocation hl2 = new HelperLocation(this, this.orientation);
hl.moveForwards(1.0); hl.moveForwards(1.0);
hl2.moveForwards(5.0); hl2.moveForwards(5.0);
FXWisp ef = new FXWisp(
super.worldObj, ThaumicMachinery.sendFXPacket(
hl.x + 0.5, this.worldObj,
hl.y + 0.5, new PacketFXWisp(
hl.z + 0.5, hl.x + 0.5,
hl2.x + 0.5, hl.y + 0.5,
hl2.y + 0.5, hl.z + 0.5,
hl2.z + 0.5, hl2.x + 0.5,
0.6F, hl2.y + 0.5,
this.focus == 0 ? 5 : this.focus hl2.z + 0.5,
0.6f,
this.focus == 0 ? 5 : this.focus,
true,
0.0f
)
); );
ef.shrink = true; //ef.blendmode = 1;
ef.blendmode = 1;
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
} }
Collection<EntityItem> c = this.entities.values(); Collection<EntityItem> c = this.entities.values();
@ -212,12 +190,10 @@ public class TileBore extends TileEntity implements ISidedInventory {
} }
public boolean gettingPower() { public boolean gettingPower() {
return super.worldObj.isBlockIndirectlyGettingPowered( return this.worldObj.isRemote ? this.isActive
super.xCoord, super.yCoord, super.zCoord : super.worldObj.isBlockIndirectlyGettingPowered(
) super.xCoord, super.yCoord, super.zCoord
|| super.worldObj.isBlockIndirectlyGettingPowered( );
super.xCoord, super.yCoord + 1, super.zCoord
);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -319,21 +295,20 @@ public class TileBore extends TileEntity implements ISidedInventory {
entity.delayBeforeCanPickup = 2; entity.delayBeforeCanPickup = 2;
entity.fireResistance = 50; entity.fireResistance = 50;
entity.noClip = true; entity.noClip = true;
boolean dp = true;
if (dp) { ThaumicMachinery.sendFXPacket(
FXWisp ef = new FXWisp( this.worldObj,
super.worldObj, new PacketFXWisp(
(double) ((float) entity.prevPosX), (double) ((float) entity.prevPosX),
(double) ((float) entity.prevPosY + 0.1F), (double) ((float) entity.prevPosY + 0.1F),
(double) ((float) entity.prevPosZ), (double) ((float) entity.prevPosZ),
0.4F, 0.4F,
this.focus == 0 ? 5 : this.focus this.focus == 0 ? 5 : this.focus,
); true,
ef.shrink = true; 0.0f
ef.blendmode = 1; )
Minecraft.getMinecraft().effectRenderer.addEffect(ef); );
} //ef.blendmode = 1;
if (this.entities.get(entity.getEntityId()) == null) { if (this.entities.get(entity.getEntityId()) == null) {
this.entities.put(entity.getEntityId(), entity); this.entities.put(entity.getEntityId(), entity);
@ -356,16 +331,18 @@ public class TileBore extends TileEntity implements ISidedInventory {
entity.motionZ = 0.0; entity.motionZ = 0.0;
entity.noClip = false; entity.noClip = false;
entity.fireResistance = 1; entity.fireResistance = 1;
FXWisp ef = new FXWisp( ThaumicMachinery.sendFXPacket(
super.worldObj, this.worldObj,
(double) ((float) entity.prevPosX), new PacketFXWisp(
(double) ((float) entity.prevPosY + 0.1F), (double) ((float) entity.prevPosX),
(double) ((float) entity.prevPosZ), (double) ((float) entity.prevPosY + 0.1F),
1.0F, (double) ((float) entity.prevPosZ),
this.focus == 0 ? 5 : this.focus 1.0F,
this.focus == 0 ? 5 : this.focus,
true,
0.0f
)
); );
ef.shrink = true;
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
switch (this.orientation) { switch (this.orientation) {
case 0: case 0:
@ -679,6 +656,7 @@ public class TileBore extends TileEntity implements ISidedInventory {
@Override @Override
public void setInventorySlotContents(int i, ItemStack itemstack) { public void setInventorySlotContents(int i, ItemStack itemstack) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
this.boreItemStacks[i] = itemstack; this.boreItemStacks[i] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
itemstack.stackSize = this.getInventoryStackLimit(); itemstack.stackSize = this.getInventoryStackLimit();
@ -862,8 +840,12 @@ public class TileBore extends TileEntity implements ISidedInventory {
@Override @Override
public boolean isItemValidForSlot(int slot, ItemStack stack) { public boolean isItemValidForSlot(int slot, ItemStack stack) {
// TODO: filtering if (slot == 0) {
return true; return stack.getItem() instanceof ItemFocus;
} else if (slot == 1) {
return stack.getItem() instanceof ItemSingularity;
}
return false;
} }
@Override @Override
@ -892,6 +874,13 @@ public class TileBore extends TileEntity implements ISidedInventory {
nbt.setShort("orientation", (short) this.orientation); nbt.setShort("orientation", (short) this.orientation);
nbt.setShort("duration", (short) this.duration); nbt.setShort("duration", (short) this.duration);
nbt.setShort("maxDuration", (short) this.maxDuration); 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( return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt 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.orientation = nbt.getShort("orientation");
this.duration = nbt.getShort("duration"); this.duration = nbt.getShort("duration");
this.maxDuration = nbt.getShort("maxDuration"); 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