From dc9cf65660e605ada3da351972a233d21a00a4e2 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 4 Aug 2013 11:18:39 -0400 Subject: [PATCH] Fixed pathfinder NPE and EM Contractor model --- .../contractor/BlockEMContractor.java | 8 ++--- .../contractor/Pathfinder.java | 10 +++++++ .../contractor/TileEntityEMContractor.java | 4 +-- .../model/ModelEMContractor.java | 29 ++++++++++--------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/resonantinduction/contractor/BlockEMContractor.java b/src/resonantinduction/contractor/BlockEMContractor.java index 82fa73df..e7e85694 100644 --- a/src/resonantinduction/contractor/BlockEMContractor.java +++ b/src/resonantinduction/contractor/BlockEMContractor.java @@ -33,7 +33,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider @Override public boolean onBlockActivated(World world, int par2, int par3, int par4, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - TileEntityEMContractor contractor = (TileEntityEMContractor) par1World.getBlockTileEntity(par2, par3, par4); + TileEntityEMContractor contractor = (TileEntityEMContractor) world.getBlockTileEntity(par2, par3, par4); if (entityPlayer.getCurrentEquippedItem() != null) { @@ -41,12 +41,12 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider { ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem()); Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); - + if (linkVec != null) { - if(linkVec.getTileEntity(world) instanceof TileEntityEMContractor) + if (linkVec.getTileEntity(world) instanceof TileEntityEMContractor) { - contractor.setLink((TileEntityEMContractor)linkVec.getTileEntity(world)); + contractor.setLink((TileEntityEMContractor) linkVec.getTileEntity(world)); } } diff --git a/src/resonantinduction/contractor/Pathfinder.java b/src/resonantinduction/contractor/Pathfinder.java index 7093ed58..c1d99f96 100644 --- a/src/resonantinduction/contractor/Pathfinder.java +++ b/src/resonantinduction/contractor/Pathfinder.java @@ -35,6 +35,16 @@ public class Pathfinder public boolean find(Vector3 start) { + /** + * Instantiate Variables + */ + this.openSet = new HashSet(); + this.closedSet = new HashSet(); + this.navMap = new HashMap(); + this.gScore = new HashMap(); + this.fScore = new HashMap(); + this.results = new HashSet(); + this.openSet.add(start); this.gScore.put(start, (double) 0); this.fScore.put(start, this.gScore.get(start) + getEstimate(start, this.target)); diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index a80338ca..353df3a1 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -443,8 +443,8 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec if (this.linked != null) { - this.pathfinder = new Pathfinder(new Vector3(this.linked)); - this.pathfinder.find(new Vector3(this)); + this.pathfinder = new Pathfinder(new Vector3(this)); + this.pathfinder.find(new Vector3(this.linked)); } } } diff --git a/src/resonantinduction/model/ModelEMContractor.java b/src/resonantinduction/model/ModelEMContractor.java index e5bea4a0..c2b7cd33 100644 --- a/src/resonantinduction/model/ModelEMContractor.java +++ b/src/resonantinduction/model/ModelEMContractor.java @@ -5,6 +5,7 @@ import net.minecraft.client.model.ModelRenderer; public class ModelEMContractor extends ModelBase { + // fields ModelRenderer frame1; ModelRenderer frame2; ModelRenderer frame3; @@ -114,8 +115,8 @@ public class ModelEMContractor extends ModelBase right_frame_connector.mirror = true; setRotation(right_frame_connector, 0F, 0F, 0F); teslapole = new ModelRenderer(this, 0, 0); - teslapole.addBox(0F, 0F, 0F, 2, 15, 2); - teslapole.setRotationPoint(-1F, 8F, -1F); + teslapole.addBox(-1F, -1F, -1F, 2, 15, 2); + teslapole.setRotationPoint(0F, 9F, 0F); teslapole.setTextureSize(128, 128); teslapole.mirror = true; setRotation(teslapole, 0F, 0F, 0F); @@ -168,26 +169,26 @@ public class ModelEMContractor extends ModelBase base4.mirror = true; setRotation(base4, 0F, 0F, 0F); pole1 = new ModelRenderer(this, 5, 26); - pole1.addBox(0F, 0F, 0F, 1, 6, 1); - pole1.setRotationPoint(-0.5F, 17F, 6F); + pole1.addBox(-0.5F, -1F, -0.5F, 1, 6, 1); + pole1.setRotationPoint(0F, 18F, 6.5F); pole1.setTextureSize(128, 128); pole1.mirror = true; setRotation(pole1, 0F, 0F, 0F); pole2 = new ModelRenderer(this, 5, 26); - pole2.addBox(0F, 0F, 0F, 1, 6, 1); - pole2.setRotationPoint(-0.5F, 17F, -7F); + pole2.addBox(-0.5F, -1F, -0.5F, 1, 6, 1); + pole2.setRotationPoint(0F, 18F, -6.5F); pole2.setTextureSize(128, 128); pole2.mirror = true; setRotation(pole2, 0F, 0F, 0F); pole3 = new ModelRenderer(this, 5, 26); - pole3.addBox(0F, 0F, 0F, 1, 6, 1); - pole3.setRotationPoint(-7F, 17F, -0.5F); + pole3.addBox(-0.5F, -1F, -0.5F, 1, 6, 1); + pole3.setRotationPoint(-6.5F, 18F, 0F); pole3.setTextureSize(128, 128); pole3.mirror = true; setRotation(pole3, 0F, 0F, 0F); pole4 = new ModelRenderer(this, 5, 26); - pole4.addBox(0F, 0F, 0F, 1, 6, 1); - pole4.setRotationPoint(6F, 17F, -0.5F); + pole4.addBox(-0.5F, -1F, -0.5F, 1, 6, 1); + pole4.setRotationPoint(6.5F, 18F, 0F); pole4.setTextureSize(128, 128); pole4.mirror = true; setRotation(pole4, 0F, 0F, 0F); @@ -227,10 +228,10 @@ public class ModelEMContractor extends ModelBase { if (rotate) { - Coil1.rotateAngleY = (float)Math.toRadians(Math.toDegrees(Coil1.rotateAngleY)+3 < 360 ? Math.toDegrees(Coil1.rotateAngleY)+3 : 0); - coil2.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil2.rotateAngleY)+3 < 360 ? Math.toDegrees(coil2.rotateAngleY)+3 : 0); - coil3.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil3.rotateAngleY)+3 < 360 ? Math.toDegrees(coil3.rotateAngleY)+3 : 0); - coil4.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil4.rotateAngleY)+3 < 360 ? Math.toDegrees(coil4.rotateAngleY)+3 : 0); + Coil1.rotateAngleY = (float) Math.toRadians(Math.toDegrees(Coil1.rotateAngleY) + 3 < 360 ? Math.toDegrees(Coil1.rotateAngleY) + 3 : 0); + coil2.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil2.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil2.rotateAngleY) + 3 : 0); + coil3.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil3.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil3.rotateAngleY) + 3 : 0); + coil4.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil4.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil4.rotateAngleY) + 3 : 0); } frame1.render(f5);