Fix Sigil of the Phantom Bridge

I'm tentatively considering this fixed. I'd rather not do it this way, but it seems to work...
This commit is contained in:
Nick 2016-01-11 13:36:07 -08:00
parent 0d70eb359e
commit 9950b32d53
3 changed files with 39 additions and 29 deletions
src/main/java/WayofTime/bloodmagic

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TilePhantomBlock;
import net.minecraft.block.Block;
@ -24,6 +25,7 @@ public class BlockPhantom extends BlockContainer
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".phantom");
setCreativeTab(BloodMagic.tabBloodMagic);
}
@Override
@ -45,6 +47,12 @@ public class BlockPhantom extends BlockContainer
return true;
}
@Override
public int getRenderType()
{
return 3;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer()
@ -76,6 +84,6 @@ public class BlockPhantom extends BlockContainer
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TilePhantomBlock();
return new TilePhantomBlock(100);
}
}

View file

@ -1,11 +1,8 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.tile.TilePhantomBlock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -28,9 +25,6 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleable
if (player.isSneaking())
verticalOffset--;
if (world.isRemote)
verticalOffset--;
int posX = (int) Math.round(player.posX - 0.5f);
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
@ -40,25 +34,9 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleable
for (int iz = posZ - range; iz <= posZ + range; iz++)
{
BlockPos blockPos = new BlockPos(ix, posY + verticalOffset, iz);
Block block = world.getBlockState(blockPos).getBlock();
if (world.isAirBlock(blockPos))
{
world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState(), 3);
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TilePhantomBlock)
{
((TilePhantomBlock) tile).setDuration(100);
}
} else if (block == ModBlocks.phantomBlock)
{
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TilePhantomBlock)
{
((TilePhantomBlock) tile).setDuration(100);
}
}
world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState());
}
}
}

View file

@ -1,23 +1,30 @@
package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
public class TilePhantomBlock extends TileEntity implements ITickable
{
private int ticksRemaining;
public TilePhantomBlock()
public TilePhantomBlock(int ticksRemaining)
{
this.ticksRemaining = ticksRemaining;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
this.ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
}
@Override
@ -34,12 +41,29 @@ public class TilePhantomBlock extends TileEntity implements ITickable
if (ticksRemaining <= 0)
{
worldObj.setBlockToAir(pos);
worldObj.removeTileEntity(getPos());
worldObj.setBlockToAir(getPos());
}
}
public void setDuration(int duration)
@Override
public Packet getDescriptionPacket()
{
ticksRemaining = duration;
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
{
super.onDataPacket(net, pkt);
readFromNBT(pkt.getNbtCompound());
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
{
return oldState.getBlock() != newState.getBlock();
}
}