net.minecraft.world.WorldServer Java Examples

The following examples show how to use net.minecraft.world.WorldServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileEntityPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 7 votes vote down vote up
@Override
public TileEntity createRelocatedTile(BlockPos newPos, ShipTransform transform,
    CoordinateSpaceType coordinateSpaceType) {
    TileEntityPassengerChair relocatedTile = new TileEntityPassengerChair();
    relocatedTile.setWorld(getWorld());
    relocatedTile.setPos(newPos);

    if (chairEntityUUID != null) {
        EntityMountableChair chairEntity = (EntityMountableChair) ((WorldServer) getWorld())
            .getEntityFromUuid(chairEntityUUID);
        if (chairEntity != null) {
            Vec3d newMountPos = transform
                .transform(chairEntity.getMountPos(), TransformType.SUBSPACE_TO_GLOBAL);
            chairEntity.setMountValues(newMountPos, coordinateSpaceType, newPos);
        } else {
            chairEntityUUID = null;
        }
    }

    relocatedTile.chairEntityUUID = this.chairEntityUUID;
    // Move everything to the new tile.
    this.chairEntityUUID = null;
    this.markDirty();
    return relocatedTile;
}
 
Example #2
Source File: TCMazeHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static Map<CellLoc, Short> calculateCellLocs(WorldServer world) {
    ConcurrentHashMap<CellLoc, Short> oldDat = MazeHandler.labyrinth;
    ConcurrentHashMap<CellLoc, Short> bufferOld = new ConcurrentHashMap<CellLoc, Short>(labyrinthCopy);
    MazeHandler.labyrinth = labyrinthCopy;
    int chX = getHighestPossibleRandWH(); //To ensure we're always +x and +z
    int chZ = getHighestPossibleRandWH();
    int w = randWH(world.rand);
    int h = randWH(world.rand);
    while (MazeHandler.mazesInRange(chX, chZ, w, h)) {
        chX++; //We grow the mazes in +x direction!
    }
    MazeThread mt = new MazeThread(chX, chZ, w, h, world.rand.nextLong());
    mt.run();
    Map<CellLoc, Short> locs = calculateDifferences(bufferOld);
    labyrinthCopy = MazeHandler.labyrinth;
    MazeHandler.labyrinth = oldDat;
    return locs;
}
 
Example #3
Source File: InventoryCommandsImplementation.java    From malmo with MIT License 6 votes vote down vote up
@Override
public InventoryChangeMessage onMessage(final InventoryMessage message, MessageContext ctx)
{
    final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world;
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            ItemStack[] changes = null;
            if (message.combine)
                changes = combineSlots(player, message.invA, message.slotA, message.invB, message.slotB, message.containerPos);
            else
                changes = swapSlots(player, message.invA, message.slotA, message.invB, message.slotB, message.containerPos);
            if (changes != null)
                MalmoMod.network.sendTo(new InventoryChangeMessage(changes[0], changes[1]), player);
        }
    });
    return null;
}
 
Example #4
Source File: PacketRequestTE.java    From LookingGlass with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handle(ByteBuf data, EntityPlayer player) {
	if (ModConfigs.disabled) return;
	int dim = data.readInt();
	int xPos = data.readInt();
	int yPos = data.readInt();
	int zPos = data.readInt();

	if (!DimensionManager.isDimensionRegistered(dim)) return;
	WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim);
	if (world == null) return;
	TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
	if (tile != null) {
		//FIXME: This is currently a very "forceful" method of doing this, and not technically guaranteed to produce correct results
		// This would be much better handled by using the getDescriptionPacket method and wrapping that packet in a LookingGlass
		// packet to control delivery timing, allowing for processing the packet while the correct target world is the active world
		// This idea requires that that system be in place, though, so until then this hack will hopefully hold.
		NBTTagCompound tag = new NBTTagCompound();
		tile.writeToNBT(tag);
		ServerPacketDispatcher.getInstance().addPacket(player, PacketTileEntityNBT.createPacket(xPos, yPos, zPos, tag, dim));
	}
}
 
Example #5
Source File: PythonCode.java    From pycode-minecraft with MIT License 6 votes vote down vote up
private void ensureCompiled() {
    if (!this.codeChanged) return;
    FMLLog.fine("Eval my code: %s", this.code);

    // now execute the code
    try {
        PythonEngine.eval(this.code, this.context);
        if (!world.isRemote) {
            ((WorldServer)world).spawnParticle(EnumParticleTypes.CRIT,
                    pos.getX() + .5, pos.getY() + 1, pos.getZ() + .5,
                    20, 0, 0, 0, .5, new int[0]);
        }
    } catch (ScriptException e) {
        failz0r(world, pos, "Error running code, traceback:\n%s", stackTraceToString(e));
    }
    this.codeChanged = false;
}
 
Example #6
Source File: SMapRequestPacket.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(final SMapRequestPacket message, final MessageContext ctx) {
	IThreadListener mainThread = (WorldServer) ctx.getServerHandler().player.world; // or Minecraft.getMinecraft() on the client
	mainThread.addScheduledTask(new Runnable() 
	{
		@Override
		public void run() 
		{
			int j;
			IslandMap map = WorldGen.getInstance().getIslandMap(message.islandX, message.islandZ);
			long seed = ctx.getServerHandler().player.world.getSeed()+Helper.combineCoords(message.islandX, message.islandZ);
			TFC.network.sendTo(new CMapPacket(message.islandX, message.islandZ, seed), ctx.getServerHandler().player);
		}
	});
	return null; // no response in this case
}
 
Example #7
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example #8
Source File: StructureLoader.java    From YUNoMakeGoodMap with Apache License 2.0 6 votes vote down vote up
@Override
public void generate(World world, BlockPos pos)
{
    PlacementSettings settings = new PlacementSettings();
    Template temp = null;
    String suffix = world.provider.getDimensionType().getSuffix();
    String opts = world.getWorldInfo().getGeneratorOptions() + suffix;

    if (!Strings.isNullOrEmpty(opts))
        temp = StructureUtil.loadTemplate(new ResourceLocation(opts), (WorldServer)world, true);
    if (temp == null)
        temp = StructureUtil.loadTemplate(new ResourceLocation("/config/", this.fileName + suffix), (WorldServer)world, !Strings.isNullOrEmpty(suffix));
    if (temp == null)
        return; //If we're not in the overworld, and we don't have a template...

    BlockPos spawn = StructureUtil.findSpawn(temp, settings);
    if (spawn != null)
    {
        pos = pos.subtract(spawn);
        world.setSpawnPoint(pos);
    }

    temp.addBlocksToWorld(world, pos, settings, 0); //Push to world, with no neighbor notifications!
    world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
}
 
Example #9
Source File: CyberwareAPI.java    From Cyberware with MIT License 6 votes vote down vote up
public static void updateData(Entity targetEntity)
{
	if (!targetEntity.worldObj.isRemote)
	{
		WorldServer world = (WorldServer) targetEntity.worldObj;
		
		NBTTagCompound nbt = CyberwareAPI.getCapability(targetEntity).serializeNBT();
		
		if (targetEntity instanceof EntityPlayer)
		{
			PACKET_HANDLER.sendTo(new CyberwareSyncPacket(nbt, targetEntity.getEntityId()), (EntityPlayerMP) targetEntity);
			//System.out.println("Sent data for player " + ((EntityPlayer) targetEntity).getName() + " to that player's client");
		}

		for (EntityPlayer trackingPlayer : world.getEntityTracker().getTrackingPlayers(targetEntity))
		{
			PACKET_HANDLER.sendTo(new CyberwareSyncPacket(nbt, targetEntity.getEntityId()), (EntityPlayerMP) trackingPlayer);
			
			if (targetEntity instanceof EntityPlayer)
			{
				//System.out.println("Sent data for player " + ((EntityPlayer) targetEntity).getName() + " to player " + trackingPlayer.getName());
			}
		}
	}

}
 
Example #10
Source File: BlockUtils.java    From GriefPrevention with MIT License 6 votes vote down vote up
private static void chunkLoadPostProcess(Chunk chunk) {
    if (chunk != null) {
        WorldServer world = (WorldServer) chunk.getWorld();
        world.getChunkProvider().id2ChunkMap.put(ChunkPos.asLong(chunk.x, chunk.z), chunk);

        org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) chunk;
        for (Direction direction : CARDINAL_SET) {
            Vector3i neighborPosition = spongeChunk.getPosition().add(direction.asBlockOffset());
            ChunkProviderBridge spongeChunkProvider = (ChunkProviderBridge) world.getChunkProvider();
            net.minecraft.world.chunk.Chunk neighbor = spongeChunkProvider.bridge$getLoadedChunkWithoutMarkingActive(neighborPosition.getX(), neighborPosition.getZ());
            if (neighbor != null) {
                int neighborIndex = directionToIndex(direction);
                int oppositeNeighborIndex = directionToIndex(direction.getOpposite());
                ((ChunkBridge) spongeChunk).bridge$setNeighborChunk(neighborIndex, neighbor);
                ((ChunkBridge) neighbor).bridge$setNeighborChunk(oppositeNeighborIndex, (net.minecraft.world.chunk.Chunk)(Object) chunk);
            }
        }

        chunk.populate(world.getChunkProvider(), world.getChunkProvider().chunkGenerator);
    }
}
 
Example #11
Source File: StructureRegistry.java    From OpenModsLib with MIT License 6 votes vote down vote up
public Map<String, BlockPos> getNearestStructures(final WorldServer world, final BlockPos pos) {
	final ImmutableMap.Builder<String, BlockPos> result = ImmutableMap.builder();
	visitStructures(world, (generator, structure) -> {
		try {
			BlockPos structPos = generator.getNearestStructurePos(world, structure, pos, true);

			if (structPos != null) {
				if (!Strings.isNullOrEmpty(structure)) result.put(structure, structPos);
			}
		} catch (IndexOutOfBoundsException e) {
			// bug in MC, just ignore
			// hopefully fixed by magic of ASM
		}
	});

	return result.build();
}
 
Example #12
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public final int despawnVanillaAnimals(WorldServer worldObj)
{
    int count = 0;
    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if (!(entity instanceof EntityLiving))
        {
            continue;
        }
        if ((entity instanceof EntityCow || entity instanceof EntitySheep || entity instanceof EntityPig || entity instanceof EntityOcelot || entity instanceof EntityChicken || entity instanceof EntitySquid || entity instanceof EntityWolf))
        {
            count += entityDespawnCheck(worldObj, (EntityLiving) entity);

        }
    }
    return count;
}
 
Example #13
Source File: MessageQuestUpdate.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(final MessageQuestUpdate message, MessageContext ctx) {
	if (ctx.side != Side.SERVER) {
		return null;
	}

	final EntityPlayerMP player = ctx.getServerHandler().player;

	if (player == null) {
		return null;
	}

	final WorldServer worldServer = player.getServerWorld();

	worldServer.addScheduledTask(new Runnable() {
		@Override
		public void run() {
			new Worker(message.action).work(message, player);
		}
	});

	return null;
}
 
Example #14
Source File: GTCommandTeleporter.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
	int oldDimension = player.getEntityWorld().provider.getDimension();
	EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
	MinecraftServer server = player.getEntityWorld().getMinecraftServer();
	WorldServer worldServer = server.getWorld(dimension);
	player.addExperienceLevel(0);
	if (worldServer == null || worldServer.getMinecraftServer() == null) { // Dimension doesn't exist
		throw new IllegalArgumentException("Dimension: " + dimension + " doesn't exist!");
	}
	worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new GTCommandTeleporter(worldServer, x, y, z));
	player.setPositionAndUpdate(x, y, z);
	if (oldDimension == 1) {
		// For some reason teleporting out of the end does weird things.
		player.setPositionAndUpdate(x, y, z);
		worldServer.spawnEntity(player);
		worldServer.updateEntityWithOptionalForce(player, false);
	}
}
 
Example #15
Source File: BackpackDataItems.java    From WearableBackpacks with MIT License 6 votes vote down vote up
public static void generateLoot(ItemStackHandler items, String tableStr, long seed,
                                World world, EntityPlayer player) {
	Random rnd = new Random(seed);
	double maxFullness = (0.6 + rnd.nextDouble() * 0.2);
	int maxOccupiedSlots = (int)Math.ceil(items.getSlots() * maxFullness);
	
	LootTableManager manager = world.getLootTableManager();
	LootTable table = manager.getLootTableFromLocation(new ResourceLocation(tableStr));
	LootContext context = new LootContext(((player != null) ? player.getLuck() : 0),
	                                      (WorldServer)world, manager, player, null, null);
	List<ItemStack> loot = table.generateLootForPools(rnd, context);
	Collections.shuffle(loot);
	
	List<Integer> randomizedSlots = new ArrayList<Integer>(items.getSlots());
	for (int i = 0; i < items.getSlots(); i++) randomizedSlots.add(i);
	Collections.shuffle(randomizedSlots);
	for (int i = 0; (i < maxOccupiedSlots) && (i < loot.size()); i++) {
		ItemStack stack = loot.get(i);
		int slot = randomizedSlots.get(i);
		items.setStackInSlot(slot, stack);
	}
}
 
Example #16
Source File: SpigotCommand.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!testPermission(sender)) return true;

    if (args.length != 1) {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        return false;
    }

    if (args[0].equals("reload")) {
        Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
        Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");

        MinecraftServer console = MinecraftServer.getServerCB();
        org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings"));
        for (WorldServer world : console.worlds) {
            world.spigotConfig.init();
        }
        console.server.reloadCount++;

        Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
    }

    return true;
}
 
Example #17
Source File: RoutePath.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean burnCablesInPath(World world, long voltage, long amperage) {
    for (BlockPos blockPos : path.keySet()) {
        WireProperties wireProperties = path.get(blockPos);
        if (voltage > wireProperties.voltage || amperage > wireProperties.amperage) {
            TileEntity tileEntity = world.getTileEntity(blockPos);
            if (tileEntity instanceof TileEntityCable) {
                world.setBlockToAir(blockPos);
                world.setBlockState(blockPos, Blocks.FIRE.getDefaultState());

                if (!world.isRemote) {
                    ((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_LARGE,
                        blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5,
                        5 + world.rand.nextInt(3), 0.0, 0.0, 0.0, 0.1);
                }
            }
        }
    }
    return true;
}
 
Example #18
Source File: ItemEnderBag.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean targetOutsideOfPlayerRange(ItemStack stack, EntityPlayer player)
{
    TargetData target = TargetData.getTargetFromSelectedModule(stack, ModuleType.TYPE_LINKCRYSTAL);

    if (target == null)
    {
        return true;
    }

    // We allow a max range of 64 blocks, to hopefully be on the safer side
    //return target.dimension != player.dimension || player.getDistanceSq(target.posX, target.posY, target.posZ) >= 4096.0d;

    WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(target.dimension);

    if ((player instanceof EntityPlayerMP) == false || world == null ||
         world.getPlayerChunkMap().isPlayerWatchingChunk((EntityPlayerMP) player, target.pos.getX() >> 4, target.pos.getZ() >> 4) == false)
    {
        return true;
    }

    return false;
}
 
Example #19
Source File: ItemRemote.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate(ItemStack remote, World worl, Entity entity, int slot, boolean holdingItem){
    if(!worl.isRemote) {
        NBTTagCompound tag = remote.getTagCompound();
        if(tag != null) {
            if(tag.hasKey("securityX")) {
                int x = tag.getInteger("securityX");
                int y = tag.getInteger("securityY");
                int z = tag.getInteger("securityZ");
                int dimensionId = tag.getInteger("securityDimension");
                WorldServer world = null;
                for(WorldServer w : MinecraftServer.getServer().worldServers) {
                    if(w.provider.dimensionId == dimensionId) {
                        world = w;
                        break;
                    }
                }
                if(world != null) {
                    TileEntity te = world.getTileEntity(x, y, z);
                    if(!(te instanceof TileEntitySecurityStation)) {
                        tag.removeTag("securityX");
                        tag.removeTag("securityY");
                        tag.removeTag("securityZ");
                        tag.removeTag("securityDimension");
                    }
                }
            }
        }
    }
}
 
Example #20
Source File: ClaimedChunkCacheController.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public void injectChunkIntoWorld(Chunk chunk, int x, int z, boolean putInId2ChunkMap) {
    VSChunkClaim chunkClaim = parent.getOwnedChunks();
    chunk.generateSkylightMap();
    chunk.checkLight();

    // Make sure this chunk knows we own it.
    ((IPhysicsChunk) chunk).setParentPhysicsObject(Optional.of(this.parent));

    ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
    chunk.dirty = true;
    claimedChunks[x - chunkClaim.minX()][z - chunkClaim.minZ()] = chunk;

    if (putInId2ChunkMap) {
        provider.loadedChunks.put(ChunkPos.asLong(x, z), chunk);
    }

    chunk.onLoad();
    // We need to set these otherwise certain events like Sponge's PhaseTracker will refuse to work properly with ships!
    chunk.setTerrainPopulated(true);
    chunk.setLightPopulated(true);
    // Inject the entry into the player chunk map.
    // Sanity check first
    if (!((WorldServer) world).isCallingFromMinecraftThread()) {
        throw new IllegalThreadStateException("We cannot call this crap from another thread!");
    }
    PlayerChunkMap map = ((WorldServer) world).getPlayerChunkMap();
    PlayerChunkMapEntry entry = map.getOrCreateEntry(x, z);
    entry.sentToPlayers = true;
    entry.players = parent.getWatchingPlayers();
}
 
Example #21
Source File: BlockUtils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static EntityPlayerMP makeBreaker(@Nonnull World world, @Nonnull BlockPos pos, @Nullable Entity entity) {
	if (entity instanceof EntityPlayerMP) {
		return (EntityPlayerMP) entity;
	}
	EntityPlayerMP bro = FakePlayerFactory.get((WorldServer) world, BREAKER);
	bro.moveToBlockPosAndAngles(pos, 0, -90);
	return bro;
}
 
Example #22
Source File: TileAdditionalEldritchPortal.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void informSessionStart(EntityPlayer player) {
    if(trackedPortalActivity.containsKey(player)) {
        ExtendedChunkCoordinates tileCoords = trackedPortalActivity.get(player);
        trackedPortalActivity.remove(player);
        if(tileCoords != null) {
            ChunkCoordinates cc = tileCoords.coordinates;
            WorldServer ws = MinecraftServer.getServer().worldServerForDimension(tileCoords.dimId);
            ws.removeTileEntity(cc.posX, cc.posY, cc.posZ);
            ws.setBlockToAir(cc.posX, cc.posY, cc.posZ);
            ws.markBlockForUpdate(cc.posX, cc.posY, cc.posZ);
        }
    }
}
 
Example #23
Source File: PacketRequestChunk.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle(ByteBuf data, EntityPlayer player) {
	if (ModConfigs.disabled) return;
	int dim = data.readInt();
	int xPos = data.readInt();
	int yPos = data.readInt();
	int zPos = data.readInt();

	if (!DimensionManager.isDimensionRegistered(dim)) return;
	WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim);
	if (world == null) return;
	Chunk chunk = world.getChunkFromChunkCoords(xPos, zPos);
	if (!chunk.isChunkLoaded) chunk = world.getChunkProvider().loadChunk(xPos, zPos);
	ServerPacketDispatcher.getInstance().addPacket(player, PacketChunkInfo.createPacket(chunk, true, yPos, dim));
}
 
Example #24
Source File: NEIServerUtils.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void toggleRaining(World world, boolean notify) {
    boolean raining = !world.isRaining();
    if (!raining)//turn off
        ((WorldServer) world).provider.resetRainAndThunder();
    else
        world.getWorldInfo().setRaining(!isRaining(world));

    if (notify)
        ServerUtils.sendChatToAll(new ChatComponentTranslation("nei.chat.rain." + (raining ? "on" : "off")));
}
 
Example #25
Source File: RoofGen.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public RoofGen(WorldServer world, BlockPos pos, EnumFacing actualFacing,
               String material, int aWidth, int aDepth, ArgParser spec) throws BlockTypeError {
    this.world = world;
    this.stair = this.getRoofStair(material);
    if (this.stair == null) {
        // not a stair material so go with just blocks
        this.stair = this.filler = this.slab = PyRegistry.getBlockVariant(spec, pos, actualFacing, world);
    } else {
        this.filler = this.getRoofFiller(material);
        this.slab = this.getSlabBlock(material);
    }
    this.north_south = actualFacing == EnumFacing.NORTH || actualFacing == EnumFacing.SOUTH;
    this.fill = spec.getBoolean("fill", true);

    // alter pos, width and depth based on orientation so that the
    // code which always generates in the EAST facing will work
    switch (actualFacing) {
        case EAST:
            this.width = aWidth;
            this.depth = aDepth;
            this.pos = pos.add(1, 0, 0);
            break;
        case WEST:
            this.width = aWidth;
            this.depth = aDepth;
            this.pos = pos.add(-aDepth, 0, -(aWidth-1));
            break;
        case NORTH:
            this.width = aDepth;
            this.depth = aWidth;
            this.pos = pos.add(0, 0, -aDepth);
            break;
        case SOUTH:
            this.width = aDepth;
            this.depth = aWidth;
            this.pos = pos.add(-(aWidth-1), 0, 1);
            break;
    }
}
 
Example #26
Source File: PythonCode.java    From pycode-minecraft with MIT License 5 votes vote down vote up
static public void failz0r(World world, BlockPos pos, String fmt, Object... args) {
    if (world.isRemote) return;
    ((WorldServer)world).spawnParticle(EnumParticleTypes.SPELL,
            pos.getX() + .5, pos.getY() + 1, pos.getZ() + .5,
            20, 0, 0, 0, .5, new int[0]);
    FMLLog.severe(fmt, args);
}
 
Example #27
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public final int despawnMob(WorldServer worldObj, Class... classList)
{
    List<Class> myList = new ArrayList();
    for (Class element : classList)
    {
        myList.add(element);
    }
    return despawnMob(worldObj, myList);
}
 
Example #28
Source File: TileEntityDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nonnull
private FakePlayer getPlayer()
{
    if (this.fakePlayer == null)
    {
        int dim = this.getWorld().provider.getDimension();

        this.fakePlayer = FakePlayerFactory.get((WorldServer) this.getWorld(),
                new GameProfile(new UUID(dim, dim), Reference.MOD_ID + ":drawbridge"));
    }

    return this.fakePlayer;
}
 
Example #29
Source File: PhysicsObject.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
/**
 * Generates the new chunks
 */
public TickSyncCompletableFuture<Void> assembleShipAsOrderedByPlayer(EntityPlayer player) {
    if (world().isRemote) {
        throw new IllegalStateException("This method cannot be invoked on client side!");
    }
    if (!(world() instanceof WorldServer)) {
        throw new IllegalStateException("The world " + world() + " wasn't an instance of WorldServer");
    }

    BlockPos centerInWorld = new BlockPos(getWrapperEntity().posX,
        getWrapperEntity().posY, getWrapperEntity().posZ);

    // The thread the tick sync will execute on.
    IThreadListener worldServerThread = (WorldServer) world();

    return TickSyncCompletableFuture
        .supplyAsync(() -> DetectorManager.getDetectorFor(getDetectorID(), centerInWorld, world(),
            VSConfig.maxShipSize + 1, true))
        .thenAcceptTickSync(detector -> {
            if (detector.foundSet.size() > VSConfig.maxShipSize || detector.cleanHouse) {
                System.err.println("Ship too big or bedrock detected!");
                if (player != null) {
                    player.sendMessage(new TextComponentString(
                        "Ship construction canceled because its exceeding the ship size limit; "
                            +
                            "or because it's attached to bedrock. " +
                            "Raise it with /physsettings maxshipsize [number]"));
                }
                getWrapperEntity().setDead();
                return;
            }
            assembleShip(player, detector, centerInWorld);

            markFullyLoaded();
        }, worldServerThread);
}
 
Example #30
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public final int despawnMob(WorldServer worldObj, List<Class> classList)
{
    int count = 0;
    if (classList == null)
    {
        classList = vanillaClassList;
    }

    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if (!(entity instanceof EntityLiving))
        {
            continue;
        }
        for (Iterator iterator = classList.iterator(); iterator.hasNext();)
        {
            if (iterator != null)
            {
                Class class2 = (Class) iterator.next();
                if (class2 == entity.getClass())
                {
                    count += entityDespawnCheck(worldObj, (EntityLiving) entity);
                }
            }
        }

    }
    return count;
}