This commit is contained in:
gnembon committed 2021-09-18 08:46:27 -03:00
1 parent 70754dbfe8
commit bc175509a2
24 files changed
+155 -113

No files matched your search

@@ -308,11 +308,11 @@ public class EntityPlayerActionPack
case BLOCK:
{
player.updateLastActionTime();
ServerWorld world = player.getServerWorld();
ServerWorld world = player.method_37908();
BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getSide();
if (pos.getY() < player.getServerWorld().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
if (pos.getY() < player.method_37908().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
{
ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit);
if (result.isAccepted())
@@ -347,7 +347,7 @@ public class EntityPlayerActionPack
}
}
ItemStack handItem = player.getStackInHand(hand);
if (player.interactionManager.interactItem(player, player.getServerWorld(), handItem, hand).isAccepted())
if (player.interactionManager.interactItem(player, player.method_37908(), handItem, hand).isAccepted())
{
ap.itemUseCooldown = 3;
return true;
@@ -400,7 +400,7 @@ public class EntityPlayerActionPack
boolean blockBroken = false;
if (player.interactionManager.getGameMode().isCreative())
{
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.method_37908().getTopY());
ap.blockHitDelay = 5;
blockBroken = true;
}
@@ -408,9 +408,9 @@ public class EntityPlayerActionPack
{
if (ap.currentBlock != null)
{
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.method_37908().getTopY());
}
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.method_37908().getTopY());
boolean notAir = !state.isAir();
if (notAir && ap.curBlockDamageMP == 0)
{
@@ -433,7 +433,7 @@ public class EntityPlayerActionPack
ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.world, pos);
if (ap.curBlockDamageMP >= 1)
{
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.method_37908().getTopY());
ap.currentBlock = null;
ap.blockHitDelay = 5;
blockBroken = true;
@@ -455,7 +455,7 @@ public class EntityPlayerActionPack
EntityPlayerActionPack ap = ((ServerPlayerEntityInterface) player).getActionPack();
if (ap.currentBlock == null) return;
player.world.setBlockBreakingInfo(-1, ap.currentBlock, -1);
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getServerWorld().getTopY());
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.method_37908().getTopY());
ap.currentBlock = null;
}
},
@@ -135,8 +135,13 @@ public class FeatureGenerator
private static ConfiguredStructureFeature<?, ?> getDefaultFeature(StructureFeature<?> structure, ServerWorld world, BlockPos pos, boolean tryHard)
{
ConfiguredStructureFeature<?, ?> configuredFeature = world.getBiome(pos).getGenerationSettings().method_30978(structure.configure(null));
if (configuredFeature.config != null || !tryHard) return configuredFeature;
var definedStructures = world.getServer().getSaveProperties().getGeneratorOptions().getChunkGenerator().getStructuresConfig().method_38424(structure);
var optinalBiome = world.getRegistryManager().get(Registry.BIOME_KEY).getKey(world.getBiome(pos));
if (optinalBiome.isPresent())
for (var configureStructure: definedStructures.inverse().get(optinalBiome.get()))
if (configureStructure.feature == structure)
return configureStructure;
if (!tryHard) return null;
return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getEntries().stream().
filter(cS -> cS.getValue().feature == structure).
findFirst().map(Map.Entry::getValue).orElse(null);
@@ -147,26 +152,21 @@ public class FeatureGenerator
long seed = world.getSeed();
ChunkGenerator generator = world.getChunkManager().getChunkGenerator();
StructureConfig params = generator.getStructuresConfig().getForType(structure);
synchronized(boo) {
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));
ConfiguredStructureFeature<?, ?> configuredFeature = biome.getGenerationSettings().method_30978(structure.configure(null));
Biome biome = world.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9));
ConfiguredStructureFeature<?, ?> configuredFeature = getDefaultFeature(structure, world, pos, false);
if (configuredFeature == null || configuredFeature.config == null) return null;
ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess
// using here world for heightview, rather than chunk since we - unlike vanilla, want to avoid creating any chunks even on the
// structure starts level - lets see where would that take us.
if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos, biome, chunkPos, configuredFeature.config, world)) // should start at
if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos, chunkPos, configuredFeature.config, world)) // should start at
{
if (!computeBox) return StructureStart.DEFAULT;
StructureManager manager = world.getStructureManager();
StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos, 0, seed);
synchronized (boo) {
structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, biome, (T) configuredFeature.config, world);
structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, (T) configuredFeature.config, world, (b) -> b == biome);
}
if (!structureStart3.hasChildren()) return null;
return structureStart3;