use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.
the class TileEntityCargoLoader method checkForCargoEntity.
public void checkForCargoEntity() {
boolean foundFuelable = false;
BlockVec3 thisVec = new BlockVec3(this);
for (final EnumFacing dir : EnumFacing.VALUES) {
final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
if (pad != null && pad instanceof TileEntityMulti) {
final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
if (mainTile instanceof ICargoEntity) {
this.attachedFuelable = (ICargoEntity) mainTile;
foundFuelable = true;
break;
}
} else if (pad != null && pad instanceof ICargoEntity) {
this.attachedFuelable = (ICargoEntity) pad;
foundFuelable = true;
break;
}
}
if (!foundFuelable) {
this.attachedFuelable = null;
}
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.
the class TileEntityFuelLoader method update.
@Override
public void update() {
super.update();
if (!this.worldObj.isRemote) {
this.loadedFuelLastTick = false;
final FluidStack liquidContained = FluidUtil.getFluidContained(this.containingItems[1]);
if (FluidUtil.isFuel(liquidContained)) {
FluidUtil.loadFromContainer(this.fuelTank, GCFluids.fluidFuel, this.containingItems, 1, liquidContained.amount);
}
if (this.ticks % 100 == 0) {
this.attachedFuelable = null;
BlockVec3 thisVec = new BlockVec3(this);
for (final EnumFacing dir : EnumFacing.VALUES) {
final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
if (pad instanceof TileEntityMulti) {
final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
if (mainTile instanceof IFuelable) {
this.attachedFuelable = (IFuelable) mainTile;
break;
}
} else if (pad instanceof IFuelable) {
this.attachedFuelable = (IFuelable) pad;
break;
}
}
}
if (this.fuelTank != null && this.fuelTank.getFluid() != null && this.fuelTank.getFluid().amount > 0) {
final FluidStack liquid = new FluidStack(GCFluids.fluidFuel, 2);
if (this.attachedFuelable != null && this.hasEnoughEnergyToRun && !this.disabled) {
int filled = this.attachedFuelable.addFuel(liquid, true);
this.loadedFuelLastTick = filled > 0;
this.fuelTank.drain(filled, true);
}
}
}
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.
the class EventHandlerMars method orientCamera.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void orientCamera(OrientCameraEvent event) {
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
if (entity != null) {
int x = MathHelper.floor_double(entity.posX);
int y = MathHelper.floor_double(entity.posY);
int z = MathHelper.floor_double(entity.posZ);
TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(new BlockPos(x, y - 1, z));
if (tile instanceof TileEntityMulti) {
tile = ((TileEntityMulti) tile).getMainBlockTile();
}
if (tile instanceof TileEntityCryogenicChamber) {
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
switch(tile.getBlockMetadata() & 3) {
case 0:
GL11.glTranslatef(-0.4F, -0.5F, 4.1F);
break;
case 1:
GL11.glTranslatef(0, -0.5F, 4.1F);
break;
case 2:
GL11.glTranslatef(0, -0.5F, 4.1F);
break;
case 3:
GL11.glTranslatef(0.0F, -0.5F, 4.1F);
break;
}
GL11.glRotatef(-180, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(FMLClientHandler.instance().getClientPlayerEntity().sleepTimer - 50, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.3F, 0.0F);
}
}
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.
the class TileEntityMulti method initialiseMultiTiles.
protected boolean initialiseMultiTiles(BlockPos pos, World world) {
IMultiBlock thisTile = (IMultiBlock) this;
// Client can create its own fake blocks and tiles - no need for networking in 1.8+
if (world.isRemote) {
thisTile.onCreate(world, pos);
}
List<BlockPos> positions = new ArrayList<>();
thisTile.getPositions(pos, positions);
boolean result = true;
for (BlockPos vecToAdd : positions) {
TileEntity tile = world.getTileEntity(vecToAdd);
if (tile instanceof TileEntityMulti) {
((TileEntityMulti) tile).mainBlockPosition = pos;
} else if (tile == null) {
Block b = world.getBlockState(vecToAdd).getBlock();
if (!(b instanceof BlockMulti)) {
world.setBlockState(vecToAdd, GCBlocks.fakeBlock.getDefaultState().withProperty(BlockMulti.MULTI_TYPE, thisTile.getMultiType()), 2);
}
world.setTileEntity(vecToAdd, new TileEntityMulti(pos));
} else {
result = false;
}
}
if (result == false && !world.isRemote) {
// //Try again to create all the multiblocks - currently disabled because making new tiles here interferes with server->client tileEntity sync during worldgen (Abandoned Base)
// thisTile.onCreate(world, pos);
}
return result;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.
the class ItemAstroMiner method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tile = null;
if (worldIn.isRemote || playerIn == null) {
return false;
} else {
final Block id = worldIn.getBlockState(pos).getBlock();
if (id == GCBlocks.fakeBlock) {
tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityMulti) {
tile = ((TileEntityMulti) tile).getMainBlockTile();
}
}
if (id == AsteroidBlocks.minerBaseFull) {
tile = worldIn.getTileEntity(pos);
}
if (tile instanceof TileEntityMinerBase) {
if (worldIn.provider instanceof WorldProviderSpaceStation) {
playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner7.fail")));
return false;
}
if (((TileEntityMinerBase) tile).getLinkedMiner() != null) {
playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner.fail")));
return false;
}
// Gives a chance for any loaded Astro Miner to link itself
if (((TileEntityMinerBase) tile).ticks < 15L) {
return false;
}
EntityPlayerMP playerMP = (EntityPlayerMP) playerIn;
GCPlayerStats stats = GCPlayerStats.get(playerIn);
int astroCount = stats.getAstroMinerCount();
if (astroCount >= ConfigManagerAsteroids.astroMinerMax && (!playerIn.capabilities.isCreativeMode)) {
playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner2.fail")));
return false;
}
if (!((TileEntityMinerBase) tile).spawnMiner(playerMP)) {
playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner1.fail") + " " + GCCoreUtil.translate(EntityAstroMiner.blockingBlock.toString())));
return false;
}
if (!playerIn.capabilities.isCreativeMode) {
stats.setAstroMinerCount(stats.getAstroMinerCount() + 1);
--stack.stackSize;
}
return true;
}
}
return false;
}
Aggregations