use of net.minecraft.entity.player.PlayerInventory in project BluePower by Qmunity.
the class ContainerGhosts method clickedPhantom.
/**
* This method is copied from the BuildCraft code, which can be found here: https://github.com/BuildCraft/BuildCraft
* @author CovertJaguar <http://www.railcraft.info>
*/
private ItemStack clickedPhantom(Slot slot, int dragType, ClickType clickTypeIn, PlayerEntity player) {
ItemStack stack = ItemStack.EMPTY;
if (clickTypeIn.ordinal() == 2) {
if (((IPhantomSlot) slot).canAdjust()) {
slot.set(ItemStack.EMPTY);
}
} else if (clickTypeIn.ordinal() == 0 || clickTypeIn.ordinal() == 1) {
PlayerInventory playerInv = player.inventory;
slot.setChanged();
ItemStack stackSlot = slot.getItem();
ItemStack stackHeld = playerInv.getCarried();
if (stackSlot != ItemStack.EMPTY) {
stack = stackSlot.copy();
}
if (stackSlot == ItemStack.EMPTY) {
if (stackHeld != ItemStack.EMPTY && slot.mayPlace(stackHeld)) {
fillPhantomSlot(slot, stackHeld, clickTypeIn.ordinal(), dragType);
}
} else if (stackHeld == ItemStack.EMPTY) {
adjustPhantomSlot(slot, clickTypeIn.ordinal(), dragType);
slot.onQuickCraft(stack, playerInv.getCarried());
} else if (slot.mayPlace(stackHeld)) {
if (canStacksMerge(stackSlot, stackHeld)) {
adjustPhantomSlot(slot, clickTypeIn.ordinal(), dragType);
} else {
fillPhantomSlot(slot, stackHeld, clickTypeIn.ordinal(), dragType);
}
}
}
return stack;
}
use of net.minecraft.entity.player.PlayerInventory in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerRespawn.
@SubscribeEvent
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
World world = event.getPlayer().getEntityWorld();
PlayerEntity player = event.getPlayer();
PlayerInventory playerInventory = player.inventory;
if (!world.isRemote) {
ItemStack mirrorStack = ItemStack.EMPTY;
for (int i = 0; i < playerInventory.getSizeInventory(); i++) {
ItemStack stack = playerInventory.getStackInSlot(i);
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
mirrorStack = stack;
break;
}
}
if (!mirrorStack.isEmpty()) {
if (mirrorStack.getDamage() < mirrorStack.getMaxDamage() - 1) {
CompoundNBT compound = NBTHelper.ensureTagExists(mirrorStack);
if (compound.contains("SpawnDimension") && compound.contains("SpawnPoint")) {
DimensionType spawnDimension = DimensionType.byName(new ResourceLocation(compound.getString("SpawnDimension")));
if (spawnDimension != null && player.dimension != spawnDimension) {
MinecraftServer server = world.getServer();
if (server != null) {
BlockPos spawnPoint = NBTUtil.readBlockPos(compound.getCompound("SpawnPoint"));
((ServerPlayerEntity) player).teleport(server.getWorld(spawnDimension), spawnPoint.getX() + 0.5D, spawnPoint.getY(), spawnPoint.getZ() + 0.5D, player.rotationYaw, player.rotationPitch);
}
}
}
}
}
}
}
Aggregations