use of net.minecraftforge.common.util.FakePlayer in project Totemic by TeamTotemic.
the class BlockDrum method playDaMusicu.
public void playDaMusicu(WorldServer world, BlockPos pos, EntityPlayer player, TileDrum tileDrum, boolean isSneaking) {
IBlockState state = world.getBlockState(pos);
if (!isSneaking) {
if (!(player instanceof FakePlayer)) {
tileDrum.canPlay = false;
Totemic.api.music().playMusic(world, pos, player, ModContent.drum);
world.spawnParticle(EnumParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 2, 0.0, 0.0, 0.0, 0.0);
world.notifyBlockUpdate(pos, state, state, 7);
}
} else {
tileDrum.canPlay = false;
Totemic.api.music().playSelector(world, pos, player, ModContent.drum);
world.spawnParticle(EnumParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 2, 0.0, 0.0, 0.0, 0.0);
world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 2, 0.0, 0.0, 0.0, 0.0);
world.notifyBlockUpdate(pos, state, state, 7);
}
TotemUtil.playSound(world, pos, ModSounds.drum, SoundCategory.PLAYERS, 1.0f, 1.0f);
}
use of net.minecraftforge.common.util.FakePlayer in project BuildCraft by BuildCraft.
the class TileEngineCreative method onBlockActivated.
@Override
public boolean onBlockActivated(EntityPlayer player, EnumFacing side) {
if (!getWorld().isRemote) {
Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, pos)) {
powerMode = powerMode.getNext();
energy = 0;
if (!(player instanceof FakePlayer)) {
if (BuildCraftCore.hidePowerNumbers) {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless", LocaleUtil.localize("chat.pipe.power.iron.level." + powerMode.maxPower)));
} else {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode", powerMode.maxPower));
}
}
sendNetworkUpdate();
((IToolWrench) equipped).wrenchUsed(player, pos);
return true;
}
}
return !player.isSneaking();
}
use of net.minecraftforge.common.util.FakePlayer in project BuildCraft by BuildCraft.
the class TemplateBuilder method doPlaceTask.
@Override
protected boolean doPlaceTask(PlaceTask placeTask) {
FakePlayer fakePlayer = BuildCraftAPI.fakePlayerProvider.getFakePlayer((WorldServer) tile.getWorldBC(), tile.getOwner(), tile.getBuilderPos());
fakePlayer.setHeldItem(fakePlayer.getActiveHand(), placeTask.items.get(0));
return TemplateApi.templateRegistry.handle(tile.getWorldBC(), placeTask.pos, fakePlayer, placeTask.items.get(0));
}
use of net.minecraftforge.common.util.FakePlayer in project BuildCraft by BuildCraft.
the class PipeBehaviourStripes method onDrop.
@PipeEventHandler
public void onDrop(PipeEventItem.Drop event) {
if (direction == null) {
return;
}
IPipeHolder holder = pipe.getHolder();
World world = holder.getPipeWorld();
BlockPos pos = holder.getPipePos();
FakePlayer player = BuildCraftAPI.fakePlayerProvider.getFakePlayer((WorldServer) world, holder.getOwner(), pos);
player.inventory.clear();
// set the main hand of the fake player to the stack
player.inventory.setInventorySlotContents(player.inventory.currentItem, event.getStack());
if (PipeApi.stripeRegistry.handleItem(world, pos, direction, event.getStack(), player, this)) {
event.setStack(StackUtil.EMPTY);
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stack = player.inventory.removeStackFromSlot(i);
if (!stack.isEmpty()) {
sendItem(stack, direction);
}
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project BuildCraft by BuildCraft.
the class BlockUtil method destroyBlock.
public static boolean destroyBlock(WorldServer world, BlockPos pos, @Nonnull ItemStack tool, GameProfile owner) {
FakePlayer fakePlayer = getFakePlayerWithTool(world, tool, owner);
BreakEvent breakEvent = new BreakEvent(world, pos, world.getBlockState(pos), fakePlayer);
MinecraftForge.EVENT_BUS.post(breakEvent);
if (breakEvent.isCanceled()) {
return false;
}
world.destroyBlock(pos, true);
return true;
}
Aggregations