Skip to content

Commit

Permalink
Fixup faucets
Browse files Browse the repository at this point in the history
  • Loading branch information
LepkoQQ committed Apr 6, 2014
1 parent a1b8d62 commit 15a9af6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
47 changes: 34 additions & 13 deletions src/main/java/tconstruct/blocks/SearedBlock.java
Expand Up @@ -2,16 +2,6 @@

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.CastingBasinLogic;
import tconstruct.blocks.logic.CastingTableLogic;
import tconstruct.blocks.logic.FaucetLogic;
import tconstruct.client.block.SearedRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.SmelteryEvent;
import tconstruct.library.tools.AbilityHelper;
import mantle.blocks.abstracts.InventoryBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
Expand All @@ -25,6 +15,18 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.CastingBasinLogic;
import tconstruct.blocks.logic.CastingTableLogic;
import tconstruct.blocks.logic.FaucetLogic;
import tconstruct.client.block.SearedRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.SmelteryEvent;
import tconstruct.library.tools.AbilityHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class SearedBlock extends InventoryBlock
{
Expand Down Expand Up @@ -361,16 +363,35 @@ public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int
return world.getBlockMetadata(x, y, z) == 1;
}

private boolean wasPowered = false;

@Override
public void onNeighborBlockChange (World world, int x, int y, int z, Block neighborBlockID)
{
if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 1)
if (world.getBlockMetadata(x, y, z) == 1)
{
FaucetLogic logic = (FaucetLogic) world.getTileEntity(x, y, z);
logic.setActive(true);
boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z);
if (!wasPowered && isPowered)
{
FaucetLogic logic = (FaucetLogic) world.getTileEntity(x, y, z);
logic.setActive(true);
}
wasPowered = isPowered;
}
}

@Override
public boolean canPlaceBlockOnSide (World world, int x, int y, int z, int side)
{
ForgeDirection dir = ForgeDirection.getOrientation(side ^ 1);
TileEntity tile = world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (tile instanceof IFluidHandler)
{
return true;
}
return false;
}

@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tconstruct/blocks/logic/FaucetLogic.java
Expand Up @@ -103,13 +103,13 @@ public ForgeDirection getForgeDirection ()
@Override
public void setDirection (int side)
{
//direction = (byte) side;
direction = (byte) side;
}

@Override
public void setDirection (float yaw, float pitch, EntityLivingBase player)
{
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
/*int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
switch (facing)
{
case 0:
Expand All @@ -127,7 +127,7 @@ public void setDirection (float yaw, float pitch, EntityLivingBase player)
case 3:
direction = 4;
break;
}
}*/
}

@Override
Expand Down Expand Up @@ -244,4 +244,4 @@ public FluidTankInfo[] getTankInfo (ForgeDirection from)
// TODO Auto-generated method stub
return null;
}
}
}

0 comments on commit 15a9af6

Please sign in to comment.