Initial commit of BM 1.8

This commit is contained in:
WayofTime 2015-07-29 08:23:01 -04:00
parent d99eadbea7
commit c5681dc831
713 changed files with 6502 additions and 27334 deletions

View file

@ -14,8 +14,9 @@ import net.minecraft.block.BlockTrapDoor;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.loot.DemonVillageLootRegistry;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.IBlockPortalNode;
@ -276,7 +277,7 @@ public class BlockSet
return GameRegistry.findBlock(modId, name);
}
public int getMetaForDirection(ForgeDirection dir)
public int getMetaForDirection(EnumFacing dir)
{
if (metadata.length < 4)
{
@ -298,7 +299,7 @@ public class BlockSet
}
}
public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, int index, boolean populateInventories, int tier)
public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, int index, boolean populateInventories, int tier)
{
Block block = this.getBlock();
if (index >= positions.size() || block == null)
@ -333,14 +334,15 @@ public class BlockSet
default:
}
world.setBlock(xCoord + xOff, yCoord + yOff, zCoord + zOff, block, meta, 3);
BlockPos newPos = new BlockPos(xCoord + xOff, yCoord + yOff, zCoord + zOff);
world.setBlockState(newPos, block.getStateFromMeta(meta), 3);
if(populateInventories)
{
this.populateIfIInventory(world, xCoord + xOff, yCoord + yOff, zCoord + zOff, tier);
this.populateIfIInventory(world, newPos, tier);
}
if(block instanceof IBlockPortalNode)
{
TileEntity tile = world.getTileEntity(xCoord + xOff, yCoord + yOff, zCoord + zOff);
TileEntity tile = world.getTileEntity(newPos);
if(tile instanceof ITilePortalNode)
{
((ITilePortalNode) tile).setPortalLocation(teDemonPortal);
@ -348,16 +350,16 @@ public class BlockSet
}
}
public void populateIfIInventory(World world, int x, int y, int z, int tier)
public void populateIfIInventory(World world, BlockPos pos, int tier)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IInventory)
{
DemonVillageLootRegistry.populateChest((IInventory)tile, tier);
}
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories, int tier)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories, int tier)
{
for (int i = 0; i < positions.size(); i++)
{

View file

@ -4,8 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -52,7 +54,7 @@ public class BuildingSchematic
blockList.add(set);
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories)
{
for (BlockSet set : blockList)
{
@ -86,7 +88,7 @@ public class BuildingSchematic
return new Int3(gridX, doorY, gridZ);
}
public List<Int3> getGriddedPositions(ForgeDirection dir)
public List<Int3> getGriddedPositions(EnumFacing dir)
{
List<Int3> positionList = new ArrayList();
@ -127,7 +129,7 @@ public class BuildingSchematic
return positionList;
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
// GridSpaceHolder grid = this.createGSH(); //GridSpaceHolder is not aware of the buildings - need to use the schematic
@ -137,10 +139,12 @@ public class BuildingSchematic
{
for (Int3 pos : positionList)
{
Block block = world.getBlock(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
BlockPos newPos = new BlockPos(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block != ModBlocks.blockDemonPortal)
{
world.setBlockToAir(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
world.setBlockToAir(newPos);
}
}
}

View file

@ -1,7 +1,7 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -30,17 +30,17 @@ public class DemonBuilding
return schematic.getName();
}
public boolean isValid(GridSpaceHolder master, int gridX, int gridZ, ForgeDirection dir)
public boolean isValid(GridSpaceHolder master, int gridX, int gridZ, EnumFacing dir)
{
return area.doesContainAll(master, gridX, gridZ, dir);
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories)
{
schematic.buildAll(teDemonPortal, world, xCoord, yCoord, zCoord, dir, populateInventories);
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
public void setAllGridSpaces(int xInit, int zInit, int yLevel, EnumFacing dir, int type, GridSpaceHolder master)
{
area.setAllGridSpaces(xInit, zInit, yLevel, dir, type, master);
}
@ -57,7 +57,7 @@ public class DemonBuilding
return scheme.createGSH();
}
public Int3 getDoorSpace(ForgeDirection dir)
public Int3 getDoorSpace(EnumFacing dir)
{
int x;
int z;
@ -84,7 +84,7 @@ public class DemonBuilding
return new Int3(x, doorGridSpace.yCoord, z);
}
public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel)
public Int3 getGridOffsetFromRoad(EnumFacing sideOfRoad, int yLevel)
{
Int3 doorSpace = this.getDoorSpace(sideOfRoad);
int x = doorSpace.xCoord;
@ -109,7 +109,7 @@ public class DemonBuilding
return new Int3(x, yLevel, z);
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
schematic.destroyAllInField(world, xCoord, yCoord, zCoord, dir);
}

View file

@ -3,9 +3,11 @@ package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.IRoadWard;
@ -16,19 +18,19 @@ public class DemonVillagePath
public int xPos;
public int yPos;
public int zPos;
public ForgeDirection dir;
public EnumFacing dir;
public int length;
public static boolean canGoDown = true;
public static boolean tunnelIfObstructed = false;
public static boolean createBridgeInAirIfObstructed = false;
public DemonVillagePath(int xi, int yi, int zi, ForgeDirection dir, int length)
public DemonVillagePath(int xi, int yi, int zi, EnumFacing dir2, int length)
{
this.xPos = xi;
this.yPos = yi;
this.zPos = zi;
this.dir = dir;
this.dir = dir2;
this.length = length;
}
@ -40,11 +42,11 @@ public class DemonVillagePath
int rad = this.getRoadRadius();
int value = 0;
int finalYPos = this.constructPartialPath(portal, world, clearance, xi - rad * dir.offsetX, yi, zi - rad * dir.offsetZ, dir, length + rad, false);
int finalYPos = this.constructPartialPath(portal, world, clearance, xi - rad * dir.getFrontOffsetX(), yi, zi - rad * dir.getFrontOffsetZ(), dir, length + rad, false);
for (int i = -rad; i <= rad; i++)
{
value = Math.max(this.constructPartialPath(portal, world, clearance, xi - rad * dir.offsetX + i * dir.offsetZ, yi, zi - rad * dir.offsetZ + i * dir.offsetX, dir, length + 2 * rad, true), value);
value = Math.max(this.constructPartialPath(portal, world, clearance, xi - rad * dir.getFrontOffsetX() + i * dir.getFrontOffsetZ(), yi, zi - rad * dir.getFrontOffsetZ() + i * dir.getFrontOffsetX(), dir, length + 2 * rad, true), value);
if(TEDemonPortal.printDebug)
System.out.println("" + (length + 2 * rad) + ", " + value + "");
}
@ -80,12 +82,12 @@ public class DemonVillagePath
* @param doConstruct
* @return length if doConstruct, yi if !doConstruct
*/
public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int xi, int yi, int zi, ForgeDirection dir, int length, boolean doConstruct)
public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int xi, int yi, int zi, EnumFacing dir, int length, boolean doConstruct)
{
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
int xOffset = i * dir.getFrontOffsetX();
int zOffset = i * dir.getFrontOffsetZ();
boolean completed = false;
@ -93,14 +95,19 @@ public class DemonVillagePath
{
int sign = 1;
Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos1 = pos1.offsetUp();
IBlockState state1 = world.getBlockState(pos1);
IBlockState highState1 = world.getBlockState(highPos1);
Block block1 = state1.getBlock();
Block highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
if(doConstruct)
{
world.setBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
yi += sign * yOffset;
completed = true;
@ -108,14 +115,19 @@ public class DemonVillagePath
} else if(canGoDown)
{
sign = -1;
Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
highPos1 = pos1.offsetUp();
state1 = world.getBlockState(pos1);
highState1 = world.getBlockState(highPos1);
block1 = state1.getBlock();
highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block2)) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
if(doConstruct)
if(doConstruct)
{
world.setBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
yi += sign * yOffset;
completed = true;
@ -129,15 +141,17 @@ public class DemonVillagePath
boolean returnAmount = true;
if(createBridgeInAirIfObstructed)
{
Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi, zi + zOffset);
IBlockState state1 = world.getBlockState(pos1);
Block block1 = state1.getBlock();
if (block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || !this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
if (block1.isReplaceable(world, pos1) || !this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
{
returnAmount = false;
if(doConstruct)
{
world.setBlock(xi + xOffset, yi, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
}else
{
@ -146,18 +160,20 @@ public class DemonVillagePath
}else if(tunnelIfObstructed)
{
Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi, zi + zOffset);
IBlockState state1 = world.getBlockState(pos1);
Block block1 = state1.getBlock();
if (!block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
if (!block1.isReplaceable(world, pos1) || this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
{
returnAmount = false;
if(doConstruct)
{
world.setBlock(xi + xOffset, yi, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockToAir(xi + xOffset, yi + 1, zi + zOffset);
world.setBlockToAir(xi + xOffset, yi + 2, zi + zOffset);
world.setBlockToAir(xi + xOffset, yi + 3, zi + zOffset);
world.setBlockState(pos1, portal.getRoadState(), 3);
world.setBlockToAir(pos1.offsetUp(1));
world.setBlockToAir(pos1.offsetUp(2));
world.setBlockToAir(pos1.offsetUp(3));
}
}else
{
@ -183,27 +199,37 @@ public class DemonVillagePath
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
int xOffset = i * dir.getFrontOffsetX();
int zOffset = i * dir.getFrontOffsetZ();
for (int yOffset = 0; yOffset <= clearance; yOffset++)
{
int sign = 1;
Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos1 = pos1.offsetUp();
IBlockState state1 = world.getBlockState(pos1);
IBlockState highState1 = world.getBlockState(highPos1);
Block block1 = state1.getBlock();
Block highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
yi += sign * yOffset;
break;
} else
{
sign = -1;
Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos2 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos2 = pos2.offsetUp();
IBlockState state2 = world.getBlockState(pos2);
IBlockState highState2 = world.getBlockState(highPos2);
Block block2 = state2.getBlock();
Block highBlock2 = highState2.getBlock();
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block2) ) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, pos2) && this.isBlockReplaceable(block2) ) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, highPos2)))
{
yi += sign * yOffset;
break;

View file

@ -1,11 +1,13 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class GridSpaceHolder
{
@ -139,7 +141,7 @@ public class GridSpaceHolder
}
}
public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, ForgeDirection dir)
public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, EnumFacing dir)
{
if (master != null)
{
@ -191,7 +193,7 @@ public class GridSpaceHolder
return false;
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
public void setAllGridSpaces(int xInit, int zInit, int yLevel, EnumFacing dir, int type, GridSpaceHolder master)
{
if(TEDemonPortal.printDebug)
AlchemicalWizardry.logger.info("Grid space selected: (" + xInit + "," + zInit + ")");
@ -239,7 +241,7 @@ public class GridSpaceHolder
}
}
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
for (int i = -negXRadius; i <= posXRadius; i++)
{
@ -278,12 +280,14 @@ public class GridSpaceHolder
{
for (int m = -2; m <= 2; m++)
{
Block block = world.getBlock(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
BlockPos newPos = new BlockPos(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block == ModBlocks.blockDemonPortal)
{
continue;
}
world.setBlockToAir(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
world.setBlockToAir(newPos);
}
}
}

View file

@ -24,7 +24,6 @@ public class EntityAIOccasionalRangedAttack extends EntityAIBase
private int maxRangedAttackTime;
private float field_96562_i;
private float field_82642_h;
private static final String __OBFID = "CL_00001609";
private double range;
public EntityAIOccasionalRangedAttack(IOccasionalRangedAttackMob p_i1649_1_, double p_i1649_2_, int p_i1649_4_, float p_i1649_5_, double range)
@ -110,7 +109,7 @@ public class EntityAIOccasionalRangedAttack extends EntityAIBase
*/
public void updateTask()
{
double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.getBoundingBox().minY, this.attackTarget.posZ);
boolean flag = this.entityHost.getEntitySenses().canSee(this.attackTarget);
if (flag)

View file

@ -3,7 +3,7 @@ package WayofTime.alchemicalWizardry.common.demonVillage.ai;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.tileentity.TileEntity;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -20,14 +20,14 @@ public class EntityDemonAIHurtByTarget extends EntityAIHurtByTarget
@Override
public void startExecuting()
{
Int3 portalPosition = ((IHoardDemon)this.taskOwner).getPortalLocation();
BlockPos portalPosition = ((IHoardDemon)this.taskOwner).getPortalLocation();
if(portalPosition == null)
{
super.startExecuting();
return;
}
TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition.xCoord, portalPosition.yCoord, portalPosition.zCoord);
TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition);
if((this.taskOwner.getAITarget() instanceof IHoardDemon && portalPosition.equals(((IHoardDemon)this.taskOwner.getAITarget()).getPortalLocation())))
{
@ -45,7 +45,7 @@ public class EntityDemonAIHurtByTarget extends EntityAIHurtByTarget
}
// double d0 = this.getTargetDistance();
// List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
// List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
// Iterator iterator = list.iterator();
//
// while (iterator.hasNext())

View file

@ -20,11 +20,11 @@ import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggroCloaking;
@ -34,7 +34,6 @@ import WayofTime.alchemicalWizardry.common.demonVillage.ai.IOccasionalRangedAtta
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRangedAttackMob, IHoardDemon
@ -43,7 +42,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private boolean isAngry = true;
private Int3 demonPortal;
private BlockPos demonPortal;
private static float maxTamedHealth = 200.0F;
private static float maxUntamedHealth = 200.0F;
@ -54,7 +53,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
super(par1World, AlchemicalWizardry.entityMinorDemonGruntID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
// this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
@ -68,7 +67,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
this.setAggro(false);
this.setTamed(false);
demonPortal = new Int3(0,0,0);
demonPortal = new BlockPos(0,0,0);
if (par1World != null && !par1World.isRemote)
{
@ -128,13 +127,13 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
}
@Override
public void setPortalLocation(Int3 position)
public void setPortalLocation(BlockPos position)
{
this.demonPortal = position;
}
@Override
public Int3 getPortalLocation()
public BlockPos getPortalLocation()
{
return this.demonPortal;
}
@ -176,23 +175,25 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
public void writeEntityToNBT(NBTTagCompound tag)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
super.writeEntityToNBT(tag);
tag.setBoolean("Angry", this.isAngry());
this.demonPortal.writeToNBT(par1NBTTagCompound);
tag.setInteger("xCoord", this.demonPortal.getX());
tag.setInteger("yCoord", this.demonPortal.getY());
tag.setInteger("zCoord", this.demonPortal.getZ());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
public void readEntityFromNBT(NBTTagCompound tag)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.demonPortal = Int3.readFromNBT(par1NBTTagCompound);
super.readEntityFromNBT(tag);
this.setAngry(tag.getBoolean("Angry"));
this.demonPortal = new BlockPos(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
this.setCombatTask();
}
@ -252,7 +253,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
if(!this.enthralled)
{
TileEntity tile = this.worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
TileEntity tile = this.worldObj.getTileEntity(this.demonPortal);
if(tile instanceof TEDemonPortal)
{
((TEDemonPortal) tile).enthrallDemon(this);
@ -261,12 +262,12 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
IMasterRitualStone stone = (IMasterRitualStone)tile;
LocalRitualStorage stor = stone.getLocalStorage();
if(stor instanceof LocalStorageAlphaPact)
{
LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
storage.thrallDemon(this);
}
// if(stor instanceof LocalStorageAlphaPact)
// {
// LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
//
// storage.thrallDemon(this);
// }
}
}
super.onUpdate();
@ -325,7 +326,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
this.heal((float) itemfood.getHealAmount(itemstack));
if (itemstack.stackSize <= 0)
{
@ -343,8 +344,8 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
// this.setPathToEntity(null);
// this.setTarget(null);
this.setAttackTarget(null);
}
@ -367,7 +368,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
// this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
@ -500,7 +501,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
}
@Override
public boolean thrallDemon(Int3 location)
public boolean thrallDemon(BlockPos location)
{
this.setPortalLocation(location);
return true;
@ -509,9 +510,9 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
@Override
public boolean isSamePortal(IHoardDemon demon)
{
Int3 position = demon.getPortalLocation();
TileEntity portal = worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
BlockPos position = demon.getPortalLocation();
TileEntity portal = worldObj.getTileEntity(this.demonPortal);
return portal instanceof TEDemonPortal ? portal == worldObj.getTileEntity(position.xCoord, position.yCoord, position.zCoord) : false;
return portal instanceof TEDemonPortal ? portal == worldObj.getTileEntity(position) : false;
}
}

View file

@ -1,11 +1,11 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
public interface IHoardDemon
{
void setPortalLocation(Int3 position);
Int3 getPortalLocation();
boolean thrallDemon(Int3 location);
void setPortalLocation(BlockPos position);
BlockPos getPortalLocation();
boolean thrallDemon(BlockPos location);
boolean isSamePortal(IHoardDemon demon);
}

View file

@ -18,7 +18,7 @@ public class DemonVillageLootRegistry
String[] tier1Strings = new String[]{ChestGenHooks.DUNGEON_CHEST, ChestGenHooks.PYRAMID_DESERT_CHEST};
for(String str : tier1Strings)
{
WeightedRandomChestContent[] contents = ChestGenHooks.getItems(str, new Random());
List<WeightedRandomChestContent> contents = ChestGenHooks.getItems(str, new Random());
if(contents != null)
{
for(WeightedRandomChestContent content : contents)
@ -34,16 +34,6 @@ public class DemonVillageLootRegistry
public static void populateChest(IInventory tile, int tier)
{
WeightedRandomChestContent.generateChestContents(new Random(), toArray(list1), tile, tile.getSizeInventory() / 3);
}
public static WeightedRandomChestContent[] toArray(List<WeightedRandomChestContent> aList)
{
int size = aList.size();
WeightedRandomChestContent[] contents = new WeightedRandomChestContent[size];
contents = aList.toArray(contents);
return contents;
WeightedRandomChestContent.generateChestContents(new Random(), list1, tile, tile.getSizeInventory() / 3);
}
}

View file

@ -1,9 +1,9 @@
package WayofTime.alchemicalWizardry.common.demonVillage.tileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
@ -12,15 +12,10 @@ public class BlockDemonChest extends BlockChest implements IBlockPortalNode
public BlockDemonChest()
{
super(0);
this.setHardness(2.5F).setStepSound(soundTypeWood).setBlockName("demonChest");
this.setHardness(2.5F).setStepSound(soundTypeWood).setUnlocalizedName("demonChest");
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
public IInventory func_149951_m(World world, int x, int y, int z)
{
return (IInventory)world.getTileEntity(x, y, z);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
@ -28,18 +23,18 @@ public class BlockDemonChest extends BlockChest implements IBlockPortalNode
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TEDemonChest)
{
((TEDemonChest) tile).notifyPortalOfInteraction();
}
super.breakBlock(world, x, y, z, block, meta);
super.breakBlock(world, pos, state);
}
@Override
public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
return true;
}

View file

@ -1,16 +1,17 @@
package WayofTime.alchemicalWizardry.common.demonVillage.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
public Int3 portalLocation = new Int3(0,0,0);
public BlockPos portalLocation = BlockPos.ORIGIN;
@Override
public String getInventoryName()
public String getName()
{
return "Demon's Chest";
}
@ -20,21 +21,24 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
super.readFromNBT(tag);
NBTTagCompound portalTag = tag.getCompoundTag("portalLocation");
portalLocation = Int3.readFromNBT(portalTag);
portalLocation = new BlockPos(portalTag.getInteger("xCoord"), portalTag.getInteger("yCoord"), portalTag.getInteger("zCoord"));
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagCompound portalTag = portalLocation.writeToNBT(new NBTTagCompound());
NBTTagCompound portalTag = new NBTTagCompound();
portalTag.setInteger("xCoord", portalLocation.getX());
portalTag.setInteger("yCoord", portalLocation.getY());
portalTag.setInteger("zCoord", portalLocation.getZ());
tag.setTag("portalLocation", portalTag);
}
@Override
public void openInventory()
public void openInventory(EntityPlayer player)
{
super.openInventory();
super.openInventory(player);
this.notifyPortalOfInteraction();
}
@ -49,13 +53,13 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
if(teDemonPortal != null)
{
portalLocation = new Int3(teDemonPortal.xCoord, teDemonPortal.yCoord, teDemonPortal.zCoord);
portalLocation = teDemonPortal.getPos();
}
}
public TEDemonPortal getDemonPortal()
{
TileEntity tile = worldObj.getTileEntity(portalLocation.xCoord, portalLocation.yCoord, portalLocation.zCoord);
TileEntity tile = worldObj.getTileEntity(portalLocation);
if(tile instanceof TEDemonPortal)
{
return (TEDemonPortal)tile;
@ -71,6 +75,6 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
return;
}
portal.notifyDemons(xCoord, yCoord, zCoord, 50);
portal.notifyDemons(pos.getX(), pos.getY(), pos.getZ(), 50);
}
}

View file

@ -15,6 +15,7 @@ import java.util.Random;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
@ -22,9 +23,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.block.BlockTeleposer;
@ -42,7 +45,7 @@ import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardD
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class TEDemonPortal extends TileEntity
public class TEDemonPortal extends TileEntity implements IUpdatePlayerListBox
{
public DemonType type = DemonType.FIRE;
@ -85,7 +88,7 @@ public class TEDemonPortal extends TileEntity
public float pointPool;
public String nextDemonPortalName = "";
public ForgeDirection nextDemonPortalDirection = ForgeDirection.DOWN;
public EnumFacing nextDemonPortalDirection = EnumFacing.DOWN;
public int buildingStage = -1;
@ -116,7 +119,7 @@ public class TEDemonPortal extends TileEntity
isInitialized = false;
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, yCoord));
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, pos.getY()));
this.houseCooldown = 0;
this.roadCooldown = 0;
@ -282,7 +285,7 @@ public class TEDemonPortal extends TileEntity
{
if(demon instanceof IHoardDemon)
{
boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord));
boolean enthrall = ((IHoardDemon) demon).thrallDemon(pos);
if(enthrall)
{
this.hoardList.add((IHoardDemon)demon);
@ -306,10 +309,10 @@ public class TEDemonPortal extends TileEntity
{
if (Math.abs(xIndex) == 1 || Math.abs(zIndex) == 1)
{
this.setGridSpace(xIndex, zIndex, new GridSpace(GridSpace.ROAD, yCoord));
this.setGridSpace(xIndex, zIndex, new GridSpace(GridSpace.ROAD, pos.getY()));
} else if (xIndex == 0 && zIndex == 0)
{
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, yCoord));
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, pos.getY()));
} else
{
this.setGridSpace(xIndex, zIndex, new GridSpace());
@ -334,7 +337,7 @@ public class TEDemonPortal extends TileEntity
public void createParty()
{
worldObj.createExplosion(null, xCoord + rand.nextInt(10) - rand.nextInt(10), yCoord, zCoord + rand.nextInt(10) - rand.nextInt(10), 5*rand.nextFloat(), false);
worldObj.createExplosion(null, pos.getX() + rand.nextInt(10) - rand.nextInt(10), pos.getY(), pos.getZ() + rand.nextInt(10) - rand.nextInt(10), 5*rand.nextFloat(), false);
}
public void start()
@ -346,7 +349,7 @@ public class TEDemonPortal extends TileEntity
* Randomly increase one of the cooldowns such that a road, house, or a demon portal tier is caused. Demons are also randomly spawned via this mechanic.
*/
@Override
public void updateEntity()
public void update()
{
if(worldObj.isRemote)
{
@ -364,7 +367,7 @@ public class TEDemonPortal extends TileEntity
if(delayBeforeParty <= 0)
{
worldObj.createExplosion(null, xCoord, yCoord, zCoord, 15, false);
worldObj.createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), 15, false);
this.initialize();
}
@ -493,7 +496,7 @@ public class TEDemonPortal extends TileEntity
this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName");
this.buildingStage = par1NBTTagCompound.getInteger("buildingStage");
this.nextDemonPortalDirection = ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.nextDemonPortalDirection = EnumFacing.getFront(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.pointPool = par1NBTTagCompound.getFloat("pointPool");
this.lockdownTimer = par1NBTTagCompound.getInteger("lockdownTimer");
@ -553,24 +556,24 @@ public class TEDemonPortal extends TileEntity
public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonType type, boolean spawnGuardian)
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
@ -582,30 +585,30 @@ public class TEDemonPortal extends TileEntity
if(TEDemonPortal.printDebug)
System.out.println("Spawning Demons");
return DemonPacketRegistry.spawnDemons(teDemonPortal, worldObj, xCoord + road.xCoord * 5, road.yCoord + 1, zCoord + road.zCoord * 5, type, tier, spawnGuardian);
return DemonPacketRegistry.spawnDemons(teDemonPortal, worldObj, pos.getX() + road.xCoord * 5, road.yCoord + 1, pos.getZ() + road.zCoord * 5, type, tier, spawnGuardian);
}
public int createRandomRoad() //Return the number of road spaces
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
@ -617,7 +620,7 @@ public class TEDemonPortal extends TileEntity
if(printDebug)
AlchemicalWizardry.logger.info("X: " + x + " Z: " + z + " Direction: " + dir.toString());
List<ForgeDirection> directions = this.findValidExtentionDirection(x, z);
List<EnumFacing> directions = this.findValidExtentionDirection(x, z);
if (directions.size() <= 0)
{
@ -627,9 +630,9 @@ public class TEDemonPortal extends TileEntity
int maxDistance = 5;
int distance = 0;
ForgeDirection dominantDirection = null;
EnumFacing dominantDirection = null;
for (ForgeDirection direction : directions)
for (EnumFacing direction : directions)
{
int amt = this.getLength(direction, maxDistance, x, z);
if (amt > distance)
@ -656,9 +659,9 @@ public class TEDemonPortal extends TileEntity
return distance;
}
public List<ForgeDirection> findValidExtentionDirection(int x, int z)
public List<EnumFacing> findValidExtentionDirection(int x, int z)
{
List<ForgeDirection> directions = new LinkedList();
List<EnumFacing> directions = new LinkedList();
if (this.getGridSpace(x, z) == null || !this.getGridSpace(x, z).isRoadSegment())
{
@ -668,41 +671,41 @@ public class TEDemonPortal extends TileEntity
GridSpace nextGrid = this.getGridSpace(x + 1, z);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.EAST);
directions.add(EnumFacing.EAST);
}
nextGrid = this.getGridSpace(x - 1, z);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.WEST);
directions.add(EnumFacing.WEST);
}
nextGrid = this.getGridSpace(x, z + 1);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.SOUTH);
directions.add(EnumFacing.SOUTH);
}
nextGrid = this.getGridSpace(x, z - 1);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.NORTH);
directions.add(EnumFacing.NORTH);
}
return directions;
}
public int getLength(ForgeDirection dir, int maxLength, int x, int z) //Number of spaces forward
public int getLength(EnumFacing dir, int maxLength, int x, int z) //Number of spaces forward
{
for (int i = 1; i <= maxLength; i++)
{
GridSpace space = this.getGridSpace(x + i * dir.offsetX, z + i * dir.offsetZ);
GridSpace space = this.getGridSpace(x + i * dir.getFrontOffsetX(), z + i * dir.getFrontOffsetZ());
if (space.isEmpty())
{
for (int k = 1; k <= this.getRoadSpacer(); k++)
{
GridSpace space1 = this.getGridSpace(x + i * dir.offsetX + dir.offsetZ * k, z + i * dir.offsetZ + dir.offsetX * k);
GridSpace space2 = this.getGridSpace(x + i * dir.offsetX - dir.offsetZ * k, z + i * dir.offsetZ - dir.offsetX * k);
GridSpace space1 = this.getGridSpace(x + i * dir.getFrontOffsetX() + dir.getFrontOffsetZ() * k, z + i * dir.getFrontOffsetZ() + dir.getFrontOffsetX() * k);
GridSpace space2 = this.getGridSpace(x + i * dir.getFrontOffsetX() - dir.getFrontOffsetZ() * k, z + i * dir.getFrontOffsetZ() - dir.getFrontOffsetX() * k);
if (space1.isRoadSegment() || space2.isRoadSegment())
{
@ -723,10 +726,10 @@ public class TEDemonPortal extends TileEntity
return maxLength;
}
public Int3 findRoadSpaceFromDirection(ForgeDirection dir, int amount) //TODO
public Int3 findRoadSpaceFromDirection(EnumFacing dir, int amount) //TODO
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -745,7 +748,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + Math.min(posZRadius, limit); i >= Math.max(0, -limit + negZRadius); i--)
{
@ -762,7 +765,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + Math.min(posXRadius, limit); i >= Math.max(0, -limit + negXRadius); i--)
{
@ -779,7 +782,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = Math.max(0, -limit + negXRadius); i <= negXRadius + Math.min(posXRadius, limit); i++)
{
@ -801,10 +804,10 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public Int3 findEmptySpaceNearRoad(ForgeDirection dir, int amount, int closeness)
public Int3 findEmptySpaceNearRoad(EnumFacing dir, int amount, int closeness)
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -828,7 +831,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + posZRadius; i >= 0; i--)
{
@ -850,7 +853,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + posXRadius; i >= 0; i--)
{
@ -872,7 +875,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
@ -899,10 +902,10 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public Int3 findEmptySpaceFromDirection(ForgeDirection dir, int amount)
public Int3 findEmptySpaceFromDirection(EnumFacing dir, int amount)
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -921,7 +924,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + posZRadius; i >= 0; i--)
{
@ -938,7 +941,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + posXRadius; i >= 0; i--)
{
@ -955,7 +958,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
@ -977,7 +980,7 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public int createGriddedRoad(int gridXi, int yi, int gridZi, ForgeDirection dir, int gridLength, boolean convertStarter) //Total grid length
public int createGriddedRoad(int gridXi, int yi, int gridZi, EnumFacing dir, int gridLength, boolean convertStarter) //Total grid length
{
if (gridLength == 0 || gridLength == 1)
{
@ -992,13 +995,13 @@ public class TEDemonPortal extends TileEntity
{
this.setGridSpace(initGridX, initGridZ, new GridSpace(GridSpace.CROSSROAD, initY));
DemonCrosspath crosspath = new DemonCrosspath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5);
DemonCrosspath crosspath = new DemonCrosspath(pos.getX() + initGridX * 5, initY, pos.getZ() + initGridZ * 5);
crosspath.createCrosspath(worldObj);
}
for (int index = 0; index < gridLength - 1; index++)
{
DemonVillagePath path = new DemonVillagePath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5, dir, 6);
DemonVillagePath path = new DemonVillagePath(pos.getX() + initGridX * 5, initY, pos.getZ() + initGridZ * 5, dir, 6);
Int3AndBool temp = path.constructFullPath(this, worldObj, this.getRoadStepClearance());
Int3 next = temp.coords;
@ -1015,8 +1018,8 @@ public class TEDemonPortal extends TileEntity
return index;
}
initGridX += dir.offsetX;
initGridZ += dir.offsetZ;
initGridX += dir.getFrontOffsetX();
initGridZ += dir.getFrontOffsetZ();
if (!this.getGridSpace(initGridX, initGridZ).isRoadSegment())
{
@ -1157,10 +1160,10 @@ public class TEDemonPortal extends TileEntity
//
// this.initialize();
//
// if (ForgeDirection.getOrientation(side) == ForgeDirection.UP)
// if (EnumFacing.getOrientation(side) == EnumFacing.UP)
// {
// this.createRandomBuilding(DemonBuilding.BUILDING_HOUSE, 0);
// } else if (ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
// } else if (EnumFacing.getOrientation(side) == EnumFacing.DOWN)
// {
// this.createRandomBuilding(DemonBuilding.BUILDING_PORTAL, 0);
// } else
@ -1194,11 +1197,11 @@ public class TEDemonPortal extends TileEntity
// GridSpaceHolder grid = this.createGSH();
List<ForgeDirection> directions = new ArrayList();
List<EnumFacing> directions = new ArrayList();
for (int i = 2; i < 6; i++)
{
ForgeDirection testDir = ForgeDirection.getOrientation(i);
EnumFacing testDir = EnumFacing.getFront(i);
directions.add(testDir);
}
@ -1207,9 +1210,9 @@ public class TEDemonPortal extends TileEntity
return 0;
}
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
HashMap<EnumFacing, List<DemonBuilding>> schemMap = new HashMap();
for (ForgeDirection nextDir : directions)
for (EnumFacing nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList)
{
@ -1234,7 +1237,7 @@ public class TEDemonPortal extends TileEntity
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
EnumFacing chosenDirection = (EnumFacing) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
// Int3 portalSpace = build.getDoorSpace(chosenDirection);
@ -1276,7 +1279,7 @@ public class TEDemonPortal extends TileEntity
GridSpaceHolder grid = this.createGSH();
ForgeDirection chosenDirection = this.nextDemonPortalDirection;
EnumFacing chosenDirection = this.nextDemonPortalDirection;
Int3 portalSpace = build.getDoorSpace(chosenDirection);
int yOffset = portalSpace.yCoord;
@ -1288,9 +1291,9 @@ public class TEDemonPortal extends TileEntity
case 1:
int yDestination = yLevel + yOffset;
if(yCoord != yDestination)
if(pos.getY() != yDestination)
{
BlockTeleposer.swapBlocks(this, worldObj, worldObj, xCoord, yCoord, zCoord, xCoord, yDestination, zCoord);
BlockTeleposer.swapBlocks(this, worldObj, worldObj, pos, new BlockPos(pos.getX(), yDestination, pos.getZ()));
}else
{
//Nuthin - just as a reminder that we can now increment properly
@ -1298,9 +1301,9 @@ public class TEDemonPortal extends TileEntity
break;
case 2:
build.destroyAllInField(worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite());
build.destroyAllInField(worldObj, pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite(), true);
build.buildAll(this, worldObj, pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection.getOpposite(), true);
build.setAllGridSpaces(x, z, yLevel, chosenDirection.getOpposite(), GridSpace.MAIN_PORTAL, grid);
this.loadGSH(grid);
break;
@ -1314,24 +1317,24 @@ public class TEDemonPortal extends TileEntity
public int createRandomHouse(int buildingTier)
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 space = this.findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1); // Second: 1 *
@ -1350,12 +1353,12 @@ public class TEDemonPortal extends TileEntity
return 0;
}
List<ForgeDirection> directions = new ArrayList();
List<EnumFacing> directions = new ArrayList();
for (int i = 2; i < 6; i++)
{
ForgeDirection testDir = ForgeDirection.getOrientation(i);
if (this.getGridSpace(x + testDir.offsetX, z + testDir.offsetZ).isEmpty())
EnumFacing testDir = EnumFacing.getFront(i);
if (this.getGridSpace(x + testDir.getFrontOffsetX(), z + testDir.getFrontOffsetZ()).isEmpty())
{
directions.add(testDir);
}
@ -1366,9 +1369,9 @@ public class TEDemonPortal extends TileEntity
return 0;
}
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
HashMap<EnumFacing, List<DemonBuilding>> schemMap = new HashMap();
for (ForgeDirection nextDir : directions)
for (EnumFacing nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList)
{
@ -1403,19 +1406,19 @@ public class TEDemonPortal extends TileEntity
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
EnumFacing chosenDirection = (EnumFacing) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
Int3 offsetSpace = build.getGridOffsetFromRoad(chosenDirection, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
build.destroyAllInField(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite(), true);
build.destroyAllInField(worldObj, pos.getX() + (x + xOff) * 5, yLevel, pos.getZ() + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, pos.getX() + (x + xOff) * 5, yLevel, pos.getZ() + (z + zOff) * 5, chosenDirection.getOpposite(), true);
build.setAllGridSpaces(x + xOff, z + zOff, yLevel, chosenDirection.getOpposite(), GridSpace.HOUSE, grid);
this.loadGSH(grid);
DemonVillagePath path = new DemonVillagePath(xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection, 2);
DemonVillagePath path = new DemonVillagePath(pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection, 2);
Int3AndBool temp = path.constructFullPath(this, worldObj, this.getRoadStepClearance());
@ -1446,14 +1449,14 @@ public class TEDemonPortal extends TileEntity
return -1;
}
public void createRoad(int xi, int yi, int zi, ForgeDirection dir, int length, boolean doesNotDrop)
public void createRoad(int xi, int yi, int zi, EnumFacing dir, int length, boolean doesNotDrop)
{
int curX = xi;
int curY = yi;
int curZ = zi;
int roadRadius = this.getRoadRadius();
if (dir.offsetY != 0)
if (dir.getFrontOffsetY() != 0)
{
return;
}
@ -1495,6 +1498,11 @@ public class TEDemonPortal extends TileEntity
}
return 0;
}
public IBlockState getRoadState()
{
return getRoadBlock().getStateFromMeta(getRoadMeta());
}
public int getRoadStepClearance()
{