some more texture work
This commit is contained in:
parent
f12725b4e0
commit
9f3622ea33
13 changed files with 253 additions and 107 deletions
|
@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.power.IEnergyInterfaceTile;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.tiles.TileMachineBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -316,11 +317,10 @@ public class RecipeCrafter {
|
|||
|
||||
|
||||
public void setIsActive() {
|
||||
// if (isActive()) { //TODO 1.8 update
|
||||
// parentTile.getWorld().setBlockMetadataWithNotify(parentTile.getPos().getX(), parentTile.getPos().getY(), parentTile.getPos().getZ(), 1, 2);
|
||||
// } else {
|
||||
// parentTile.getWorld().setBlockMetadataWithNotify(parentTile.getPos().getX(), parentTile.getPos().getY(), parentTile.getPos().getZ(), 0, 2);
|
||||
// }
|
||||
if(parentTile.getWorld().getBlockState(parentTile.getPos()).getBlock() instanceof BlockMachineBase){
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) parentTile.getWorld().getBlockState(parentTile.getPos()).getBlock();
|
||||
blockMachineBase.setActive(isActive(), parentTile.getWorld(), parentTile.getPos());
|
||||
}
|
||||
parentTile.getWorld().markBlockForUpdate(parentTile.getPos());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockDynamicLiquid;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
|
@ -22,21 +24,36 @@ import net.minecraft.util.MathHelper;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import reborncore.api.IBlockTextureProvider;
|
||||
import reborncore.common.BaseBlock;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.TileMachineBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockMachineBase extends BlockContainer {
|
||||
public abstract class BlockMachineBase extends BaseTileBlock implements IBlockTextureProvider {
|
||||
|
||||
public static PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
||||
|
||||
public BlockMachineBase(Material material) {
|
||||
super(Material.rock);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHardness(2f);
|
||||
setStepSound(soundTypeMetal);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false));
|
||||
}
|
||||
|
||||
protected BlockState createBlockState() {
|
||||
|
||||
FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
ACTIVE = PropertyBool.create("active");
|
||||
return new BlockState(this, FACING, ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,38 +69,38 @@ public class BlockMachineBase extends BlockContainer {
|
|||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
onBlockAdded(worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
this.setDefaultDirection(worldIn, pos);
|
||||
this.setDefaultFacing(worldIn, pos, state);
|
||||
}
|
||||
|
||||
private void setDefaultDirection(World world, BlockPos pos) {
|
||||
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
Block block = worldIn.getBlockState(pos.north()).getBlock();
|
||||
Block block1 = worldIn.getBlockState(pos.south()).getBlock();
|
||||
Block block2 = worldIn.getBlockState(pos.west()).getBlock();
|
||||
Block block3 = worldIn.getBlockState(pos.east()).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (!world.isRemote) {
|
||||
Block block1 = world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)).getBlock();
|
||||
Block block2 = world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)).getBlock();
|
||||
Block block3 = world.getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())).getBlock();
|
||||
Block block4 = world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())).getBlock();
|
||||
|
||||
byte b = 3;
|
||||
|
||||
if (block1.isOpaqueCube() && !block2.isOpaqueCube()) {
|
||||
b = 3;
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
if (block2.isOpaqueCube() && !block1.isOpaqueCube()) {
|
||||
b = 2;
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
if (block3.isOpaqueCube() && !block4.isOpaqueCube()) {
|
||||
b = 5;
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
if (block4.isOpaqueCube() && !block3.isOpaqueCube()) {
|
||||
b = 4;
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
//TODO 1.8 meta
|
||||
// world.setBlockMetadataWithNotify(x, y, z, b, 2);
|
||||
setTileRotation(world, pos, b);
|
||||
|
||||
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -97,22 +114,7 @@ public class BlockMachineBase extends BlockContainer {
|
|||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
onBlockPlacedBy(worldIn, pos.getX(), pos.getY(), pos.getZ(), placer, stack);
|
||||
|
||||
int l = MathHelper
|
||||
.floor_double((double) (placer.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0) {
|
||||
setTileRotation(worldIn, pos, 2);
|
||||
}
|
||||
if (l == 1) {
|
||||
setTileRotation(worldIn, pos, 5);
|
||||
}
|
||||
if (l == 2) {
|
||||
setTileRotation(worldIn, pos, 3);
|
||||
}
|
||||
if (l == 3) {
|
||||
setTileRotation(worldIn, pos, 4);
|
||||
}
|
||||
setFacing(placer.getHorizontalFacing().getOpposite(), worldIn, pos);
|
||||
}
|
||||
|
||||
public boolean canCreatureSpawn(EnumCreatureType type, World world, int x,
|
||||
|
@ -172,23 +174,6 @@ public class BlockMachineBase extends BlockContainer {
|
|||
}
|
||||
}
|
||||
|
||||
public void setTileRotation(World world, BlockPos pos, int meta) {
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileMachineBase) {
|
||||
((TileMachineBase) world.getTileEntity(pos)).setRotation(meta);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTileRotation(World world, BlockPos pos) {
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileMachineBase) {
|
||||
return ((TileMachineBase) world.getTileEntity(pos)).getRotation();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getTileRotation(IBlockAccess blockAccess, BlockPos pos) {
|
||||
return blockAccess.getTileEntity(pos) != null ? getTileRotation(blockAccess.getTileEntity(pos).getWorld(), pos) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
@ -213,7 +198,8 @@ public class BlockMachineBase extends BlockContainer {
|
|||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile != null && tile instanceof TileMachineBase) {
|
||||
TileMachineBase machineBase = (TileMachineBase) tile;
|
||||
machineBase.setRotation(EnumFacing.getFront(machineBase.getRotation()).getOpposite().ordinal());
|
||||
//TODO fix
|
||||
// world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, EnumFacing.getFront(world.getBlockState(pos).getValue(FACING)).getOpposite()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -341,4 +327,64 @@ public class BlockMachineBase extends BlockContainer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureName(IBlockState blockState, EnumFacing facing) {
|
||||
if(this instanceof IRotationTexture){
|
||||
IRotationTexture rotationTexture = (IRotationTexture) this;
|
||||
if(getFacing(blockState) == facing){
|
||||
return isActive(blockState) ? rotationTexture.getFrontOn() : rotationTexture.getFrontOff();
|
||||
}
|
||||
if(facing == EnumFacing.UP){
|
||||
return rotationTexture.getTop();
|
||||
}
|
||||
if(facing == EnumFacing.DOWN){
|
||||
return rotationTexture.getBottom();
|
||||
}
|
||||
return rotationTexture.getSide();
|
||||
}
|
||||
return "techreborn:blocks/machine/machine_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
boolean active = false;
|
||||
if(meta > 6){
|
||||
active = true;
|
||||
meta =- 6;
|
||||
}
|
||||
int facingInt = meta;
|
||||
EnumFacing facing = EnumFacing.getFront(facingInt);
|
||||
if(facing == EnumFacing.DOWN || facing == EnumFacing.UP){
|
||||
facing = EnumFacing.NORTH;
|
||||
}
|
||||
return this.getDefaultState().withProperty(FACING, facing).withProperty(ACTIVE, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
int facingInt = state.getValue(FACING).getIndex();
|
||||
int activeInt = state.getValue(ACTIVE) ? 0 : 6;
|
||||
return facingInt + activeInt;
|
||||
}
|
||||
|
||||
public boolean isActive(IBlockState state){
|
||||
return state.getValue(ACTIVE);
|
||||
}
|
||||
|
||||
public EnumFacing getFacing(IBlockState state){
|
||||
return state.getValue(FACING);
|
||||
}
|
||||
|
||||
public void setFacing(EnumFacing facing, World world, BlockPos pos){
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
|
||||
}
|
||||
|
||||
|
||||
public void setActive(Boolean active, World world, BlockPos pos){
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(ACTIVE, active));
|
||||
}
|
||||
@Override
|
||||
public int amoutOfVariants() {
|
||||
return 12; //six for Facing, and then 2 for eatch of them for if active
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class BlockStorage extends BaseBlock implements IBlockTextureProvider {
|
|||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return (Integer) state.getValue(METADATA);
|
||||
return state.getValue(METADATA);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState() {
|
||||
|
|
14
src/main/java/techreborn/blocks/IRotationTexture.java
Normal file
14
src/main/java/techreborn/blocks/IRotationTexture.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
public interface IRotationTexture {
|
||||
|
||||
String getFrontOff();
|
||||
|
||||
String getFrontOn();
|
||||
|
||||
String getSide();
|
||||
|
||||
String getTop();
|
||||
|
||||
String getBottom();
|
||||
}
|
|
@ -6,10 +6,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.blocks.IRotationTexture;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
|
||||
public class BlockAlloyFurnace extends BlockMachineBase {
|
||||
public class BlockAlloyFurnace extends BlockMachineBase implements IRotationTexture {
|
||||
|
||||
|
||||
public BlockAlloyFurnace(Material material) {
|
||||
|
@ -31,4 +32,30 @@ public class BlockAlloyFurnace extends BlockMachineBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
private final String prefix = "techreborn:/blocks/machine/";
|
||||
|
||||
@Override
|
||||
public String getFrontOff() {
|
||||
return prefix + "alloy_furnace_front_off";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn() {
|
||||
return prefix + "alloy_furnace_front_on";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide() {
|
||||
return prefix + "alloy_furnace_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop() {
|
||||
return prefix + "alloy_furnace_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom() {
|
||||
return prefix + "machine_bottom";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.blocks.IRotationTexture;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
|
||||
public class BlockAlloySmelter extends BlockMachineBase {
|
||||
public class BlockAlloySmelter extends BlockMachineBase implements IRotationTexture {
|
||||
|
||||
|
||||
public BlockAlloySmelter(Material material) {
|
||||
|
@ -31,4 +32,31 @@ public class BlockAlloySmelter extends BlockMachineBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
private final String prefix = "techreborn:/blocks/machine/";
|
||||
|
||||
@Override
|
||||
public String getFrontOff() {
|
||||
return prefix + "electric_alloy_furnace_front_off";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn() {
|
||||
return prefix + "electric_alloy_furnace_front_on";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide() {
|
||||
return prefix + "machine_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop() {
|
||||
return prefix + "machine_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom() {
|
||||
return prefix + "machine_bottom";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.blocks.IRotationTexture;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileAesu;
|
||||
|
||||
public class BlockAesu extends BlockMachineBase {
|
||||
public class BlockAesu extends BlockMachineBase implements IRotationTexture {
|
||||
|
||||
|
||||
|
||||
|
@ -55,4 +56,31 @@ public class BlockAesu extends BlockMachineBase {
|
|||
// : (side == metadata ? this.iconFront : this.blockIcon));
|
||||
// }
|
||||
|
||||
private final String prefix = "techreborn:/blocks/machine/";
|
||||
|
||||
@Override
|
||||
public String getFrontOff() {
|
||||
return prefix + "aesu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn() {
|
||||
return prefix + "aesu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide() {
|
||||
return prefix + "aesu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop() {
|
||||
return prefix + "aesu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom() {
|
||||
return prefix + "aesu_side";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class GuiBlastFurnace extends GuiContainer {
|
|||
GuiButton button = new GuiButton(212, k + 4, l + 6, 20, 20, "");
|
||||
buttonList.add(button);
|
||||
super.initGui();
|
||||
CoordTriplet coordinates = new CoordTriplet(blastfurnace.getPos().getX() - (EnumFacing.getFront(blastfurnace.getRotation()).getFrontOffsetX() * 2), blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - (EnumFacing.getFront(blastfurnace.getRotation()).getFrontOffsetZ() * 2));
|
||||
CoordTriplet coordinates = new CoordTriplet(blastfurnace.getPos().getX() - (EnumFacing.getFront(blastfurnace.getFacing()).getFrontOffsetX() * 2), blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - (EnumFacing.getFront(blastfurnace.getFacing()).getFrontOffsetZ() * 2));
|
||||
if(coordinates.equals(ClientProxy.multiblockRenderEvent.anchor) && blastfurnace.getHeat() != 0){
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
button.displayString = "B";
|
||||
|
@ -136,7 +136,7 @@ public class GuiBlastFurnace extends GuiContainer {
|
|||
MultiblockSet set = new MultiblockSet(multiblock);
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||
ClientProxy.multiblockRenderEvent.partent = new Location(blastfurnace.getPos().getX(), blastfurnace.getPos().getY(), blastfurnace.getPos().getZ(), blastfurnace.getWorld());
|
||||
ClientProxy.multiblockRenderEvent.anchor = new CoordTriplet(blastfurnace.getPos().getX() - (EnumFacing.getFront(blastfurnace.getRotation()).getFrontOffsetX() * 2), blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - (EnumFacing.getFront(blastfurnace.getRotation()).getFrontOffsetZ() * 2));
|
||||
ClientProxy.multiblockRenderEvent.anchor = new CoordTriplet(blastfurnace.getPos().getX() - (EnumFacing.getFront(blastfurnace.getFacing()).getFrontOffsetX() * 2), blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - (EnumFacing.getFront(blastfurnace.getFacing()).getFrontOffsetZ() * 2));
|
||||
}
|
||||
button.displayString = "A";
|
||||
} else {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GuiFusionReactor extends GuiContainer {
|
|||
GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, "");
|
||||
buttonList.add(button);
|
||||
super.initGui();
|
||||
CoordTriplet coordinates = new CoordTriplet(fusionController.getPos().getX() - (EnumFacing.getFront(fusionController.getRotation()).getFrontOffsetX() * 2), fusionController.getPos().getY() - 1, fusionController.getPos().getZ() - (EnumFacing.getFront(fusionController.getRotation()).getFrontOffsetZ() * 2));
|
||||
CoordTriplet coordinates = new CoordTriplet(fusionController.getPos().getX() - (EnumFacing.getFront(fusionController.getFacingInt()).getFrontOffsetX() * 2), fusionController.getPos().getY() - 1, fusionController.getPos().getZ() - (EnumFacing.getFront(fusionController.getFacingInt()).getFrontOffsetZ() * 2));
|
||||
if(coordinates.equals(ClientProxy.multiblockRenderEvent.anchor)){
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
button.displayString = "B";
|
||||
|
|
|
@ -53,12 +53,12 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable {
|
|||
|
||||
@Override
|
||||
public short getFacing() {
|
||||
return (short) getRotation();
|
||||
return (short) getFacingInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(short facing) {
|
||||
setRotation(facing);
|
||||
setFacing(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,12 +144,12 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable {
|
|||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getRotation() != Functions.getIntDirFromDirection(direction);
|
||||
return getFacing() != Functions.getIntDirFromDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getRotation() == Functions.getIntDirFromDirection(direction);
|
||||
return getFacing() == Functions.getIntDirFromDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -13,10 +14,12 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import reborncore.common.misc.Location;
|
||||
import reborncore.common.multiblock.IMultiblockPart;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
@ -57,6 +60,10 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
|
||||
@Override
|
||||
public short getFacing() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if(block instanceof BlockMachineBase){
|
||||
return (short) ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos)).getIndex();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.ITickable;
|
||||
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.EnumFacing;
|
||||
import reborncore.common.packets.PacketHandler;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
|
||||
public class TileMachineBase extends TileEntity implements ITickable {
|
||||
|
||||
int rotation;
|
||||
|
||||
public void syncWithAll() {
|
||||
if (!worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(),
|
||||
|
@ -32,34 +33,6 @@ public class TileMachineBase extends TileEntity implements ITickable {
|
|||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public void setRotation(int rotation) {
|
||||
this.rotation = rotation;
|
||||
syncWithAll();
|
||||
worldObj.notifyBlockOfStateChange(getPos(), blockType);
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
if (tagCompound.hasKey("meta") && !tagCompound.hasKey("rotation")) {
|
||||
rotation = tagCompound.getInteger("meta");
|
||||
} else {
|
||||
rotation = tagCompound.getInteger("rotation");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger("rotation", rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
updateEntity();
|
||||
|
@ -69,5 +42,28 @@ public class TileMachineBase extends TileEntity implements ITickable {
|
|||
|
||||
}
|
||||
|
||||
public int getFacingInt() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if(block instanceof BlockMachineBase){
|
||||
return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos)).getIndex();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public EnumFacing getFacingEnum() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if(block instanceof BlockMachineBase){
|
||||
return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setFacing(EnumFacing enumFacing) {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if(block instanceof BlockMachineBase){
|
||||
((BlockMachineBase) block).setFacing(enumFacing, worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,12 +85,12 @@ public class TileLesu extends TilePowerAcceptor {//TODO wrench
|
|||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return Functions.getIntDirFromDirection(direction) != getRotation();
|
||||
return direction != getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return Functions.getIntDirFromDirection(direction) == getRotation();
|
||||
return direction == getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue