use of net.minecraft.entity.player.EntityPlayerMP in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method doRayTrace.
public RaytraceResult doRayTrace(World world, int x, int y, int z, EntityPlayer player) {
double reachDistance = 5;
if (player instanceof EntityPlayerMP) {
reachDistance = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
}
double eyeHeight = world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight();
Vec3 lookVec = player.getLookVec();
Vec3 origin = Vec3.createVectorHelper(player.posX, player.posY + eyeHeight, player.posZ);
Vec3 direction = origin.addVector(lookVec.xCoord * reachDistance, lookVec.yCoord * reachDistance, lookVec.zCoord * reachDistance);
return doRayTrace(world, x, y, z, origin, direction);
}
use of net.minecraft.entity.player.EntityPlayerMP in project LogisticsPipes by RS485.
the class DummyContainer method detectAndSendChanges.
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
for (int i = 0; i < inventorySlots.size(); ++i) {
if (inventorySlots.get(i) instanceof IFuzzySlot) {
IFuzzySlot fuzzySlot = (IFuzzySlot) inventorySlots.get(i);
BitSet set = inventoryFuzzySlotsContent.get(i);
if (set == null) {
set = fuzzySlot.getFuzzyFlags().getBitSet();
MainProxy.sendToPlayerList(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(set), crafters);
inventoryFuzzySlotsContent.set(i, set);
} else {
BitSet setB = fuzzySlot.getFuzzyFlags().getBitSet();
if (!set.equals(setB)) {
MainProxy.sendToPlayerList(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(setB), crafters);
inventoryFuzzySlotsContent.set(i, setB);
}
}
}
ItemStack itemstack = ((Slot) inventorySlots.get(i)).getStack();
ItemStack itemstack1 = (ItemStack) inventoryItemStacks.get(i);
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) {
itemstack1 = itemstack == null ? null : itemstack.copy();
inventoryItemStacks.set(i, itemstack1);
for (Object crafter : crafters) {
boolean revert = false;
if (overrideMCAntiSend && crafter instanceof EntityPlayerMP && ((EntityPlayerMP) crafter).isChangingQuantityOnly) {
((EntityPlayerMP) crafter).isChangingQuantityOnly = false;
revert = true;
}
((ICrafting) crafter).sendSlotContents(this, i, itemstack1);
if (revert) {
((EntityPlayerMP) crafter).isChangingQuantityOnly = true;
}
}
}
}
overrideMCAntiSend = false;
}
use of net.minecraft.entity.player.EntityPlayerMP in project BetterStorage by copygirl.
the class ChristmasEventHandler method onPlayerDeath.
@SubscribeEvent
public void onPlayerDeath(LivingDeathEvent event) {
if (!(event.entity instanceof EntityPlayerMP))
return;
EntityPlayer player = (EntityPlayer) event.entity;
BetterChristmasProperties properties = EntityUtils.getProperties(player, BetterChristmasProperties.class);
NBTTagCompound entityData = player.getEntityData();
NBTTagCompound persistent = entityData.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
entityData.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistent);
NBTTagCompound propertiesCompound = new NBTTagCompound();
properties.saveNBTData(propertiesCompound);
persistent.setTag(BetterChristmasProperties.identifier, propertiesCompound);
}
use of net.minecraft.entity.player.EntityPlayerMP in project BetterStorage by copygirl.
the class ItemBackpack method onPlaceBackpack.
/** Places an equipped backpack when the player right clicks
* on the ground while sneaking and holding nothing. */
public static boolean onPlaceBackpack(EntityPlayer player, int x, int y, int z, int side) {
if (player.getCurrentEquippedItem() != null || !player.isSneaking())
return false;
ItemStack backpack = ItemBackpack.getBackpack(player);
if (backpack == null)
return false;
boolean success = false;
if (!ItemBackpack.isBackpackOpen(player)) {
// Try to place the backpack as if it was being held and used by the player.
success = backpack.getItem().onItemUse(backpack, player, player.worldObj, x, y, z, side, 0, 0, 0);
if (backpack.stackSize <= 0) {
ItemBackpack.setBackpack(player, null, null);
backpack = null;
}
}
// Make sure the client has the same information as the server. It does not sync when backpackChestplate is disabled because there are no changes to the slot in that case.
if (!player.worldObj.isRemote && success && player instanceof EntityPlayerMP && BetterStorage.globalConfig.getBoolean(GlobalConfig.backpackChestplate)) {
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S2FPacketSetSlot(0, 6, backpack));
}
if (success)
player.swingItem();
return success;
}
use of net.minecraft.entity.player.EntityPlayerMP in project BetterStorage by copygirl.
the class BackpackHandler method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
if (event.entity.worldObj.isRemote || !(event.entity instanceof EntityPlayerMP) || !(event.target instanceof EntityLivingBase) || (((EntityPlayerMP) event.entity).playerNetServerHandler == null) || ((event.target instanceof EntityPlayer) && !BetterStorage.globalConfig.getBoolean(GlobalConfig.enableBackpackInteraction)))
return;
EntityPlayerMP player = (EntityPlayerMP) event.entity;
EntityLivingBase target = (EntityLivingBase) event.target;
if (ItemBackpack.openBackpack(player, target))
player.swingItem();
}
Aggregations