use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project MorePlanets by SteveKunG.
the class ItemCreativeSpaceKit method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(player);
InventoryExtended inv = stats.getExtendedInventory();
// Oxygen Mask
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
// Oxygen Gear
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
// Creative Oxygen Tank
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxygenCanisterInfinite));
// Creative Oxygen Tank
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxygenCanisterInfinite));
// Parachute
inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
// Frequency Module
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
// Thermal Armor Tier 2
inv.setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2, 1, 0));
// Thermal Armor Tier 2
inv.setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
// Thermal Armor Tier 2
inv.setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
// Thermal Armor Tier 2
inv.setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
// Shield Controller
inv.setInventorySlotContents(10, new ItemStack(VenusItems.basicItem, 1, 0));
}
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EventHandlerGC method schematicUnlocked.
@SubscribeEvent
public void schematicUnlocked(Unlock event) {
GCPlayerStats stats = GCPlayerStats.get(event.player);
if (!stats.getUnlockedSchematics().contains(event.page)) {
stats.getUnlockedSchematics().add(event.page);
Collections.sort(stats.getUnlockedSchematics());
if (event.player != null && event.player.connection != null) {
Integer[] iArray = new Integer[stats.getUnlockedSchematics().size()];
for (int i = 0; i < iArray.length; i++) {
ISchematicPage page = stats.getUnlockedSchematics().get(i);
iArray[i] = page == null ? -2 : page.getPageID();
}
List<Object> objList = new ArrayList<Object>();
objList.add(iArray);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SCHEMATIC_LIST, GCCoreUtil.getDimensionID(event.player.world), objList), event.player);
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EventHandlerGC method onPlayerRightClickedBlock.
@SubscribeEvent
public void onPlayerRightClickedBlock(PlayerInteractEvent.RightClickBlock event) {
// Skip events triggered from Thaumcraft Golems and other non-players
if (event.getEntityPlayer() == null || event.getEntityPlayer().inventory == null || event.getPos() == null || (event.getPos().getX() == 0 && event.getPos().getY() == 0 && event.getPos().getZ() == 0)) {
return;
}
final World worldObj = event.getEntityPlayer().world;
if (worldObj == null) {
return;
}
final Block idClicked = worldObj.getBlockState(event.getPos()).getBlock();
if (idClicked == Blocks.BED && worldObj.provider instanceof IGalacticraftWorldProvider && !worldObj.isRemote && !((IGalacticraftWorldProvider) worldObj.provider).hasBreathableAtmosphere()) {
if (GalacticraftCore.isPlanetsLoaded) {
GCPlayerStats stats = GCPlayerStats.get(event.getEntityPlayer());
if (!stats.hasReceivedBedWarning()) {
event.getEntityPlayer().sendMessage(new TextComponentString(GCCoreUtil.translate("gui.bed_fail.message")));
stats.setReceivedBedWarning(true);
}
}
if (worldObj.provider instanceof WorldProviderSpaceStation) {
// On space stations simply block the bed activation => no explosion
event.setCanceled(true);
return;
}
// Optionally prevent beds from exploding - depends on canRespawnHere() in the WorldProvider interacting with this
EventHandlerGC.bedActivated = true;
if (worldObj.provider.canRespawnHere() && !EventHandlerGC.bedActivated) {
EventHandlerGC.bedActivated = true;
// On planets allow the bed to be used to designate a player spawn point
event.getEntityPlayer().setSpawnChunk(event.getPos(), false, GCCoreUtil.getDimensionID(event.getWorld()));
} else {
EventHandlerGC.bedActivated = false;
}
}
final ItemStack heldStack = event.getEntityPlayer().inventory.getCurrentItem();
final TileEntity tileClicked = worldObj.getTileEntity(event.getPos());
if (!heldStack.isEmpty()) {
if (tileClicked != null && tileClicked instanceof IKeyable) {
if (heldStack.getItem() instanceof IKeyItem) {
if (((IKeyItem) heldStack.getItem()).getTier(heldStack) == -1 || ((IKeyable) tileClicked).getTierOfKeyRequired() == -1 || ((IKeyItem) heldStack.getItem()).getTier(heldStack) == ((IKeyable) tileClicked).getTierOfKeyRequired()) {
event.setCanceled(((IKeyable) tileClicked).onValidKeyActivated(event.getEntityPlayer(), heldStack, event.getFace()));
} else if (!event.getEntityPlayer().isSneaking()) {
event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
}
} else {
event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
}
}
if (heldStack.getItem() instanceof ItemFlintAndSteel || heldStack.getItem() instanceof ItemFireball) {
if (!worldObj.isRemote) {
if (idClicked != Blocks.TNT && OxygenUtil.noAtmosphericCombustion(event.getEntityPlayer().world.provider) && !OxygenUtil.isAABBInBreathableAirBlock(event.getEntityLiving().world, new AxisAlignedBB(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), event.getPos().getX() + 1, event.getPos().getY() + 2, event.getPos().getZ() + 1))) {
event.setCanceled(true);
}
}
}
} else if (tileClicked != null && tileClicked instanceof IKeyable) {
event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EventHandlerGC method onPlayerDeath.
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event) {
if (event.getEntityLiving() instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(event.getEntityPlayer());
if (!event.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
event.getEntityPlayer().captureDrops = true;
for (int i = stats.getExtendedInventory().getSizeInventory() - 1; i >= 0; i--) {
ItemStack stack = stats.getExtendedInventory().getStackInSlot(i);
if (!stack.isEmpty()) {
event.getEntityPlayer().dropItem(stack, true, false);
stats.getExtendedInventory().setInventorySlotContents(i, ItemStack.EMPTY);
}
}
event.getEntityLiving().captureDrops = false;
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class GCPlayerHandler method sendAirRemainingPacket.
protected static void sendAirRemainingPacket(EntityPlayerMP player, GCPlayerStats stats) {
final float f1 = stats.getTankInSlot1().isEmpty() ? 0.0F : stats.getTankInSlot1().getMaxDamage() / 90.0F;
final float f2 = stats.getTankInSlot2().isEmpty() ? 0.0F : stats.getTankInSlot2().getMaxDamage() / 90.0F;
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_AIR_REMAINING, GCCoreUtil.getDimensionID(player.world), new Object[] { MathHelper.floor(stats.getAirRemaining() / f1), MathHelper.floor(stats.getAirRemaining2() / f2), PlayerUtil.getName(player) }), player);
}
Aggregations