use of net.minecraftforge.common.util.FakePlayer in project Armourers-Workshop by RiskyKen.
the class EquipmentWardrobeHandler method onRender.
@SubscribeEvent(priority = EventPriority.HIGH)
public void onRender(RenderPlayerEvent.SetArmorModel event) {
int slot = -event.slot + 3;
if (slot > 3) {
return;
}
EntityPlayer player = event.entityPlayer;
if (player instanceof MannequinFakePlayer) {
return;
}
if (player.getGameProfile() == null) {
return;
}
if (player instanceof FakePlayer) {
return;
}
int result = -1;
// Hide the armour if it had been skinned.
ItemStack stack = player.getCurrentArmor(event.slot);
if (SkinNBTHelper.stackHasSkinData(stack)) {
result = -2;
}
// Hide the armour if the player has turned it off.
PlayerPointer playerPointer = new PlayerPointer(player);
if (equipmentWardrobeMap.containsKey(playerPointer)) {
EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
if (ewd.armourOverride.get(slot)) {
result = -2;
}
}
event.result = result;
}
use of net.minecraftforge.common.util.FakePlayer in project Armourers-Workshop by RiskyKen.
the class EquipmentWardrobeHandler method onRender.
@SubscribeEvent
public void onRender(RenderPlayerEvent.Pre event) {
EntityPlayer player = event.entityPlayer;
if (player instanceof MannequinFakePlayer) {
return;
}
if (player.getGameProfile() == null) {
return;
}
if (player instanceof FakePlayer) {
return;
}
// Hide the head overlay if the player has turned it off.
PlayerPointer playerPointer = new PlayerPointer(player);
RenderPlayer renderer = event.renderer;
if (equipmentWardrobeMap.containsKey(playerPointer)) {
EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
renderer.modelBipedMain.bipedHeadwear.isHidden = ewd.headOverlay;
if (!ewd.headOverlay) {
if (SkinModelRenderer.INSTANCE.playerHasCustomHead(player)) {
renderer.modelBipedMain.bipedHeadwear.isHidden = true;
}
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project BiomesOPlenty by Glitchfiend.
the class BlockBOPPlant method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
switch((BOPPlants) state.getValue(this.variantProperty)) {
case BERRYBUSH:
// an activated berry bush turns into a regular bush and drops a berry
worldIn.setBlockState(pos, paging.getVariantState(BOPPlants.BUSH));
EntityItem berries = new EntityItem(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), new ItemStack(BOPItems.berries));
if (!worldIn.isRemote) {
worldIn.spawnEntity(berries);
if (!(playerIn instanceof FakePlayer)) {
berries.onCollideWithPlayer(playerIn);
}
}
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
use of net.minecraftforge.common.util.FakePlayer in project BluePower by Qmunity.
the class TileDeployer method redstoneChanged.
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
if (!level.isClientSide && newValue) {
sendUpdatePacket();
FakePlayer player = FakePlayerFactory.get((ServerWorld) level, FAKE_PLAYER_PROFILE);
for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = inventory.get(i);
player.inventory.setItem(i, stack);
}
rightClick(player, 9);
for (int i = 0; i < inventory.size(); i++) {
ItemStack stack = player.inventory.getItem(i);
if (stack.isEmpty() || stack.getCount() <= 0) {
inventory.set(i, ItemStack.EMPTY);
} else {
inventory.set(i, stack);
}
player.inventory.setItem(i, ItemStack.EMPTY);
}
for (int i = 0; i < player.inventory.getContainerSize(); i++) {
ItemStack stack = player.inventory.getItem(i);
if (!stack.isEmpty() && stack.getCount() > 0) {
ItemStack remainder = IOHelper.insert(this, stack, getFacingDirection().getOpposite(), false);
if (!remainder.isEmpty()) {
level.addFreshEntity(new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5, remainder));
}
player.inventory.setItem(i, ItemStack.EMPTY);
}
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project BloodMagic by WayofTime.
the class CheatyItem method onItemRightClick.
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
World world = par3EntityPlayer.worldObj;
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer instanceof FakePlayer) {
return par1ItemStack;
}
if (world != null) {
double posX = par3EntityPlayer.posX;
double posY = par3EntityPlayer.posY;
double posZ = par3EntityPlayer.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
}
if (par3EntityPlayer.worldObj.isRemote) {
return par1ItemStack;
}
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
if (itemTag == null || itemTag.getString("ownerName").equals("")) {
return par1ItemStack;
}
if (par3EntityPlayer.isSneaking()) {
SoulNetworkHandler.setCurrentEssence(itemTag.getString("ownerName"), 0);
} else {
SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 1000000, Integer.MAX_VALUE);
}
return par1ItemStack;
}
Aggregations