use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.
the class BlockMachineMars method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
int metadata = getMetaFromState(state);
final int angle = MathHelper.floor_double(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
int change = EnumFacing.getHorizontal(angle).getOpposite().getHorizontalIndex();
worldIn.setBlockState(pos, getStateFromMeta((metadata & 12) + change), 3);
switch(metadata & 12) {
case BlockMachineMars.CRYOGENIC_CHAMBER_METADATA:
BlockMulti.onPlacement(worldIn, pos, placer, this);
break;
case BlockMachineMars.LAUNCH_CONTROLLER_METADATA:
WorldUtil.markAdjacentPadForUpdate(worldIn, pos);
TileEntity var8 = worldIn.getTileEntity(pos);
if (var8 instanceof IChunkLoader && !worldIn.isRemote && ConfigManagerMars.launchControllerChunkLoad && placer instanceof EntityPlayer) {
((IChunkLoader) var8).setOwnerName(((EntityPlayer) placer).getName());
((IChunkLoader) var8).onTicketLoaded(ForgeChunkManager.requestTicket(GalacticraftCore.instance, var8.getWorld(), Type.NORMAL), true);
} else if (var8 instanceof TileEntityLaunchController && placer instanceof EntityPlayer) {
((TileEntityLaunchController) var8).setOwnerName(((EntityPlayer) placer).getName());
}
break;
}
}
use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.
the class PacketSimpleMars method handleServerSide.
@Override
public void handleServerSide(EntityPlayer player) {
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
switch(this.type) {
case S_UPDATE_SLIMELING_DATA:
Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0));
if (entity instanceof EntitySlimeling) {
EntitySlimeling slimeling = (EntitySlimeling) entity;
int subType = (Integer) this.data.get(1);
switch(subType) {
case 0:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.setSittingAI(!slimeling.isSitting());
slimeling.setJumping(false);
slimeling.getNavigator().clearPathEntity();
slimeling.setAttackTarget(null);
}
break;
case 1:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.slimelingName = (String) this.data.get(2);
slimeling.setName(slimeling.slimelingName);
}
break;
case 2:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.age += 5000;
}
break;
case 3:
if (!slimeling.isInLove() && player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.setInLove(playerBase);
}
break;
case 4:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.attackDamage = Math.min(slimeling.attackDamage + 0.1F, 1.0F);
}
break;
case 5:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
slimeling.setHealth(slimeling.getHealth() + 5.0F);
}
break;
case 6:
if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
MarsUtil.openSlimelingInventory(playerBase, slimeling);
}
break;
}
}
break;
case S_WAKE_PLAYER:
BlockPos c = playerBase.playerLocation;
if (c != null) {
EventWakePlayer event = new EventWakePlayer(playerBase, c, true, true, false, true);
MinecraftForge.EVENT_BUS.post(event);
playerBase.wakeUpPlayer(true, true, false);
}
break;
case S_UPDATE_ADVANCED_GUI:
TileEntity tile = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
switch((Integer) this.data.get(0)) {
case 0:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.setFrequency((Integer) this.data.get(2));
}
break;
case 1:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.setLaunchDropdownSelection((Integer) this.data.get(2));
}
break;
case 2:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.setDestinationFrequency((Integer) this.data.get(2));
}
break;
case 3:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.launchPadRemovalDisabled = (Integer) this.data.get(2) == 1;
}
break;
case 4:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.setLaunchSchedulingEnabled((Integer) this.data.get(2) == 1);
}
break;
case 5:
if (tile instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
launchController.requiresClientUpdate = true;
}
break;
default:
break;
}
break;
case S_UPDATE_CARGO_ROCKET_STATUS:
Entity entity2 = player.worldObj.getEntityByID((Integer) this.data.get(0));
if (entity2 instanceof EntityCargoRocket) {
EntityCargoRocket rocket = (EntityCargoRocket) entity2;
int subType = (Integer) this.data.get(1);
switch(subType) {
default:
rocket.statusValid = rocket.checkLaunchValidity();
break;
}
}
break;
case S_SWITCH_LAUNCH_CONTROLLER_GUI:
BlockPos pos = (BlockPos) this.data.get(0);
TileEntity tile1 = player.worldObj.getTileEntity(pos);
if (tile1 instanceof TileEntityLaunchController) {
TileEntityLaunchController launchController = (TileEntityLaunchController) tile1;
switch((Integer) this.data.get(1)) {
case 0:
MarsUtil.openAdvancedLaunchController(playerBase, launchController);
break;
case 1:
player.openGui(GalacticraftPlanets.instance, GuiIdsPlanets.MACHINE_MARS, player.worldObj, pos.getX(), pos.getY(), pos.getZ());
break;
}
}
break;
default:
break;
}
}
use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.
the class TileEntityLandingPad method testConnectedTile.
private void testConnectedTile(int x, int z, HashSet<ILandingPadAttachable> connectedTiles) {
BlockPos testPos = new BlockPos(x, this.getPos().getY(), z);
if (!this.worldObj.isBlockLoaded(testPos, false))
return;
final TileEntity tile = this.worldObj.getTileEntity(testPos);
if (tile instanceof ILandingPadAttachable && ((ILandingPadAttachable) tile).canAttachToLandingPad(this.worldObj, this.getPos())) {
connectedTiles.add((ILandingPadAttachable) tile);
if (GalacticraftCore.isPlanetsLoaded && tile instanceof TileEntityLaunchController) {
((TileEntityLaunchController) tile).setAttachedPad(this);
}
}
}
use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.
the class PacketSimpleMars method handleClientSide.
@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
EntityPlayerSP playerBaseClient = null;
if (player instanceof EntityPlayerSP) {
playerBaseClient = (EntityPlayerSP) player;
}
switch(this.type) {
case C_OPEN_CUSTOM_GUI:
int entityID = 0;
Entity entity = null;
switch((Integer) this.data.get(1)) {
case 0:
entityID = (Integer) this.data.get(2);
entity = player.worldObj.getEntityByID(entityID);
if (entity != null && entity instanceof EntitySlimeling) {
FMLClientHandler.instance().getClient().displayGuiScreen(new GuiSlimelingInventory(player, (EntitySlimeling) entity));
}
player.openContainer.windowId = (Integer) this.data.get(0);
break;
case 1:
entityID = (Integer) this.data.get(2);
entity = player.worldObj.getEntityByID(entityID);
if (entity != null && entity instanceof EntityCargoRocket) {
FMLClientHandler.instance().getClient().displayGuiScreen(new GuiCargoRocket(player.inventory, (EntityCargoRocket) entity));
}
player.openContainer.windowId = (Integer) this.data.get(0);
break;
}
break;
case C_OPEN_CUSTOM_GUI_TILE:
BlockPos pos;
TileEntity tile;
switch((Integer) this.data.get(1)) {
case 0:
pos = (BlockPos) this.data.get(2);
tile = player.worldObj.getTileEntity(pos);
if (tile != null && tile instanceof TileEntityLaunchController) {
FMLClientHandler.instance().getClient().displayGuiScreen(new GuiLaunchControllerAdvanced(player.inventory, (TileEntityLaunchController) tile));
}
player.openContainer.windowId = (Integer) this.data.get(0);
break;
}
break;
case C_BEGIN_CRYOGENIC_SLEEP:
pos = (BlockPos) this.data.get(0);
tile = player.worldObj.getTileEntity(pos);
if (tile instanceof TileEntityCryogenicChamber) {
((TileEntityCryogenicChamber) tile).sleepInBedAt(player, pos.getX(), pos.getY(), pos.getZ());
}
default:
break;
}
}
use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.
the class MarsUtil method openAdvancedLaunchController.
public static void openAdvancedLaunchController(EntityPlayerMP player, TileEntityLaunchController launchController) {
player.getNextWindowId();
player.closeContainer();
int windowId = player.currentWindowId;
GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMars(EnumSimplePacketMars.C_OPEN_CUSTOM_GUI_TILE, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { windowId, 0, launchController.getPos() }), player);
player.openContainer = new ContainerLaunchControllerAdvanced(player.inventory, launchController, player);
player.openContainer.windowId = windowId;
player.openContainer.onCraftGuiOpened(player);
}
Aggregations