use of net.minecraft.world.WorldServer in project MC-Prefab by Brian-Wuest.
the class StructureHandler method onMessage.
@Override
public IMessage onMessage(final StructureTagMessage message, final MessageContext ctx) {
// Or Minecraft.getMinecraft() on the client.
IThreadListener mainThread = (WorldServer) ctx.getServerHandler().player.world;
mainThread.addScheduledTask(new Runnable() {
@Override
public void run() {
// This is server side. Build the structure.
EnumStructureConfiguration structureConfig = message.getStructureConfig();
StructureConfiguration configuration = structureConfig.structureConfig.ReadFromNBTTagCompound(message.getMessageTag());
configuration.BuildStructure(ctx.getServerHandler().player, ctx.getServerHandler().player.world);
}
});
// no response in this case
return null;
}
use of net.minecraft.world.WorldServer in project Galacticraft by micdoodle8.
the class EntityTieredRocket method onUpdate.
@Override
public void onUpdate() {
if (this.getWaitForPlayer()) {
if (this.riddenByEntity != null) {
if (this.ticks >= 40) {
if (!this.worldObj.isRemote) {
Entity e = this.riddenByEntity;
e.mountEntity(null);
e.mountEntity(this);
GCLog.debug("Remounting player in rocket.");
}
this.setWaitForPlayer(false);
this.motionY = -0.5D;
} else {
this.motionX = this.motionY = this.motionZ = 0.0D;
this.riddenByEntity.motionX = this.riddenByEntity.motionY = this.riddenByEntity.motionZ = 0;
}
} else {
this.motionX = this.motionY = this.motionZ = 0.0D;
}
}
super.onUpdate();
if (!this.worldObj.isRemote) {
if (this.launchCooldown > 0) {
this.launchCooldown--;
}
if (this.preGenIterator != null) {
if (this.preGenIterator.hasNext()) {
MinecraftServer mcserver;
if (this.worldObj instanceof WorldServer) {
mcserver = ((WorldServer) this.worldObj).getMinecraftServer();
BlockVec3 coords = this.preGenIterator.next();
World w = mcserver.worldServerForDimension(coords.y);
if (w != null) {
w.getChunkFromChunkCoords(coords.x, coords.z);
// Pregen a second chunk if still on launchpad (low strain on server)
if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal() && this.preGenIterator.hasNext()) {
coords = this.preGenIterator.next();
w = mcserver.worldServerForDimension(coords.y);
w.getChunkFromChunkCoords(coords.x, coords.z);
}
}
}
} else {
this.preGenIterator = null;
EntityTieredRocket.preGenInProgress = false;
}
}
}
if (this.rumble > 0) {
this.rumble--;
} else if (this.rumble < 0) {
this.rumble++;
}
if (this.riddenByEntity != null) {
final double rumbleAmount = this.rumble / (double) (37 - 5 * Math.max(this.getRocketTier(), 5));
this.riddenByEntity.posX += rumbleAmount;
this.riddenByEntity.posZ += rumbleAmount;
}
if (this.launchPhase >= EnumLaunchPhase.IGNITED.ordinal()) {
this.performHurtAnimation();
this.rumble = (float) this.rand.nextInt(3) - 3;
}
if (!this.worldObj.isRemote) {
this.lastLastMotionY = this.lastMotionY;
this.lastMotionY = this.motionY;
}
}
use of net.minecraft.world.WorldServer in project Ceramics by KnightMiner.
the class TileFaucet method reset.
protected void reset() {
isPouring = false;
stopPouring = false;
drained = null;
// invalid direction
direction = EnumFacing.DOWN;
lastRedstoneState = false;
// sync to clients
if (getWorld() != null && !getWorld().isRemote && getWorld() instanceof WorldServer) {
CeramicsNetwork.sendToClients((WorldServer) getWorld(), pos, new FluidUpdatePacket(pos, null));
}
}
use of net.minecraft.world.WorldServer in project Wizardry by TeamWizardry.
the class BlockUtils method breakBlock.
/**
* Tries breaking a block safely and fires an event for it.
*
* @return Whether the block was successfully broken
*/
public static boolean breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nullable IBlockState oldState, @Nullable EntityPlayerMP player, boolean drop) {
if (!world.isBlockLoaded(pos))
return false;
EntityPlayerMP playerMP;
if (player == null) {
playerMP = new FakePlayer((WorldServer) world, breaker);
playerMP.setPosition(pos.getX(), pos.getY(), pos.getZ());
} else
playerMP = player;
if (player != null && !(player instanceof FakePlayer))
if (!hasBreakPermission(world, pos, playerMP))
return false;
if (oldState == null)
oldState = world.getBlockState(pos);
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, oldState, playerMP);
MinecraftForge.EVENT_BUS.post(event);
return !event.isCanceled() && (drop ? world.destroyBlock(pos, true) : world.setBlockToAir(pos));
}
use of net.minecraft.world.WorldServer in project BuildCraft by BuildCraft.
the class BptBuilderBase method isBlockPlaceCanceled.
protected boolean isBlockPlaceCanceled(World world, BlockPos pos, SchematicBlockBase schematic) {
IBlockState state = schematic instanceof SchematicBlock ? ((SchematicBlock) schematic).state : Blocks.STONE.getDefaultState();
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world, pos).get();
BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), Blocks.AIR.getDefaultState(), player);
MinecraftForge.EVENT_BUS.post(placeEvent);
return placeEvent.isCanceled();
}
Aggregations