Skip to content

Commit

Permalink
push in fixes from 1.6, format repo
Browse files Browse the repository at this point in the history
  • Loading branch information
progwml6 committed Apr 15, 2014
1 parent a83a245 commit d878cd1
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main/java/tmechworks/blocks/RedstoneMachine.java
Expand Up @@ -322,7 +322,7 @@ public void onNeighborBlockChange (World world, int x, int y, int z, Block neigh

public int getIndirectPowerLevelTo (World world, int x, int y, int z, int side)
{
// implementation of isBlockNormalCube which is client only for some reason these are both sides
// implementation of isBlockNormalCube which is client only for some reason these are both sides
if (world.getBlock(x, y, z).getMaterial().blocksMovement() && this.renderAsNormalBlock())
{
return world.getBlockPowerInput(x, y, z);
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/tmechworks/blocks/logic/AdvancedDrawbridgeLogic.java
Expand Up @@ -28,7 +28,6 @@
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import tmechworks.inventory.AdvancedDrawbridgeContainer;
import tmechworks.lib.TMechworksRegistry;
Expand Down Expand Up @@ -61,10 +60,24 @@ public AdvancedDrawbridgeLogic()
public void setWorldObj (World par1World)
{
this.worldObj = par1World;
if (!par1World.isRemote)
fakePlayer = new FakePlayerLogic((WorldServer) worldObj, new GameProfile(null, "Player.Drawbridge"), (InventoryLogic) this);
}

// Super awesome hack of post initialization hashmap-adding nonsense!
// Completely necessary due to the way players load chunks, including fake ones.
private void initFakePlayer ()
{
if (fakePlayer == null && !isInvalid())
fakePlayer = new FakePlayerLogic(new GameProfile(null, "Player.Drawbridge"), this);
}

//This gets called too early. Adding the fake player here creates multiple copies of the TileEntity and causes havoc!
/*@Override
public void validate ()
{
this.tileEntityInvalid = false;
fakePlayer = new FakePlayerLogic("Player.Drawbridge", this);
}*/

@Override
public boolean getActive ()
{
Expand Down Expand Up @@ -142,6 +155,7 @@ public void setPlacementDirection (byte keycode)
{
if (!worldObj.isRemote)
{
initFakePlayer();
if (keycode == 4)
{
fakePlayer.rotationYaw = 0;
Expand Down Expand Up @@ -282,7 +296,7 @@ public ItemStack decrStackSize (int slot, int quantity)

public void updateEntity ()
{
if (working)
if (working && !isInvalid())
{
ticks++;
if (ticks == 5)
Expand Down Expand Up @@ -323,6 +337,7 @@ public void updateEntity ()
if (block == null || block.isAir(worldObj, xPos, yPos, zPos) || block.canPlaceBlockAt(worldObj, xPos, yPos, zPos))
{
// tryExtend(worldObj, xPos, yPos, zPos, direction);
initFakePlayer();
Item blockToItem = getStackInBufferSlot(extension - 1) != null && getStackInBufferSlot(extension - 1).getItem() != null ? TMechworksRegistry.blockToItemMapping.get(Block
.getBlockFromItem(getStackInBufferSlot(extension - 1).getItem())) : Items.stick;
if (blockToItem == Item.getItemFromBlock(Blocks.air))
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/tmechworks/blocks/logic/DrawbridgeLogic.java
Expand Up @@ -53,13 +53,28 @@ public DrawbridgeLogic()
}

@Override
public void setWorldObj (World par1World)
public void invalidate ()
{
this.worldObj = par1World;
if (!worldObj.isRemote)
fakePlayer = new FakePlayerLogic((WorldServer) worldObj, new GameProfile(null, "Player.Drawbridge"), this);
this.tileEntityInvalid = true;
fakePlayer = null;
}

// Super awesome hack of post initialization hashmap-adding nonsense!
// Completely necessary due to the way players load chunks, including fake ones.
private void initFakePlayer ()
{
if (fakePlayer == null && !isInvalid())
fakePlayer = new FakePlayerLogic(new GameProfile(null, "Player.Drawbridge"), this);
}

//This gets called too early. Adding the fake player here creates multiple copies of the TileEntity and causes havoc!
/*@Override
public void validate ()
{
this.tileEntityInvalid = false;
fakePlayer = new FakePlayerLogic(new GameProfile(null, "Player.Drawbridge"), this);
}*/

@Override
public boolean getActive ()
{
Expand Down Expand Up @@ -145,6 +160,7 @@ public void setPlacementDirection (byte keycode)
{
if (!worldObj.isRemote)
{
initFakePlayer();
if (keycode == 4)
{
fakePlayer.rotationYaw = 0;
Expand Down Expand Up @@ -266,7 +282,7 @@ public ItemStack decrStackSize (int slot, int quantity)

public void updateEntity ()
{
if (working)
if (working && !isInvalid())
{
ticks++;
if (ticks == 5)
Expand Down Expand Up @@ -310,6 +326,7 @@ public void updateEntity ()
if (block == null || block.isAir(worldObj, xPos, yPos, zPos) || block.canPlaceBlockAt(worldObj, xPos, yPos, zPos))
{
//tryExtend(worldObj, xPos, yPos, zPos, direction);
initFakePlayer();
Item blockToItem = TMechworksRegistry.blockToItemMapping.get(Item.getIdFromItem(bufferStack.getItem()));
if (blockToItem == Item.getItemFromBlock(Blocks.air))
{
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/tmechworks/common/MechRecipes.java
Expand Up @@ -29,9 +29,8 @@ public static void registerAllTheThings ()
MechContent.proxyItem_blankPattern, 1, 1), 'r', new ItemStack(Items.redstone), 'd', new ItemStack(MechContent.redstoneMachine, 1, 0)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(MechContent.redstoneMachine, 1, 2), " c ", "rdr", " a ", 'a', "ingotAluminumBrass", 'c', new ItemStack(
MechContent.proxyItem_blankPattern, 1, 2), 'r', new ItemStack(Items.redstone), 'd', new ItemStack(MechContent.redstoneMachine, 1, 0)));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(MechContent.redstoneMachine, 1, 3), "blockCobalt", "blockArdite", new ItemStack(Blocks.redstone_block), new ItemStack(
MechContent.redstoneMachine, 1, 0)));

GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(MechContent.redstoneMachine, 1, 3), "ingotCobalt", "ingotCobalt", "ingotCobalt", "ingotArdite", "ingotArdite", "ingotArdite",
new ItemStack(Blocks.redstone_block), new ItemStack(MechContent.redstoneMachine, 1, 0)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(MechContent.signalBus, 1, 0), "www", "sss", 'w', MechContent.lengthWire, 's', new ItemStack(Blocks.stone_slab, 1,
OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(MechContent.signalTerminal, 1, 0), "b", "g", "b", 'b', new ItemStack(MechContent.signalBus, 1, 0), 'g', new ItemStack(Blocks.glass, 1,
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/tmechworks/lib/player/FakePlayerLogic.java
@@ -1,6 +1,6 @@
package tmechworks.lib.player;

import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
Expand All @@ -9,16 +9,18 @@

public class FakePlayerLogic extends FakePlayer
{
InventoryLogic logic;
ChunkCoordinates logicPos;

public FakePlayerLogic(WorldServer world, GameProfile gm, InventoryLogic logic)
public FakePlayerLogic(GameProfile gm, TileEntity te)
{
super(world, gm);
this.logic = logic;
super((WorldServer) te.getWorldObj(), gm);
logicPos = new ChunkCoordinates(te.xCoord, te.yCoord, te.zCoord);

}

public ChunkCoordinates getPlayerCoordinates ()
{
return new ChunkCoordinates(logic.xCoord, logic.yCoord, logic.zCoord);
return logicPos;
}

}

0 comments on commit d878cd1

Please sign in to comment.