What a dummy (block)!
This commit is contained in:
parent
42534f3509
commit
674aac188d
|
@ -84,7 +84,7 @@ public class EquivalentExchange3
|
|||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
// Initialize mod tile entities
|
||||
proxy.registerTileEntities();
|
||||
TileEntities.init();
|
||||
|
||||
// Initialize custom rendering and pre-load textures (Client only)
|
||||
proxy.initRenderingAndTextures();
|
||||
|
|
|
@ -2,23 +2,31 @@ package com.pahimar.ee3.block;
|
|||
|
||||
import com.pahimar.ee3.api.Glyph;
|
||||
import com.pahimar.ee3.array.GlyphTextureRegistry;
|
||||
import com.pahimar.ee3.init.ModBlocks;
|
||||
import com.pahimar.ee3.item.ItemChalk;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.RenderIds;
|
||||
import com.pahimar.ee3.settings.ChalkSettings;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
|
||||
import com.pahimar.ee3.tileentity.TileEntityDummy;
|
||||
import com.pahimar.ee3.tileentity.TileEntityEE;
|
||||
import com.pahimar.ee3.util.CommonSoundHelper;
|
||||
import com.pahimar.ee3.util.EntityHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
||||
{
|
||||
|
@ -47,6 +55,12 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
return RenderIds.alchemyArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random random, int par2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*
|
||||
|
@ -59,17 +73,65 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
return new TileEntityAlchemyArray();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean canPlaceBlockAt(World world, int x, int y, int z)
|
||||
// {
|
||||
// return super.canPlaceBlockAt(world, x, y, z);
|
||||
// }
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z)
|
||||
{
|
||||
// TODO: Check whether or not we can place the glyph here (given the size of the glyph)
|
||||
return super.canPlaceBlockAt(world, x, y, z);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
|
||||
{
|
||||
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
|
||||
{
|
||||
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
|
||||
boolean invalidateAlchemyArray = false;
|
||||
|
||||
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
|
||||
if (invalidateAlchemyArray)
|
||||
{
|
||||
tileEntityAlchemyArray.invalidate();
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
|
||||
|
@ -97,6 +159,8 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(new Glyph(glyphTexture, GlyphTextureRegistry.getInstance().getGlyphs().get(glyphTexture)), chalkSettings.getSize());
|
||||
|
||||
CommonSoundHelper.playChalkSoundAt((EntityPlayer) entityLiving);
|
||||
|
||||
placeDummyBlocksAround(world, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +190,59 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
private void placeDummyBlocksAround(World world, int x, int y, int z, int metaData)
|
||||
{
|
||||
// TODO: Save orientation correctly
|
||||
ForgeDirection orientation = ForgeDirection.getOrientation(metaData);
|
||||
int coordOffset = ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).getAlchemyArray().getLargestGlyphSize() / 2;
|
||||
|
||||
if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN)
|
||||
{
|
||||
for (int i = x - coordOffset; i <= x + coordOffset; i++)
|
||||
{
|
||||
for (int j = z - coordOffset; j <= z + coordOffset; j++)
|
||||
{
|
||||
if (i != x || j != z)
|
||||
{
|
||||
world.setBlock(i, y, j, ModBlocks.dummyBlock, metaData, 3);
|
||||
((TileEntityEE) world.getTileEntity(i, y, j)).setOrientation(metaData);
|
||||
((TileEntityDummy) world.getTileEntity(i, y, j)).setTrueCoords(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH)
|
||||
{
|
||||
for (int i = x - coordOffset; i <= x + coordOffset; i++)
|
||||
{
|
||||
for (int j = y - coordOffset; j <= y + coordOffset; j++)
|
||||
{
|
||||
if (i != x || j != y)
|
||||
{
|
||||
world.setBlock(i, j, z, ModBlocks.dummyBlock, metaData, 3);
|
||||
((TileEntityEE) world.getTileEntity(i, j, z)).setOrientation(metaData);
|
||||
((TileEntityDummy) world.getTileEntity(i, j, z)).setTrueCoords(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST)
|
||||
{
|
||||
for (int i = y - coordOffset; i <= y + coordOffset; i++)
|
||||
{
|
||||
for (int j = z - coordOffset; j <= z + coordOffset; j++)
|
||||
{
|
||||
if (i != y || j != z)
|
||||
{
|
||||
world.setBlock(x, i, j, ModBlocks.dummyBlock, metaData, 3);
|
||||
((TileEntityEE) world.getTileEntity(x, i, j)).setOrientation(metaData);
|
||||
((TileEntityDummy) world.getTileEntity(x, i, j)).setTrueCoords(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
||||
{
|
||||
|
@ -143,8 +260,6 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
{
|
||||
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
|
||||
|
||||
int largestGlyphSize = tileEntityAlchemyArray.getAlchemyArray().getLargestGlyphSize();
|
||||
|
||||
switch (tileEntityAlchemyArray.getOrientation())
|
||||
{
|
||||
case DOWN:
|
||||
|
@ -154,7 +269,7 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
case UP:
|
||||
{
|
||||
this.setBlockBounds(0 - (largestGlyphSize - 1) / 2, 0f, 0 - (largestGlyphSize - 1) / 2, 1 + (largestGlyphSize - 1) / 2, 0.0625f, 1 + (largestGlyphSize - 1) / 2);
|
||||
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
|
|
199
src/main/java/com/pahimar/ee3/block/BlockDummy.java
Normal file
199
src/main/java/com/pahimar/ee3/block/BlockDummy.java
Normal file
|
@ -0,0 +1,199 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
|
||||
import com.pahimar.ee3.tileentity.TileEntityDummy;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDummy extends BlockEE implements ITileEntityProvider
|
||||
{
|
||||
public BlockDummy()
|
||||
{
|
||||
super(Material.circuits);
|
||||
setCreativeTab(null);
|
||||
this.setBlockName(Names.Blocks.DUMMY_BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int getRenderType()
|
||||
// {
|
||||
// return RenderIds.dummy;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
|
||||
{
|
||||
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummy)
|
||||
{
|
||||
int trueXCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueXCoord();
|
||||
int trueYCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueYCoord();
|
||||
int trueZCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueZCoord();
|
||||
|
||||
if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray)
|
||||
{
|
||||
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord);
|
||||
boolean invalidateAlchemyArray = false;
|
||||
|
||||
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true))
|
||||
{
|
||||
invalidateAlchemyArray = true;
|
||||
}
|
||||
|
||||
if (invalidateAlchemyArray)
|
||||
{
|
||||
world.getTileEntity(x, y, z).invalidate();
|
||||
tileEntityAlchemyArray.invalidate();
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.setBlockToAir(trueXCoord, trueYCoord, trueZCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random random, int par2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
|
||||
{
|
||||
// TODO: Make this work using the blocks own orientation
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityDummy)
|
||||
{
|
||||
int trueXCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueXCoord();
|
||||
int trueYCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueYCoord();
|
||||
int trueZCoord = ((TileEntityDummy) world.getTileEntity(x, y, z)).getTrueZCoord();
|
||||
|
||||
if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray)
|
||||
{
|
||||
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord);
|
||||
|
||||
switch (tileEntityAlchemyArray.getOrientation())
|
||||
{
|
||||
case DOWN:
|
||||
{
|
||||
this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f);
|
||||
break;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f);
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f);
|
||||
break;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f);
|
||||
break;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f);
|
||||
break;
|
||||
}
|
||||
case UNKNOWN:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
|
||||
}
|
||||
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metaData)
|
||||
{
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityDummy)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
super.breakBlock(world, ((TileEntityDummy) tileEntity).getTrueXCoord(), ((TileEntityDummy) tileEntity).getTrueYCoord(), ((TileEntityDummy) tileEntity).getTrueZCoord(), block, metaData);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, metaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*
|
||||
* @param world
|
||||
* @param metaData
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metaData)
|
||||
{
|
||||
return new TileEntityDummy();
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
@GameRegistry.ObjectHolder(Reference.MOD_ID)
|
||||
public class ModBlocks
|
||||
{
|
||||
public static final BlockEE dummyBlock = new BlockDummy();
|
||||
public static final BlockEE chalkBlock = new BlockChalk();
|
||||
public static final BlockEE alchemicalFuelBlock = new BlockAlchemicalFuel();
|
||||
public static final BlockEE alchemicalChest = new BlockAlchemicalChest();
|
||||
|
@ -22,6 +23,7 @@ public class ModBlocks
|
|||
|
||||
public static void init()
|
||||
{
|
||||
GameRegistry.registerBlock(dummyBlock, Names.Blocks.DUMMY_BLOCK);
|
||||
GameRegistry.registerBlock(calcinator, Names.Blocks.CALCINATOR);
|
||||
GameRegistry.registerBlock(aludel, Names.Blocks.ALUDEL);
|
||||
GameRegistry.registerBlock(glassBell, Names.Blocks.GLASS_BELL);
|
||||
|
|
23
src/main/java/com/pahimar/ee3/init/TileEntities.java
Normal file
23
src/main/java/com/pahimar/ee3/init/TileEntities.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.pahimar.ee3.init;
|
||||
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class TileEntities
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityDummy.class, Names.Blocks.DUMMY_BLOCK);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST, "tile." + Names.Blocks.ALCHEMICAL_CHEST);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestSmall.class, Names.Blocks.ALCHEMICAL_CHEST + "Small", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Small");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestMedium.class, Names.Blocks.ALCHEMICAL_CHEST + "Medium", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Medium");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestLarge.class, Names.Blocks.ALCHEMICAL_CHEST + "Large", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Large");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAludel.class, Names.Blocks.ALUDEL, "tile." + Names.Blocks.ALUDEL);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityCalcinator.class, Names.Blocks.CALCINATOR, "tile." + Names.Blocks.CALCINATOR);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityGlassBell.class, Names.Blocks.GLASS_BELL, "tile." + Names.Blocks.GLASS_BELL);
|
||||
GameRegistry.registerTileEntity(TileEntityResearchStation.class, Names.Blocks.RESEARCH_STATION);
|
||||
GameRegistry.registerTileEntity(TileEntityAugmentationTable.class, Names.Blocks.AUGMENTATION_TABLE);
|
||||
GameRegistry.registerTileEntity(TileEntityAlchemyArray.class, Names.Blocks.ALCHEMY_ARRAY);
|
||||
}
|
||||
}
|
|
@ -22,5 +22,6 @@ public class PacketHandler
|
|||
INSTANCE.registerMessage(MessageSetEnergyValue.class, MessageSetEnergyValue.class, 7, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageTileEntityAlchemyArray.class, MessageTileEntityAlchemyArray.class, 8, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageChalkSettings.class, MessageChalkSettings.class, 9, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageTileEntityDummy.class, MessageTileEntityDummy.class, 10, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileEntityDummy;
|
||||
import com.pahimar.ee3.tileentity.TileEntityEE;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class MessageTileEntityDummy implements IMessage, IMessageHandler<MessageTileEntityDummy, IMessage>
|
||||
{
|
||||
public int x, y, z;
|
||||
public byte orientation;
|
||||
public byte state;
|
||||
public String customName, owner;
|
||||
public int trueXCoord, trueYCoord, trueZCoord;
|
||||
|
||||
public MessageTileEntityDummy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MessageTileEntityDummy(TileEntityDummy tileEntityDummy)
|
||||
{
|
||||
this.x = tileEntityDummy.xCoord;
|
||||
this.y = tileEntityDummy.yCoord;
|
||||
this.z = tileEntityDummy.zCoord;
|
||||
this.orientation = (byte) tileEntityDummy.getOrientation().ordinal();
|
||||
this.state = (byte) tileEntityDummy.getState();
|
||||
this.customName = tileEntityDummy.getCustomName();
|
||||
this.owner = tileEntityDummy.getOwner();
|
||||
this.trueXCoord = tileEntityDummy.getTrueXCoord();
|
||||
this.trueYCoord = tileEntityDummy.getTrueYCoord();
|
||||
this.trueZCoord = tileEntityDummy.getTrueZCoord();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from the supplied buffer into your specific message type
|
||||
*
|
||||
* @param buf
|
||||
*/
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.orientation = buf.readByte();
|
||||
this.state = buf.readByte();
|
||||
int customNameLength = buf.readInt();
|
||||
this.customName = new String(buf.readBytes(customNameLength).array());
|
||||
int ownerLength = buf.readInt();
|
||||
this.owner = new String(buf.readBytes(ownerLength).array());
|
||||
this.trueXCoord = buf.readInt();
|
||||
this.trueYCoord = buf.readInt();
|
||||
this.trueZCoord = buf.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deconstruct your message into the supplied byte buffer
|
||||
*
|
||||
* @param buf
|
||||
*/
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeByte(orientation);
|
||||
buf.writeByte(state);
|
||||
buf.writeInt(customName.length());
|
||||
buf.writeBytes(customName.getBytes());
|
||||
buf.writeInt(owner.length());
|
||||
buf.writeBytes(owner.getBytes());
|
||||
buf.writeInt(trueXCoord);
|
||||
buf.writeInt(trueYCoord);
|
||||
buf.writeInt(trueZCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply
|
||||
* is needed.
|
||||
*
|
||||
* @param message The message
|
||||
* @param ctx
|
||||
* @return an optional return message
|
||||
*/
|
||||
@Override
|
||||
public IMessage onMessage(MessageTileEntityDummy message, MessageContext ctx)
|
||||
{
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
|
||||
if (tileEntity instanceof TileEntityEE)
|
||||
{
|
||||
((TileEntityEE) tileEntity).setOrientation(message.orientation);
|
||||
((TileEntityEE) tileEntity).setState(message.state);
|
||||
((TileEntityEE) tileEntity).setCustomName(message.customName);
|
||||
((TileEntityEE) tileEntity).setOwner(message.owner);
|
||||
|
||||
if (tileEntity instanceof TileEntityDummy)
|
||||
{
|
||||
((TileEntityDummy) tileEntity).setTrueCoords(message.trueXCoord, message.trueYCoord, message.trueZCoord);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -10,9 +10,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
|
||||
public class MessageTileEntityEE implements IMessage, IMessageHandler<MessageTileEntityEE, IMessage>
|
||||
{
|
||||
// TODO: Investigate using compressed NBT data to unify tile entity packets into this single one
|
||||
// We would only need x, y, z, and the compressed nbt byte glyphs to do this
|
||||
|
||||
public int x, y, z;
|
||||
public byte orientation, state;
|
||||
public String customName, owner;
|
||||
|
|
|
@ -57,6 +57,7 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
RenderIds.dummy = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.calcinator = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.aludel = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.alchemicalChest = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import com.pahimar.ee3.handler.*;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public abstract class CommonProxy implements IProxy
|
||||
|
@ -24,18 +21,4 @@ public abstract class CommonProxy implements IProxy
|
|||
FMLCommonHandler.instance().bus().register(craftingHandler);
|
||||
MinecraftForge.EVENT_BUS.register(craftingHandler);
|
||||
}
|
||||
|
||||
public void registerTileEntities()
|
||||
{
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST, "tile." + Names.Blocks.ALCHEMICAL_CHEST);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestSmall.class, Names.Blocks.ALCHEMICAL_CHEST + "Small", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Small");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestMedium.class, Names.Blocks.ALCHEMICAL_CHEST + "Medium", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Medium");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestLarge.class, Names.Blocks.ALCHEMICAL_CHEST + "Large", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Large");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAludel.class, Names.Blocks.ALUDEL, "tile." + Names.Blocks.ALUDEL);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityCalcinator.class, Names.Blocks.CALCINATOR, "tile." + Names.Blocks.CALCINATOR);
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityGlassBell.class, Names.Blocks.GLASS_BELL, "tile." + Names.Blocks.GLASS_BELL);
|
||||
GameRegistry.registerTileEntity(TileEntityResearchStation.class, Names.Blocks.RESEARCH_STATION);
|
||||
GameRegistry.registerTileEntity(TileEntityAugmentationTable.class, Names.Blocks.AUGMENTATION_TABLE);
|
||||
GameRegistry.registerTileEntity(TileEntityAlchemyArray.class, Names.Blocks.ALCHEMY_ARRAY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ public interface IProxy
|
|||
{
|
||||
public abstract ClientProxy getClientProxy();
|
||||
|
||||
public abstract void registerTileEntities();
|
||||
|
||||
public abstract void initRenderingAndTextures();
|
||||
|
||||
public abstract void registerEventHandlers();
|
||||
|
|
|
@ -14,6 +14,7 @@ public class Names
|
|||
public static final String AUGMENTATION_TABLE = "augmentationTable";
|
||||
public static final String TRANSMUTATION_SQUARE = "transmutationSquare";
|
||||
public static final String ALCHEMY_ARRAY = "alchemyArray";
|
||||
public static final String DUMMY_BLOCK = "dummyBlock";
|
||||
}
|
||||
|
||||
public static final class Items
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.pahimar.ee3.reference;
|
|||
|
||||
public class RenderIds
|
||||
{
|
||||
public static int dummy;
|
||||
public static int calcinator;
|
||||
public static int aludel;
|
||||
public static int alchemicalChest;
|
||||
|
|
|
@ -199,4 +199,10 @@ public class TileEntityAlchemyArray extends TileEntityEE
|
|||
|
||||
nbtTagCompound.setTag("alchemyArray", alchemyArrayTagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
// LogHelper.info(String.format("x: %s, y: %s, z: %s", this.xCoord, this.yCoord, this.zCoord));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package com.pahimar.ee3.tileentity;
|
||||
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTileEntityDummy;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public class TileEntityDummy extends TileEntityEE
|
||||
{
|
||||
private int trueXCoord, trueYCoord, trueZCoord;
|
||||
private int ticksSinceSync;
|
||||
|
||||
public TileEntityDummy()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public int getTrueXCoord()
|
||||
{
|
||||
return trueXCoord;
|
||||
}
|
||||
|
||||
public int getTrueYCoord()
|
||||
{
|
||||
return trueYCoord;
|
||||
}
|
||||
|
||||
public int getTrueZCoord()
|
||||
{
|
||||
return trueZCoord;
|
||||
}
|
||||
|
||||
public void setTrueCoords(int trueXCoord, int trueYCoord, int trueZCoord)
|
||||
{
|
||||
this.trueXCoord = trueXCoord;
|
||||
this.trueYCoord = trueYCoord;
|
||||
this.trueZCoord = trueZCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (++ticksSinceSync % 10 == 0)
|
||||
{
|
||||
if (!worldObj.isRemote && !(worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityEE))
|
||||
{
|
||||
this.invalidate();
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityDummy(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
this.trueXCoord = nbtTagCompound.getInteger("trueXCoord");
|
||||
this.trueYCoord = nbtTagCompound.getInteger("trueYCoord");
|
||||
this.trueZCoord = nbtTagCompound.getInteger("trueZCoord");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
nbtTagCompound.setInteger("trueXCoord", trueXCoord);
|
||||
nbtTagCompound.setInteger("trueYCoord", trueYCoord);
|
||||
nbtTagCompound.setInteger("trueZCoord", trueZCoord);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue