This commit is contained in:
gnembon committed 2019-08-28 20:23:32 -03:00
1 parent 8a956fa9bc
commit 628a350ea1
23 files changed
+82 -83

No files matched your search

@@ -1,12 +1,12 @@
package carpet.fakes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
public interface StructureFeatureInterface
{
public boolean plopAnywhere(IWorld world, BlockPos pos);
public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
public boolean plopAnywhere(ServerWorld world, BlockPos pos);
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
}
@@ -1,7 +1,6 @@
package carpet.helpers;
import carpet.fakes.ServerPlayerEntityInterface;
import carpet.mixins.PlayerActionC2SPacketMixin;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
@@ -13,11 +12,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.*;
import java.util.List;
import java.util.Map;
@@ -281,7 +276,7 @@ public class EntityPlayerActionPack
BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getSide();
if (player.method_21701(player.world, pos, player.interactionManager.getGameMode())) return false;
if (ap.currentBlock != null && player.world.isAir(ap.currentBlock))
if (ap.currentBlock != null && player.world.getBlockState(ap.currentBlock).isAir())
{
ap.currentBlock = null;
return false;
@@ -3,6 +3,7 @@ package carpet.helpers;
import carpet.settings.CarpetSettings;
import carpet.fakes.StructureFeatureInterface;
import net.minecraft.block.Blocks;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
@@ -41,7 +42,7 @@ public class FeatureGenerator
@FunctionalInterface
private interface Thing
{
Boolean plop(World world, BlockPos pos);
Boolean plop(ServerWorld world, BlockPos pos);
}
private static Thing simplePlop(Feature<DefaultFeatureConfig> feature)
{
@@ -51,7 +52,7 @@ public class FeatureGenerator
{
return (w, p) -> {
CarpetSettings.skipGenerationChecks=true;
boolean res = feature.generate(w, w.getChunkManager().getChunkGenerator(), w.random, p, config);
boolean res = feature.generate(w, w.method_14178().getChunkGenerator(), w.random, p, config);
CarpetSettings.skipGenerationChecks=false;
return res;
};
@@ -61,7 +62,7 @@ public class FeatureGenerator
private static Thing spawnCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome)
{
return (w, p) -> {
ChunkGenerator chunkgen = new OverworldChunkGenerator(w, w.getChunkManager().getChunkGenerator().getBiomeSource(), new OverworldChunkGeneratorConfig()) // BiomeSourceType.VANILLA_LAYERED.applyConfig((BiomeSourceType.VANILLA_LAYERED.getConfig())), ChunkGeneratorType.SURFACE.createSettings())
ChunkGenerator chunkgen = new OverworldChunkGenerator(w, w.method_14178().getChunkGenerator().getBiomeSource(), new OverworldChunkGeneratorConfig()) // BiomeSourceType.VANILLA_LAYERED.applyConfig((BiomeSourceType.VANILLA_LAYERED.getConfig())), ChunkGeneratorType.SURFACE.createSettings())
{
@Override
public <C extends FeatureConfig> C getStructureConfig(Biome biome_1, StructureFeature<C> structureFeature_1)
@@ -72,7 +73,7 @@ public class FeatureGenerator
@Override
public BiomeSource getBiomeSource()
{
return new VanillaLayeredBiomeSource(new VanillaLayeredBiomeSourceConfig().setLevelProperties(w.getLevelProperties()))
return new VanillaLayeredBiomeSource(new VanillaLayeredBiomeSourceConfig(w.getLevelProperties()))
{
@Override
public Biome getBiome(int i, int j)
@@ -88,7 +89,7 @@ public class FeatureGenerator
};
}
public static Boolean spawn(String name, World world, BlockPos pos)
public static Boolean spawn(String name, ServerWorld world, BlockPos pos)
{
if (featureMap.containsKey(name))
return featureMap.get(name).plop(world, pos);
@@ -41,7 +41,7 @@ public abstract class BlockEntityRenderDispatcher_movableTEMixin implements Bloc
this.cameraEntity.getPos().z - zOffset) < blockEntity_1.getSquaredRenderDistance())
{
GuiLighting.enable();
int i = this.world.getLightmapIndex(blockEntity_1.getPos(), 0);
int i = this.world.method_22337(blockEntity_1.getPos());
int j = i % 65536;
int k = i / 65536;
RenderSystem.glMultiTexCoord2f(GL20.GL_TEXTURE1, (float) j, (float) k);
@@ -13,10 +13,10 @@ public class BuriedTreasureGeneratorPieceMixin
{
@Redirect(method = "generate", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
{
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
}
}
@@ -5,6 +5,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CarpetBlock;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(CarpetBlock.class)
@@ -21,7 +22,7 @@ public abstract class CarpetBlockMixin extends Block
BlockState state = super.getPlacementState(context);
if (context.getPlayer() != null && !context.getWorld().isClient)
{
WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), context.getWorld());
WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld());
}
return state;
}
@@ -13,10 +13,10 @@ public class FossilFeatureMixin
{
@Redirect(method = "method_13236", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
{
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
}
}
@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.settings.CarpetSettings;
import net.minecraft.class_4538;
import net.minecraft.structure.processor.GravityStructureProcessor;
import net.minecraft.world.Heightmap;
import net.minecraft.world.ViewableWorld;
@@ -13,10 +14,10 @@ public class GravityStructureProcessorMixin
{
@Redirect(method = "process", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/ViewableWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/class_4538;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(ViewableWorld viewableWorld, Heightmap.Type var1, int var2, int var3)
private int getTop(class_4538 class_4538, Heightmap.Type var1, int var2, int var3)
{
return viewableWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:var1, var2, var3);
return class_4538.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:var1, var2, var3);
}
}
@@ -13,10 +13,10 @@ public class IglooGeneratorPieceMixin
{
@Redirect(method = "generate", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
{
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
}
}
@@ -13,10 +13,10 @@ public class OceanRuinGeneratorPieceMixin
{
@Redirect(method = "generate", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
{
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
}
}
@@ -111,7 +111,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
else
blockState_2 = Block.getRenderingState(this.pushedBlock, this.world, this.pos);
((WorldInterface) (this.world)).setBlockStateWithBlockEntity(this.pos, blockState_2, this.carriedBlockEntity, 3);
this.world.breakBlock(this.pos, true);
this.world.breakBlock(this.pos, true, null);
}
}
@@ -1,12 +1,12 @@
package carpet.mixins;
import carpet.settings.CarpetSettings;
import carpet.helpers.BlockSaplingHelper;
import carpet.settings.CarpetSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SaplingBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biomes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -19,13 +19,13 @@ import java.util.Random;
public abstract class SaplingBlockMixin
{
@Inject(method = "generate", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"),
target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"),
cancellable = true)
private void onGenerate(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
private void onGenerate(ServerWorld serverWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
{
if(CarpetSettings.desertShrubs && iWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(iWorld_1, blockPos_1))
if(CarpetSettings.desertShrubs && serverWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
{
iWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3);
serverWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3);
ci.cancel();
}
}
@@ -7,7 +7,6 @@ import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.SpawnHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.level.LevelProperties;
@@ -77,10 +76,10 @@ public abstract class ServerChunkManagerMixin
@Redirect(method = "method_20801", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V"
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V"
))
// inject our repeat of spawns if more spawn ticks per tick are chosen.
private void spawnMultipleTimes(EntityCategory entityCategory_1, World world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
private void spawnMultipleTimes(EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
{
for (int i = 0; i < SpawnReporter.spawn_tries.get(entityCategory_1); i++)
{
@@ -17,13 +17,13 @@ public class ShipwreckGeneratorPieceMixin
@Redirect(method = "generate", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
{
if (grounded)
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
else
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
}
}
@@ -1,7 +1,7 @@
package carpet.mixins;
import carpet.settings.CarpetSettings;
import carpet.fakes.WorldInterface;
import carpet.settings.CarpetSettings;
import carpet.utils.SpawnReporter;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
@@ -9,6 +9,7 @@ import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
@@ -19,9 +20,7 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
@@ -33,9 +32,9 @@ public class SpawnHelperMixin
@Redirect(method = "spawnEntitiesInChunk", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;doesNotCollide(Lnet/minecraft/util/math/Box;)Z"
target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z"
))
private static boolean doesNotCollide(World world, Box bb)
private static boolean doesNotCollide(ServerWorld world, Box bb)
{
//.doesNotCollide is VERY expensive. On the other side - most worlds are not made of trapdoors in
// various configurations, but solid and 'passable' blocks, like air, water grass, etc.
@@ -88,9 +87,9 @@ public class SpawnHelperMixin
@Redirect(method = "spawnEntitiesInChunk", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
))
private static boolean spawnEntity(World world, Entity entity_1)
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
@@ -114,7 +113,7 @@ public class SpawnHelperMixin
target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D"
))
private static double getSqDistanceTo(PlayerEntity playerEntity, double double_1, double double_2, double double_3,
EntityCategory entityCategory_1, World world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
{
double distanceTo = playerEntity.squaredDistanceTo(double_1, double_2, double_3);
if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory_1 != EntityCategory.CREATURE)
@@ -32,11 +32,12 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
@Override
public boolean plopAnywhere(IWorld world, BlockPos pos)
public boolean plopAnywhere(ServerWorld world, BlockPos pos)
{
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator());
return plopAnywhere(world, pos, world.method_14178().getChunkGenerator());
}
public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator)
@Override
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator)
{
if (world.isClient())
return false;
@@ -60,6 +61,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
MutableIntBoundingBox box = structurestart.getBoundingBox();
structurestart.generateStructure(
world,
generator,
rand,
new MutableIntBoundingBox(
pos.getX() - this.getRadius()*16,
@@ -102,7 +104,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
ChunkPos chunkpos = new ChunkPos(packedChunkPos);
StructureStart structurestart;
Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS);
Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);
if (ichunk != null)
{
@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.settings.CarpetSettings;
import net.minecraft.class_4538;
import net.minecraft.structure.StructurePiece;
import net.minecraft.world.Heightmap;
import net.minecraft.world.ViewableWorld;
@@ -13,10 +14,10 @@ public class StructurePieceMixin
{
@Redirect(method = "isUnderSeaLevel", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/ViewableWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
target = "Lnet/minecraft/class_4538;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int getTop(ViewableWorld viewableWorld, Heightmap.Type var1, int var2, int var3)
private int getTop(class_4538 class_4538, Heightmap.Type var1, int var2, int var3)
{
return viewableWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
return class_4538.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
}
}
@@ -291,7 +291,7 @@ public class CarpetExpression
private void forceChunkUpdate(BlockPos pos, ServerWorld world)
{
Chunk chunk = world.getChunk(pos);
Chunk chunk = world.method_22350(pos);
chunk.setShouldSave(true);
for (int i = 0; i<16; i++)
{
@@ -706,7 +706,7 @@ public class CarpetExpression
genericStateTest(c, "emitted_light", lv, (s, p, w) -> new NumericValue(s.getLuminance())));
this.expr.addLazyFunction("light", -1, (c, t, lv) ->
genericStateTest(c, "light", lv, (s, p, w) -> new NumericValue(w.getLightLevel(p))));
genericStateTest(c, "light", lv, (s, p, w) -> new NumericValue(Math.max(w.getLightLevel(LightType.BLOCK, p), w.getLightLevel(LightType.SKY, p)))));
this.expr.addLazyFunction("block_light", -1, (c, t, lv) ->
genericStateTest(c, "block_light", lv, (s, p, w) -> new NumericValue(w.getLightLevel(LightType.BLOCK, p))));
@@ -748,7 +748,7 @@ public class CarpetExpression
this.expr.addLazyFunction("loaded", -1, (c, t, lv) ->
{
Value retval = ((CarpetContext) c).s.getWorld().isBlockLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
Value retval = ((CarpetContext) c).s.getWorld().isHeightValidAndBlockLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
return (c_, t_) -> retval;
});
@@ -780,7 +780,7 @@ public class CarpetExpression
this.expr.addLazyFunction("block_tick", -1, (c, t, lv) ->
booleanStateTest(c, "block_tick", lv, (s, p) ->
{
World w = ((CarpetContext)c).s.getWorld();
ServerWorld w = ((CarpetContext)c).s.getWorld();
s.onRandomTick(w, p, w.random);
return true;
}));
@@ -788,7 +788,7 @@ public class CarpetExpression
this.expr.addLazyFunction("random_tick", -1, (c, t, lv) ->
booleanStateTest(c, "random_tick", lv, (s, p) ->
{
World w = ((CarpetContext)c).s.getWorld();
ServerWorld w = ((CarpetContext)c).s.getWorld();
if (s.hasRandomTicks() || s.getFluidState().hasRandomTicks())
s.onRandomTick(w, p, w.random);
return true;
@@ -1008,7 +1008,7 @@ public class CarpetExpression
throw new InternalExpressionException("Unknown biome: "+biomeName);
ServerWorld world = cc.s.getWorld();
BlockPos pos = locator.block.getPos();
Chunk chunk = world.getChunk(pos);
Chunk chunk = world.method_22350(pos);
chunk.getBiomeArray()[(pos.getX() & 15) | (pos.getZ() & 15) << 4] = biome;
this.forceChunkUpdate(pos, world);
return LazyValue.NULL;
+10 -11
View File
@@ -1,21 +1,18 @@
package carpet.utils;
import net.minecraft.block.Block;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnType;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.BlockState;
import net.minecraft.entity.mob.MobEntityWithAi;
import net.minecraft.entity.ai.goal.WanderAroundGoal;
import net.minecraft.entity.ai.PathfindingUtil;
import net.minecraft.entity.ai.goal.WanderAroundGoal;
import net.minecraft.entity.mob.MobEntityWithAi;
import net.minecraft.entity.mob.ZombiePigmanEntity;
import net.minecraft.block.BlockPlacementEnvironment;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.text.BaseText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.text.BaseText;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import java.util.ArrayList;
@@ -171,8 +168,10 @@ public class BlockInfo
lst.add(Messenger.s(String.format(" - Normal cube: %s", state.isSimpleFullBlock(world, pos)))); //isNormalCube())));
lst.add(Messenger.s(String.format(" - Is liquid: %s", material.isLiquid())));
lst.add(Messenger.s(""));
lst.add(Messenger.s(String.format(" - Light in: %d, above: %d", world.getLightLevel(pos), world.getLightLevel(pos.up()))));
lst.add(Messenger.s(String.format(" - Brightness in: %.2f, above: %.2f", world.getBrightness(pos), world.getBrightness(pos.up()))));
lst.add(Messenger.s(String.format(" - Light in: %d, above: %d",
Math.max(world.getLightLevel(LightType.BLOCK, pos),world.getLightLevel(LightType.SKY, pos)) ,
Math.max(world.getLightLevel(LightType.BLOCK, pos.up()),world.getLightLevel(LightType.SKY, pos.up())))));
lst.add(Messenger.s(String.format(" - Brightness in: %.2f, above: %.2f", world.method_22349(pos), world.method_22349(pos.up()))));
lst.add(Messenger.s(String.format(" - Is opaque: %s", material.isSolid() )));
//lst.add(Messenger.s(String.format(" - Light opacity: %d", state.getOpacity(world,pos))));
lst.add(Messenger.s(String.format(" - Blocks light: %s", state.getMaterial().blocksLight())));
@@ -155,10 +155,10 @@ public class PerimeterDiagnostics
private boolean check_entity_spawn(BlockPos pos)
{
if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle))
if (sle == null || !worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle))
{
sle = null;
for (Biome.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos))
for (Biome.SpawnEntry sle: worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos))
{
if (el.getType() == sle.type)
{
@@ -166,7 +166,7 @@ public class PerimeterDiagnostics
break;
}
}
if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle))
if (sle == null || !worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle))
{
return false;
}
@@ -394,11 +394,11 @@ public class SpawnReporter
entity.remove();
}
public static List<BaseText> report(BlockPos pos, World worldIn)
public static List<BaseText> report(BlockPos pos, ServerWorld worldIn)
{
List<BaseText> rep = new ArrayList<>();
int x = pos.getX(); int y = pos.getY(); int z = pos.getZ();
Chunk chunk = worldIn.getChunk(pos);
Chunk chunk = worldIn.method_22350(pos);
int lc = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x, z) + 1;
String where = String.format((y >= lc) ? "%d blocks above it." : "%d blocks below it.", MathHelper.abs(y-lc));
if (y == lc) where = "right at it.";
@@ -407,7 +407,7 @@ public class SpawnReporter
for (EntityCategory enumcreaturetype : EntityCategory.values())
{
String type_code = String.format("%s", enumcreaturetype).substring(0, 3);
List<Biome.SpawnEntry> lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(enumcreaturetype, pos);
List<Biome.SpawnEntry> lst = ((ChunkGenerator)worldIn.method_14178().getChunkGenerator()).getEntitySpawnList(enumcreaturetype, pos);
if (lst != null && !lst.isEmpty())
{
for (Biome.SpawnEntry spawnEntry : lst)
+2 -1
View File
@@ -7,6 +7,7 @@ import net.minecraft.block.MaterialColor;
import net.minecraft.block.BlockState;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@@ -28,7 +29,7 @@ public class WoolTool
}
}
public static void carpetPlacedAction(DyeColor color, PlayerEntity placer, BlockPos pos, World worldIn)
public static void carpetPlacedAction(DyeColor color, PlayerEntity placer, BlockPos pos, ServerWorld worldIn)
{
if (!CarpetSettings.carpets)
{