net.minecraft.server.world.ServerWorld Java Examples

The following examples show how to use net.minecraft.server.world.ServerWorld. 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: WitchWaterBubbleColumnBlock.java    From the-hallow with MIT License 7 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
	BlockState state2 = world.getBlockState(pos.up());
	if (state2.isAir()) {
		entity.onBubbleColumnSurfaceCollision(state.get(DRAG));
		if (!world.isClient) {
			ServerWorld serverworld = (ServerWorld) world;
			
			for (int i = 0; i < 2; i++) {
				serverworld.spawnParticles(ParticleTypes.SPLASH, (float) pos.getX() + world.random.nextFloat(), pos.getY() + 1, (float) pos.getZ() + world.random.nextFloat(), 1, 0.0D, 0.0D, 0.0D, 1.0D);
				serverworld.spawnParticles(ParticleTypes.BUBBLE, (float) pos.getX() + world.random.nextFloat(), pos.getY() + 1, (float) pos.getZ() + world.random.nextFloat(), 1, 0.0D, 0.01D, 0.0D, 0.2D);
			}
		}
	} else {
		entity.onBubbleColumnCollision(state.get(DRAG));
	}
}
 
Example #2
Source File: GalacticraftCommands.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private static int teleportMultiple(CommandContext<ServerCommandSource> context) {
    try {
        ServerWorld serverWorld = DimensionArgumentType.getDimensionArgument(context, "dimension");
        if (serverWorld == null) {
            context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.dimension").setStyle(Style.EMPTY.withColor(Formatting.RED)));
            return -1;
        }

        Collection<? extends Entity> entities = EntityArgumentType.getEntities(context, "entities");
        entities.forEach((Consumer<Entity>) entity -> {
            entity.changeDimension(serverWorld);
            context.getSource().sendFeedback(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.success.multiple", entities.size(), serverWorld.getRegistryKey().getValue()), true);
        });
    } catch (CommandSyntaxException ignore) {
        context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.entity").setStyle(Style.EMPTY.withColor(Formatting.RED)));
        return -1;
    }
    return -1;
}
 
Example #3
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature<?> structure, boolean computeBox)
{
    ChunkGenerator<?> generator = world.getChunkManager().getChunkGenerator();
    if (!generator.getBiomeSource().hasStructureFeature(structure))
        return null;
    BiomeAccess biomeAccess = world.getBiomeAccess().withSource(generator.getBiomeSource());
    ChunkRandom chunkRandom = new ChunkRandom();
    ChunkPos chunkPos = new ChunkPos(pos);
    Biome biome = biomeAccess.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9));
    if (structure.shouldStartAt(biomeAccess, generator, chunkRandom, chunkPos.x, chunkPos.z, biome))
    {
        if (!computeBox) return StructureStart.DEFAULT;
        StructureManager manager = world.getSaveHandler().getStructureManager();
        StructureStart structureStart3 = structure.getStructureStartFactory().create(structure, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, generator.getSeed());
        structureStart3.initialize(generator, manager, chunkPos.x, chunkPos.z, biome);
        if (!structureStart3.hasChildren()) return null;
        return structureStart3;
    }
    return null;
}
 
Example #4
Source File: EntityValue.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static void updatePosition(Entity e, double x, double y, double z, float yaw, float pitch)
{
    if (
            !Double.isFinite(x) || Double.isNaN(x) ||
            !Double.isFinite(y) || Double.isNaN(y) ||
            !Double.isFinite(z) || Double.isNaN(z) ||
            !Float.isFinite(yaw) || Float.isNaN(yaw) ||
            !Float.isFinite(pitch) || Float.isNaN(pitch)
    )
        return;
    if (e instanceof ServerPlayerEntity)
    {
        // this forces position but doesn't angles for some reason. Need both in the API in the future.
        EnumSet<PlayerPositionLookS2CPacket.Flag> set  = EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class);
        set.add(PlayerPositionLookS2CPacket.Flag.X_ROT);
        set.add(PlayerPositionLookS2CPacket.Flag.Y_ROT);
        ((ServerPlayerEntity)e).networkHandler.teleportRequest(x, y, z, yaw, pitch, set );
    }
    else
    {
        e.refreshPositionAndAngles(x, y, z, yaw, pitch);
        ((ServerWorld) e.getEntityWorld()).getChunkManager().sendToNearbyPlayers(e, new EntityPositionS2CPacket(e));
    }

}
 
Example #5
Source File: FlowerPotBlockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "onUse", at = @At("HEAD"))
private void onActivate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.flowerPotChunkLoading && world_1.getServer() != null && !world_1.isClient)
    {
        ItemStack stack = playerEntity_1.getStackInHand(hand_1);
        Item item = stack.getItem();
        Block block = item instanceof BlockItem ? (Block) CONTENT_TO_POTTED.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR) : Blocks.AIR;
        boolean boolean_1 = block == Blocks.AIR;
        boolean boolean_2 = this.content == Blocks.AIR;
        ServerWorld serverWorld = world_1.getServer().getWorld(world_1.getDimension().getType());

        if (boolean_1 != boolean_2 && (block == Blocks.POTTED_WITHER_ROSE || this.content == Blocks.WITHER_ROSE))
        {
            // System.out.println("Chunk load status = " + boolean_2);
            serverWorld.setChunkForced(blockPos_1.getX() >> 4, blockPos_1.getZ() >> 4, boolean_2);
        }
    }
}
 
Example #6
Source File: GalacticraftCommands.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private static int teleport(CommandContext<ServerCommandSource> context) {
    try {
        ServerWorld serverWorld = DimensionArgumentType.getDimensionArgument(context, "dimension");
        if (serverWorld == null) {
            context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.dimension").setStyle(Style.EMPTY.withColor(Formatting.RED)));
            return -1;
        }

        context.getSource().getPlayer().changeDimension(serverWorld);
        context.getSource().sendFeedback(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.success.single", serverWorld.getRegistryKey().getValue()), true);

    } catch (CommandSyntaxException ignore) {
        context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.entity").setStyle(Style.EMPTY.withColor(Formatting.RED)));
        return -1;
    }
    return -1;
}
 
Example #7
Source File: EntityPlayerMPFake.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayerEntity player)
{
    player.getServer().getPlayerManager().remove(player);
    player.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
    ServerWorld worldIn = server.getWorld(player.dimension);
    ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
    GameProfile gameprofile = player.getGameProfile();
    EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, true);
    server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow);

    playerShadow.setHealth(player.getHealth());
    playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch);
    interactionManagerIn.setGameMode(player.interactionManager.getGameMode());
    ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack());
    playerShadow.stepHeight = 0.6F;
    playerShadow.dataTracker.set(PLAYER_MODEL_PARTS, player.getDataTracker().get(PLAYER_MODEL_PARTS));


    server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.dimension);
    server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow));
    player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow);
    return playerShadow;
}
 
Example #8
Source File: MixinPlayerInteractBlock_NetworkHandler.java    From Galaxy with GNU Affero General Public License v3.0 6 votes vote down vote up
@Inject(method = "onPlayerInteractBlock", at = @At(
    value = "INVOKE",
    target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactBlock(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;"
), cancellable = true)
private void onPlayerInteractBlock(PlayerInteractBlockC2SPacket packet, CallbackInfo info) {
    Main main = Main.Companion.getMain();
    if (main == null) return;
    if (main.getEventManager().emit(new PlayerInteractBlockEvent(packet, player)).getCancel()) {
        info.cancel();
        // Re-sync block & inventory
        ServerWorld world = player.getServerWorld();
        BlockPos blockPos = packet.getBlockHitResult().getBlockPos();
        player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos));
        player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos.offset(packet.getBlockHitResult().getSide())));
        player.openHandledScreen(player.currentScreenHandler);
    }
}
 
Example #9
Source File: ServerWorld_fakePlayersMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Redirect( method = "removePlayer", at  = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;removeEntity(Lnet/minecraft/entity/Entity;)V"
))
private void crashRemovePlayer(ServerWorld serverWorld, Entity entity_1, ServerPlayerEntity serverPlayerEntity_1)
{
    if ( !(ticking && serverPlayerEntity_1 instanceof EntityPlayerMPFake) )
        serverWorld.removeEntity(entity_1);
    else
        getServer().send(new ServerTask(getServer().getTicks(), () ->
        {
            serverWorld.removeEntity(serverPlayerEntity_1);
            serverPlayerEntity_1.onTeleportationDone();
        }));

}
 
Example #10
Source File: SpawnHelperMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Redirect(method = "spawnEntitiesInChunk", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
))
private static boolean spawnEntity(ServerWorld world, Entity entity_1)
{
    if (CarpetSettings.lagFreeSpawning)
        // we used the mob - next time we will create a new one when needed
        ((WorldInterface) world).getPrecookedMobs().remove(entity_1.getType());

    if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
    {
        SpawnReporter.registerSpawn(
                world.dimension.getType(),
                (MobEntity) entity_1,
                entity_1.getType().getCategory(),
                entity_1.getBlockPos());
    }
    if (!SpawnReporter.mock_spawns)
        return world.spawnEntity(entity_1);
    return false;
}
 
Example #11
Source File: StructureFeatureMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos)
{
    ChunkPos chunkpos = new ChunkPos(packedChunkPos);
    StructureStart structurestart;

    Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);

    if (ichunk != null)
    {
        structurestart = ichunk.getStructureStart(this.getName());

        if (structurestart != null && structurestart != StructureStart.DEFAULT)
        {
            return structurestart;
        }
    }
    Biome biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
    StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,generator.getSeed());
    structurestart1.initialize(generator, ((ServerWorld)worldIn).getStructureManager() , chunkpos.x, chunkpos.z, biome_1);
    structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;

    if (structurestart.hasChildren())
    {
        worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart);
    }

    //long2objectmap.put(packedChunkPos, structurestart);
    return structurestart;
}
 
Example #12
Source File: MinecraftServer_tickspeedMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
private boolean runEveryTask() {
    if (super.runTask()) {
        return true;
    } else {
        if (true) { // unconditionally this time
            for(ServerWorld serverlevel : getWorlds()) {
                if (serverlevel.getChunkManager().executeQueuedTasks()) {
                    return true;
                }
            }
        }

        return false;
    }
}
 
Example #13
Source File: BlockValue.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static BlockEntity getBlockEntity(ServerWorld world, BlockPos pos)
{
    if (world.getServer().isOnThread())
        return world.getBlockEntity(pos);
    else
        return world.getWorldChunk(pos).getBlockEntity(pos, WorldChunk.CreationType.IMMEDIATE);
}
 
Example #14
Source File: CarpetSettings.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void changeSpawnSize(int size)
{
    ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
    if (overworld != null) {
        ChunkPos centerChunk = new ChunkPos(new BlockPos(
                overworld.getLevelProperties().getSpawnX(),
                overworld.getLevelProperties().getSpawnY(),
                overworld.getLevelProperties().getSpawnZ()
        ));
        SpawnChunks.changeSpawnChunks(overworld.getChunkManager(), centerChunk, size);
    }
}
 
Example #15
Source File: CarpetEventServer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void onWorldEventFlag(ServerWorld world, BlockPos pos, int flag)
{
    handler.call(
            () -> Arrays.asList(
                    ((c, t) -> new BlockValue(null, world, pos)),
                    ((c, t) -> flag>0?Value.TRUE:Value.FALSE)
            ), () -> CarpetServer.minecraft_server.getCommandSource().withWorld(world)
    );
}
 
Example #16
Source File: CloneCommandMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "execute", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
))
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
{
    if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
}
 
Example #17
Source File: MobAI.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void clearTracking(EntityType etype)
{
    aiTrackers.remove(etype);
    for(ServerWorld world : CarpetServer.minecraft_server.getWorlds() )
    {
        for (Entity e: world.getEntities(etype, Entity::hasCustomName))
        {
            e.setCustomNameVisible(false);
            e.setCustomName(null);
        }
    }
}
 
Example #18
Source File: PerimeterDiagnostics.java    From fabric-carpet with MIT License 5 votes vote down vote up
private PerimeterDiagnostics(ServerWorld server, EntityCategory ctype, MobEntity el)
{
    this.sle = null;
    this.worldServer = server;
    this.ctype = ctype;
    this.el = el;
}
 
Example #19
Source File: ServerWorld_tickMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "tick", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;sendBlockActions()V"
))
private void tickConditionally(ServerWorld serverWorld)
{
    if (TickSpeed.process_entities) sendBlockActions();
}
 
Example #20
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "keepRunning", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/inventory/BasicInventory;getInvSize()I"
))
private int plantWart(BasicInventory basicInventory, ServerWorld serverWorld, VillagerEntity villagerEntity, long l)
{
    if (isFarmingCleric) // fill cancel that for loop by setting length to 0
    {
        for(int i = 0; i < basicInventory.getInvSize(); ++i)
        {
            ItemStack itemStack = basicInventory.getInvStack(i);
            boolean bl = false;
            if (!itemStack.isEmpty())
            {
                if (itemStack.getItem() == Items.NETHER_WART)
                {
                    serverWorld.setBlockState(currentTarget, Blocks.NETHER_WART.getDefaultState(), 3);
                    bl = true;
                }
            }

            if (bl)
            {
                serverWorld.playSound(null,
                        currentTarget.getX(), currentTarget.getY(), this.currentTarget.getZ(),
                        SoundEvents.ITEM_NETHER_WART_PLANT, SoundCategory.BLOCKS, 1.0F, 1.0F);
                itemStack.decrement(1);
                if (itemStack.isEmpty())
                {
                    basicInventory.setInvStack(i, ItemStack.EMPTY);
                }
                break;
            }
        }
        return 0;

    }
    return basicInventory.getInvSize();
}
 
Example #21
Source File: CarpetExpression.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static void forceChunkUpdate(BlockPos pos, ServerWorld world)
{
    Chunk chunk = world.getChunk(pos);
    chunk.setShouldSave(true);
    for (int i = 0; i<16; i++)
    {
        BlockPos section = new BlockPos((pos.getX()>>4 <<4)+8, 16*i, (pos.getZ()>>4 <<4)+8);
        world.getChunkManager().markForUpdate(section);
        world.getChunkManager().markForUpdate(section.east());
        world.getChunkManager().markForUpdate(section.west());
        world.getChunkManager().markForUpdate(section.north());
    }
}
 
Example #22
Source File: MixinPlayerUpdateSign_NetworkHandler.java    From Galaxy with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject(method = "onSignUpdate", at = @At(
    value = "INVOKE",
    target = "Lnet/minecraft/block/entity/SignBlockEntity;isEditable()Z"
), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT)
private void onSignUpdate(UpdateSignC2SPacket packet, CallbackInfo ci, ServerWorld serverWorld, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity, SignBlockEntity signBlockEntity) {
    Main main = Main.Companion.getMain();
    if (main == null) return;
    if (main.getEventManager().emit(new PlayerUpdateSignEvent(packet, player, signBlockEntity)).getCancel()) {
        ci.cancel();

        signBlockEntity.markDirty();
        serverWorld.updateListeners(blockPos, blockState, blockState, 3);
    }
}
 
Example #23
Source File: ParticleDisplay.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void drawParticleLine(ServerPlayerEntity player, Vec3d from, Vec3d to, String main, String accent, int count, double spread)
{
    ParticleEffect accentParticle = getEffect(accent);
    ParticleEffect mainParticle = getEffect(main);

    if (accentParticle != null) ((ServerWorld)player.world).spawnParticles(
            player,
            accentParticle,
            true,
            to.x, to.y, to.z, count,
            spread, spread, spread, 0.0);

    double lineLengthSq = from.squaredDistanceTo(to);
    if (lineLengthSq == 0) return;

    Vec3d incvec = to.subtract(from).normalize();//    multiply(50/sqrt(lineLengthSq));
    int pcount = 0;
    for (Vec3d delta = new Vec3d(0.0,0.0,0.0);
         delta.lengthSquared()<lineLengthSq;
         delta = delta.add(incvec.multiply(player.world.random.nextFloat())))
    {
        ((ServerWorld)player.world).spawnParticles(
                player,
                mainParticle,
                true,
                delta.x+from.x, delta.y+from.y, delta.z+from.z, 1,
                0.0, 0.0, 0.0, 0.0);
    }
}
 
Example #24
Source File: MixinMinecraftServer.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Redirect(method = "createWorlds", at = @At(value = "INVOKE", target = "java/util/Map.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1))
private Object proxyPutWorld(Map<Object, Object> worlds, Object type, Object world) {
	worlds.put(type, world);
	WorldEvents.onWorldLoad((ServerWorld) world);

	return world;
}
 
Example #25
Source File: MixinServerWorld.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "init", cancellable = true, at = @At(value = "INVOKE", target = "net/minecraft/world/gen/chunk/ChunkGenerator.getBiomeSource ()Lnet/minecraft/world/biome/source/BiomeSource;"))
private void hookInitForCreateWorldSpawn(LevelInfo levelInfo, CallbackInfo info) {
	ServerWorld world = (ServerWorld) (Object) this;

	if (WorldEvents.onCreateWorldSpawn(world, levelInfo)) {
		info.cancel();
	}
}
 
Example #26
Source File: ServerPlayerEntityMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "<init>", at = @At(value = "RETURN"))
private void onServerPlayerEntityContructor(
        MinecraftServer minecraftServer_1,
        ServerWorld serverWorld_1,
        GameProfile gameProfile_1,
        ServerPlayerInteractionManager serverPlayerInteractionManager_1,
        CallbackInfo ci)
{
    this.actionPack = new EntityPlayerActionPack((ServerPlayerEntity) (Object) this);
}
 
Example #27
Source File: ServerWorld_scarpetEventMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V"
))
private void onNaturalLightinig(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci,
                                ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
{
    if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
}
 
Example #28
Source File: ChunkSerializerMixin.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "serialize", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;saveToTag(Lnet/minecraft/nbt/CompoundTag;)Z"), to = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/ProtoChunk;getEntities()Ljava/util/List;")), at = @At(value = "JUMP", opcode = Opcodes.GOTO, ordinal = 2), locals = LocalCapture.CAPTURE_FAILHARD)
private static void serializeCapabilities(ServerWorld serverWorld, Chunk chunk, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable, ChunkPos chunkPos, CompoundTag compoundTag, CompoundTag level) {
	CompoundTag tag = ((CapabilityProviderHolder) chunk).serializeCaps();

	if (tag != null) {
		level.put("ForgeCaps", tag);
	}
}
 
Example #29
Source File: ChunkSerializerMixin.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Redirect(method = "deserialize", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk"))
private static WorldChunk newWorldChunk(
		World newWorld, ChunkPos newChunkPos, Biome[] newBiomes, UpgradeData newUpgradeData, TickScheduler<Block> newTickScheduler, TickScheduler<Fluid> newTickScheduler2, long newL, @Nullable ChunkSection[] newChunkSections, @Nullable Consumer<WorldChunk> newConsumer,
		ServerWorld serverWorld, StructureManager structureManager, PointOfInterestStorage pointOfInterestStorage, ChunkPos chunkPos, CompoundTag compoundTag) {
	WorldChunk chunk = new WorldChunk(newWorld, newChunkPos, newBiomes, newUpgradeData, newTickScheduler, newTickScheduler2, newL, newChunkSections, newConsumer);
	CompoundTag level = compoundTag.getCompound("Level");

	if (level.contains("ForgeCaps")) {
		((CapabilityProviderHolder) chunk).deserializeCaps(level.getCompound("ForgeCaps"));
	}

	return chunk;
}
 
Example #30
Source File: WireBlockEntity.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public void tick() {
    if (world instanceof ServerWorld) {
        if (((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos) == null && world.getBlockState(pos).getBlock() instanceof WireBlock && !world.isClient) {
            this.world.getBlockState(pos).onBlockAdded(world, pos, Blocks.AIR.getDefaultState(), false);
        }
    }
}