From 567b505439b67b49cca89a53ecbb3a7a84343526 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Fri, 14 Jun 2019 00:00:59 +1000 Subject: [PATCH] Fixes --- .../biomesoplenty/api/entity/BOPEntities.java | 3 +- .../client/util/BiomeMapColours.java | 7 +- .../client/util/GenLayerVisualizer.java | 10 +- .../common/block/trees/FirTree.java | 7 +- .../common/block/trees/RedwoodTree.java | 7 +- .../common/block/trees/UmbranTree.java | 7 +- .../common/entity/item/EntityBoatBOP.java | 1909 ++++++++--------- .../common/entity/item/ModelBoatBOP.java | 107 - .../common/entity/item/RenderBoatBOP.java | 9 +- .../entity/projectile/EntityMudball.java | 28 +- .../common/item/ItemMudball.java | 16 +- .../common/item/ItemRecordBOP.java | 4 +- .../common/world/BOPLayerUtil.java | 80 +- .../world/ChunkGeneratorOverworldBOP.java | 4 +- .../common/world/WorldTypeBOP.java | 12 +- .../gen/feature/MangroveSurfaceBuilder.java | 71 +- .../gen/feature/MarshSurfaceBuilder.java | 56 +- .../gen/feature/MeadowFlowersFeature.java | 33 +- .../world/gen/feature/MoorFlowersFeature.java | 41 +- .../world/gen/feature/MudSurfaceBuilder.java | 39 +- .../feature/MysticGroveFlowersFeature.java | 33 +- .../gen/feature/OriginFlowersFeature.java | 27 +- .../gen/feature/PodzolSurfaceBuilder.java | 33 +- .../gen/feature/PrairieFlowersFeature.java | 33 +- .../gen/feature/PumpkinPatchFeature.java | 92 +- .../gen/feature/RainforestFlowersFeature.java | 33 +- .../world/gen/feature/ScrubFeature.java | 22 +- .../gen/feature/ShrublandFlowersFeature.java | 33 +- .../gen/feature/SnowyFlowersFeature.java | 48 +- .../world/gen/feature/SplotchConfig.java | 41 +- .../world/gen/feature/SplotchFeature.java | 96 +- .../gen/feature/StandardGrassFeature.java | 65 +- .../gen/feature/TropicsFlowersFeature.java | 33 +- .../gen/feature/tree/BasicTreeFeature.java | 16 +- .../gen/feature/tree/BigTreeFeature.java | 64 +- .../gen/feature/tree/TreeFeatureBase.java | 37 +- .../java/biomesoplenty/core/ClientProxy.java | 8 +- .../java/biomesoplenty/init/ModEntities.java | 23 +- 38 files changed, 1586 insertions(+), 1601 deletions(-) delete mode 100644 src/main/java/biomesoplenty/common/entity/item/ModelBoatBOP.java diff --git a/src/main/java/biomesoplenty/api/entity/BOPEntities.java b/src/main/java/biomesoplenty/api/entity/BOPEntities.java index c055a6632..4940482ee 100644 --- a/src/main/java/biomesoplenty/api/entity/BOPEntities.java +++ b/src/main/java/biomesoplenty/api/entity/BOPEntities.java @@ -8,9 +8,10 @@ package biomesoplenty.api.entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.projectile.ProjectileItemEntity; public class BOPEntities { - public static EntityType mudball; + public static EntityType mudball; public static EntityType boat_bop; } diff --git a/src/main/java/biomesoplenty/client/util/BiomeMapColours.java b/src/main/java/biomesoplenty/client/util/BiomeMapColours.java index d9c289767..41a4f5668 100644 --- a/src/main/java/biomesoplenty/client/util/BiomeMapColours.java +++ b/src/main/java/biomesoplenty/client/util/BiomeMapColours.java @@ -8,15 +8,16 @@ package biomesoplenty.client.util; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.block.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import net.minecraftforge.common.BiomeDictionary; @@ -101,7 +102,7 @@ public class BiomeMapColours return biomeColours.get(biomeId); } - int colour = getBiomeMapColourRaw(Biome.getBiome(biomeId, null)); + int colour = getBiomeMapColourRaw(Registry.BIOME.getByValue(biomeId)); biomeColours.put(biomeId, colour); return colour; } @@ -162,7 +163,7 @@ public class BiomeMapColours public static int getBiomeBlockColourForCoords(Biome biome, BlockPos pos) { - BlockState topBlock = biome.getSurfaceBuilder().getConfig().getTop(); + BlockState topBlock = biome.getSurfaceBuilder().getConfig().getTopMaterial(); int colour; if (topBlock == Blocks.GRASS.getDefaultState()) diff --git a/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java b/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java index cd3b4c1cd..9da6e00fd 100644 --- a/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java +++ b/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java @@ -11,13 +11,12 @@ import biomesoplenty.common.world.BOPLayerUtil; import biomesoplenty.common.world.BOPWorldSettings; import biomesoplenty.common.world.layer.traits.IBOPContextExtended; import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP; -import net.minecraft.world.biome.Biomes; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.provider.BiomeProviderType; import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings; import net.minecraft.world.gen.OverworldGenSettings; -import net.minecraft.world.gen.area.AreaDimension; import net.minecraft.world.gen.area.IAreaFactory; import net.minecraft.world.gen.area.LazyArea; import org.lwjgl.glfw.GLFW; @@ -160,10 +159,8 @@ public class GenLayerVisualizer OverworldBiomeProviderSettings settingsProvider = BiomeProviderType.VANILLA_LAYERED.createSettings(); OverworldGenSettings settings = settingsProvider.getGeneratorSettings(); - int[] aint = new int[1]; LongFunction> contextFactory = (seedModifier) -> { - ++aint[0]; - return new LazyAreaLayerContextBOP(1, aint[0], 0, seedModifier); + return new LazyAreaLayerContextBOP(1, 0, seedModifier); }; IAreaFactory landAreaFactory = BOPLayerUtil.createInitialLandAndSeaFactory(contextFactory); @@ -172,8 +169,7 @@ public class GenLayerVisualizer //IAreaFactory biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0); - AreaDimension areaDimension = new AreaDimension(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); - LazyArea area = biomeAreaFactory.make(areaDimension); + LazyArea area = biomeAreaFactory.make(); int startX = 5000; int startZ = 10000; diff --git a/src/main/java/biomesoplenty/common/block/trees/FirTree.java b/src/main/java/biomesoplenty/common/block/trees/FirTree.java index 8ca3cb7f9..5f1d2fe9f 100644 --- a/src/main/java/biomesoplenty/common/block/trees/FirTree.java +++ b/src/main/java/biomesoplenty/common/block/trees/FirTree.java @@ -11,14 +11,9 @@ import java.util.Random; public class FirTree extends Tree { @Nullable + @Override protected AbstractTreeFeature getTreeFeature(Random random) { return BOPBiomeFeatures.FIR_TREE; } - - @Nullable - protected AbstractTreeFeature getBigTreeFeature(Random random) - { - return BOPBiomeFeatures.FIR_TREE_LARGE; - } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/block/trees/RedwoodTree.java b/src/main/java/biomesoplenty/common/block/trees/RedwoodTree.java index b7135366e..4c014a87d 100644 --- a/src/main/java/biomesoplenty/common/block/trees/RedwoodTree.java +++ b/src/main/java/biomesoplenty/common/block/trees/RedwoodTree.java @@ -11,14 +11,9 @@ import java.util.Random; public class RedwoodTree extends Tree { @Nullable + @Override protected AbstractTreeFeature getTreeFeature(Random random) { return BOPBiomeFeatures.REDWOOD_TREE; } - - @Nullable - protected AbstractTreeFeature getBigTreeFeature(Random random) - { - return BOPBiomeFeatures.REDWOOD_TREE_MEDIUM; - } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/block/trees/UmbranTree.java b/src/main/java/biomesoplenty/common/block/trees/UmbranTree.java index dc0de42be..d94de6dc5 100644 --- a/src/main/java/biomesoplenty/common/block/trees/UmbranTree.java +++ b/src/main/java/biomesoplenty/common/block/trees/UmbranTree.java @@ -11,14 +11,9 @@ import java.util.Random; public class UmbranTree extends Tree { @Nullable + @Override protected AbstractTreeFeature getTreeFeature(Random random) { return BOPBiomeFeatures.UMBRAN_TREE; } - - @Nullable - protected AbstractTreeFeature getBigTreeFeature(Random random) - { - return BOPBiomeFeatures.TALL_UMBRAN_TREE; - } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/item/EntityBoatBOP.java b/src/main/java/biomesoplenty/common/entity/item/EntityBoatBOP.java index 8cb08d552..4ae23b0e5 100644 --- a/src/main/java/biomesoplenty/common/entity/item/EntityBoatBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/EntityBoatBOP.java @@ -1,39 +1,32 @@ package biomesoplenty.common.entity.item; -import java.util.List; - -import javax.annotation.Nullable; - import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.api.entity.BOPEntities; import biomesoplenty.api.item.BOPItems; import net.minecraft.block.Block; -import net.minecraft.block.BlockLilyPad; import net.minecraft.block.BlockState; +import net.minecraft.block.LilyPadBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MoverType; import net.minecraft.entity.item.BoatEntity; -import net.minecraft.entity.item.EntityBoat; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityWaterMob; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.WaterMobEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.IFluidState; -import net.minecraft.init.Items; -import net.minecraft.init.Particles; -import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.IPacket; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.network.play.client.CPacketSteerBoat; +import net.minecraft.network.play.client.CSteerBoatPacket; +import net.minecraft.network.play.server.SSpawnObjectPacket; +import net.minecraft.particles.ParticleTypes; import net.minecraft.tags.FluidTags; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EntityDamageSourceIndirect; -import net.minecraft.util.EntitySelectors; -import net.minecraft.util.Direction; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundEvent; +import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -45,967 +38,917 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; +import java.util.List; + public class EntityBoatBOP extends BoatEntity { - private static final DataParameter TIME_SINCE_HIT = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); - private static final DataParameter FORWARD_DIRECTION = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); - private static final DataParameter DAMAGE_TAKEN = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.FLOAT); - private static final DataParameter BOAT_TYPE = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); - private static final DataParameter field_199704_e = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.BOOLEAN); - private static final DataParameter field_199705_f = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.BOOLEAN); - private static final DataParameter ROCKING_TICKS = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); - private final float[] paddlePositions = new float[2]; - /** How much of current speed to retain. Value zero to one. */ - private float momentum; - private float outOfControlTicks; - private float deltaRotation; - private int lerpSteps; - private double lerpX; - private double lerpY; - private double lerpZ; - private double lerpYaw; - private double lerpPitch; - private boolean leftInputDown; - private boolean rightInputDown; - private boolean forwardInputDown; - private boolean backInputDown; - private double waterLevel; - /** - * How much the boat should glide given the slippery blocks it's currently gliding over. - * Halved every tick. - */ - private float boatGlide; - private EntityBoatBOP.Status status; - private EntityBoatBOP.Status previousStatus; - private double lastYd; - private boolean rocking; - private boolean field_203060_aN; - private float rockingIntensity; - private float rockingAngle; - private float prevRockingAngle; - - public EntityBoatBOP(World worldIn) { - super(worldIn); - this.preventEntitySpawning = true; - this.setSize(1.375F, 0.5625F); - } - - public EntityBoatBOP(World worldIn, double x, double y, double z) { - this(worldIn); - this.setPosition(x, y, z); - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.prevPosX = x; - this.prevPosY = y; - this.prevPosZ = z; - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() { - return false; - } - - @Override - protected void registerData() { - this.dataManager.register(TIME_SINCE_HIT, 0); - this.dataManager.register(FORWARD_DIRECTION, 1); - this.dataManager.register(DAMAGE_TAKEN, 0.0F); - this.dataManager.register(BOAT_TYPE, EntityBoatBOP.Type.FIR.ordinal()); - this.dataManager.register(field_199704_e, false); - this.dataManager.register(field_199705_f, false); - this.dataManager.register(ROCKING_TICKS, 0); - } - - /** - * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be - * pushable on contact, like boats or minecarts. - */ - @Nullable - @Override - public AxisAlignedBB getCollisionBox(Entity entityIn) { - return entityIn.canBePushed() ? entityIn.getBoundingBox() : null; - } - - /** - * Returns the solid collision bounding box for this entity. Used to make (e.g.) boats solid. Return null if - * this entity is not solid. - * - * For general purposes, use {@link #width} and {@link #height}. - * - * @see getEntityBoundingBox - */ - @Nullable - @Override - public AxisAlignedBB getCollisionBoundingBox() { - return this.getBoundingBox(); - } - - /** - * Returns true if this entity should push and be pushed by other entities when colliding. - */ - @Override - public boolean canBePushed() { - return true; - } - - /** - * Returns the Y offset from the entity's position for any entity riding this one. - */ - @Override - public double getMountedYOffset() { - return -0.1D; - } - - /** - * Called when the entity is attacked. - */ - @Override - public boolean attackEntityFrom(DamageSource source, float amount) { - if (this.isInvulnerableTo(source)) { - return false; - } else if (!this.world.isRemote && !this.removed) { - if (source instanceof EntityDamageSourceIndirect && source.getTrueSource() != null && this.isPassenger(source.getTrueSource())) { - return false; - } else { - this.setForwardDirection(-this.getForwardDirection()); - this.setTimeSinceHit(10); - this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); - this.markVelocityChanged(); - boolean flag = source.getTrueSource() instanceof EntityPlayer && ((EntityPlayer)source.getTrueSource()).abilities.isCreativeMode; - if (flag || this.getDamageTaken() > 40.0F) { - if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { - this.entityDropItem(this.getItemBoat()); - } - - this.remove(); - } - - return true; - } - } else { - return true; - } - } - - @Override - public void onEnterBubbleColumnWithAirAbove(boolean downwards) { - if (!this.world.isRemote) { - this.rocking = true; - this.field_203060_aN = downwards; - if (this.getRockingTicks() == 0) { - this.setRockingTicks(60); - } - } - - this.world.addParticle(Particles.SPLASH, this.posX + (double)this.rand.nextFloat(), this.posY + 0.7D, this.posZ + (double)this.rand.nextFloat(), 0.0D, 0.0D, 0.0D); - if (this.rand.nextInt(20) == 0) { - this.world.playSound(this.posX, this.posY, this.posZ, this.getSplashSound(), this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat(), false); - } - - } - - /** - * Applies a velocity to the entities, to push them away from eachother. - */ - @Override - public void applyEntityCollision(Entity entityIn) { - if (entityIn instanceof EntityBoat) { - if (entityIn.getBoundingBox().minY < this.getBoundingBox().maxY) { - super.applyEntityCollision(entityIn); - } - } else if (entityIn.getBoundingBox().minY <= this.getBoundingBox().minY) { - super.applyEntityCollision(entityIn); - } - - } - - @Override - public Item getItemBoat() { - switch(this.getBOPBoatType()) { - case FIR: - default: - return BOPItems.fir_boat; - case REDWOOD: - return BOPItems.redwood_boat; - case CHERRY: - return BOPItems.cherry_boat; - case MAHOGANY: - return BOPItems.mahogany_boat; - case JACARANDA: - return BOPItems.jacaranda_boat; - case PALM: - return BOPItems.palm_boat; - case WILLOW: - return BOPItems.willow_boat; - case DEAD: - return BOPItems.dead_boat; - case MAGIC: - return BOPItems.magic_boat; - case UMBRAN: - return BOPItems.umbran_boat; - case HELLBARK: - return BOPItems.hellbark_boat; - case ETHEREAL: - return BOPItems.ethereal_boat; - } - } - - /** - * Setups the entity to do the hurt animation. Only used by packets in multiplayer. - */ - @OnlyIn(Dist.CLIENT) - @Override - public void performHurtAnimation() { - this.setForwardDirection(-this.getForwardDirection()); - this.setTimeSinceHit(10); - this.setDamageTaken(this.getDamageTaken() * 11.0F); - } - - /** - * Returns true if other Entities should be prevented from moving through this Entity. - */ - @Override - public boolean canBeCollidedWith() { - return !this.removed; - } - - /** - * Sets a target for the client to interpolate towards over the next few ticks - */ - @OnlyIn(Dist.CLIENT) - @Override - public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport) { - this.lerpX = x; - this.lerpY = y; - this.lerpZ = z; - this.lerpYaw = (double)yaw; - this.lerpPitch = (double)pitch; - this.lerpSteps = 10; - } - - /** - * Gets the horizontal facing direction of this Entity, adjusted to take specially-treated entity types into account. - */ - @Override - public Direction getAdjustedHorizontalFacing() { - return this.getHorizontalFacing().rotateY(); - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void tick() { - this.previousStatus = this.status; - this.status = this.getBoatStatus(); - if (this.status != EntityBoatBOP.Status.UNDER_WATER && this.status != EntityBoatBOP.Status.UNDER_FLOWING_WATER) { - this.outOfControlTicks = 0.0F; - } else { - ++this.outOfControlTicks; - } - - if (!this.world.isRemote && this.outOfControlTicks >= 60.0F) { - this.removePassengers(); - } - - if (this.getTimeSinceHit() > 0) { - this.setTimeSinceHit(this.getTimeSinceHit() - 1); - } - - if (this.getDamageTaken() > 0.0F) { - this.setDamageTaken(this.getDamageTaken() - 1.0F); - } - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - //super.tick(); - this.tickLerp(); - if (this.canPassengerSteer()) { - if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof EntityPlayer)) { - this.setPaddleState(false, false); - } - - this.updateMotion(); - if (this.world.isRemote) { - this.controlBoat(); - this.world.sendPacketToServer(new CPacketSteerBoat(this.getPaddleState(0), this.getPaddleState(1))); - } - - this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); - } else { - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - } - - this.updateRocking(); - - for(int i = 0; i <= 1; ++i) { - if (this.getPaddleState(i)) { - if (!this.isSilent() && (double)(this.paddlePositions[i] % ((float)Math.PI * 2F)) <= (double)((float)Math.PI / 4F) && ((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)) % (double)((float)Math.PI * 2F) >= (double)((float)Math.PI / 4F)) { - SoundEvent soundevent = this.getPaddleSound(); - if (soundevent != null) { - Vec3d vec3d = this.getLook(1.0F); - double d0 = i == 1 ? -vec3d.z : vec3d.z; - double d1 = i == 1 ? vec3d.x : -vec3d.x; - this.world.playSound((EntityPlayer)null, this.posX + d0, this.posY, this.posZ + d1, soundevent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat()); - } - } - - this.paddlePositions[i] = (float)((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)); - } else { - this.paddlePositions[i] = 0.0F; - } - } - - this.doBlockCollisions(); - List list = this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox().grow((double)0.2F, (double)-0.01F, (double)0.2F), EntitySelectors.pushableBy(this)); - if (!list.isEmpty()) { - boolean flag = !this.world.isRemote && !(this.getControllingPassenger() instanceof EntityPlayer); - - for(int j = 0; j < list.size(); ++j) { - Entity entity = list.get(j); - if (!entity.isPassenger(this)) { - if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.width < this.width && entity instanceof EntityLivingBase && !(entity instanceof EntityWaterMob) && !(entity instanceof EntityPlayer)) { - entity.startRiding(this); - } else { - this.applyEntityCollision(entity); - } - } - } - } - - } - - private void updateRocking() { - if (this.world.isRemote) { - int i = this.getRockingTicks(); - if (i > 0) { - this.rockingIntensity += 0.05F; - } else { - this.rockingIntensity -= 0.1F; - } - - this.rockingIntensity = MathHelper.clamp(this.rockingIntensity, 0.0F, 1.0F); - this.prevRockingAngle = this.rockingAngle; - this.rockingAngle = 10.0F * (float)Math.sin((double)(0.5F * (float)this.world.getGameTime())) * this.rockingIntensity; - } else { - if (!this.rocking) { - this.setRockingTicks(0); - } - - int k = this.getRockingTicks(); - if (k > 0) { - --k; - this.setRockingTicks(k); - int j = 60 - k - 1; - if (j > 0 && k == 0) { - this.setRockingTicks(0); - if (this.field_203060_aN) { - this.motionY -= 0.7D; - this.removePassengers(); - } else { - this.motionY = this.isPassenger(EntityPlayer.class) ? 2.7D : 0.6D; - } - } - - this.rocking = false; - } - } - - } - - @Nullable - @Override - protected SoundEvent getPaddleSound() { - switch(this.getBoatStatus()) { - case IN_WATER: - case UNDER_WATER: - case UNDER_FLOWING_WATER: - return SoundEvents.ENTITY_BOAT_PADDLE_WATER; - case ON_LAND: - return SoundEvents.ENTITY_BOAT_PADDLE_LAND; - case IN_AIR: - default: - return null; - } - } - - private void tickLerp() { - if (this.lerpSteps > 0 && !this.canPassengerSteer()) { - double d0 = this.posX + (this.lerpX - this.posX) / (double)this.lerpSteps; - double d1 = this.posY + (this.lerpY - this.posY) / (double)this.lerpSteps; - double d2 = this.posZ + (this.lerpZ - this.posZ) / (double)this.lerpSteps; - double d3 = MathHelper.wrapDegrees(this.lerpYaw - (double)this.rotationYaw); - this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.lerpSteps); - this.rotationPitch = (float)((double)this.rotationPitch + (this.lerpPitch - (double)this.rotationPitch) / (double)this.lerpSteps); - --this.lerpSteps; - this.setPosition(d0, d1, d2); - this.setRotation(this.rotationYaw, this.rotationPitch); - } - } - - @Override - public void setPaddleState(boolean left, boolean right) { - this.dataManager.set(field_199704_e, left); - this.dataManager.set(field_199705_f, right); - } - - @OnlyIn(Dist.CLIENT) - @Override - public float getRowingTime(int side, float limbSwing) { - return this.getPaddleState(side) ? (float)MathHelper.clampedLerp((double)this.paddlePositions[side] - (double)((float)Math.PI / 8F), (double)this.paddlePositions[side], (double)limbSwing) : 0.0F; - } - - /** - * Determines whether the boat is in water, gliding on land, or in air - */ - private EntityBoatBOP.Status getBoatStatus() { - EntityBoatBOP.Status entityboat$status = this.getUnderwaterStatus(); - if (entityboat$status != null) { - this.waterLevel = this.getBoundingBox().maxY; - return entityboat$status; - } else if (this.checkInWater()) { - return EntityBoatBOP.Status.IN_WATER; - } else { - float f = this.getBoatGlide(); - if (f > 0.0F) { - this.boatGlide = f; - return EntityBoatBOP.Status.ON_LAND; - } else { - return EntityBoatBOP.Status.IN_AIR; - } - } - } - - @Override - public float getWaterLevelAbove() { - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - int i = MathHelper.floor(axisalignedbb.minX); - int j = MathHelper.ceil(axisalignedbb.maxX); - int k = MathHelper.floor(axisalignedbb.maxY); - int l = MathHelper.ceil(axisalignedbb.maxY - this.lastYd); - int i1 = MathHelper.floor(axisalignedbb.minZ); - int j1 = MathHelper.ceil(axisalignedbb.maxZ); - - try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { - label161: - for(int k1 = k; k1 < l; ++k1) { - float f = 0.0F; - - for(int l1 = i; l1 < j; ++l1) { - for(int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(l1, k1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); - if (ifluidstate.isTagged(FluidTags.WATER)) { - f = Math.max(f, (float)k1 + ifluidstate.getHeight()); - } - - if (f >= 1.0F) { - continue label161; - } - } - } - - if (f < 1.0F) { - float f2 = (float)blockpos$pooledmutableblockpos.getY() + f; - return f2; - } - } - - float f1 = (float)(l + 1); - return f1; - } - } - - /** - * Decides how much the boat should be gliding on the land (based on any slippery blocks) - */ - @Override - public float getBoatGlide() { - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - AxisAlignedBB axisalignedbb1 = new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY - 0.001D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); - int i = MathHelper.floor(axisalignedbb1.minX) - 1; - int j = MathHelper.ceil(axisalignedbb1.maxX) + 1; - int k = MathHelper.floor(axisalignedbb1.minY) - 1; - int l = MathHelper.ceil(axisalignedbb1.maxY) + 1; - int i1 = MathHelper.floor(axisalignedbb1.minZ) - 1; - int j1 = MathHelper.ceil(axisalignedbb1.maxZ) + 1; - VoxelShape voxelshape = VoxelShapes.create(axisalignedbb1); - float f = 0.0F; - int k1 = 0; - - try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { - for(int l1 = i; l1 < j; ++l1) { - for(int i2 = i1; i2 < j1; ++i2) { - int j2 = (l1 != i && l1 != j - 1 ? 0 : 1) + (i2 != i1 && i2 != j1 - 1 ? 0 : 1); - if (j2 != 2) { - for(int k2 = k; k2 < l; ++k2) { - if (j2 <= 0 || k2 != k && k2 != l - 1) { - blockpos$pooledmutableblockpos.setPos(l1, k2, i2); - BlockState BlockState = this.world.getBlockState(blockpos$pooledmutableblockpos); - if (!(BlockState.getBlock() instanceof BlockLilyPad) && VoxelShapes.compare(BlockState.getCollisionShape(this.world, blockpos$pooledmutableblockpos).withOffset((double)l1, (double)k2, (double)i2), voxelshape, IBooleanFunction.AND)) { - f += BlockState.getSlipperiness(world, blockpos$pooledmutableblockpos, this); - ++k1; - } - } - } - } - } - } - } - - return f / (float)k1; - } - - private boolean checkInWater() { - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - int i = MathHelper.floor(axisalignedbb.minX); - int j = MathHelper.ceil(axisalignedbb.maxX); - int k = MathHelper.floor(axisalignedbb.minY); - int l = MathHelper.ceil(axisalignedbb.minY + 0.001D); - int i1 = MathHelper.floor(axisalignedbb.minZ); - int j1 = MathHelper.ceil(axisalignedbb.maxZ); - boolean flag = false; - this.waterLevel = Double.MIN_VALUE; - - try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { - for(int k1 = i; k1 < j; ++k1) { - for(int l1 = k; l1 < l; ++l1) { - for(int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(k1, l1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); - if (ifluidstate.isTagged(FluidTags.WATER)) { - float f = (float)l1 + ifluidstate.getHeight(); - this.waterLevel = Math.max((double)f, this.waterLevel); - flag |= axisalignedbb.minY < (double)f; - } - } - } - } - } - - return flag; - } - - /** - * Decides whether the boat is currently underwater. - */ - @Nullable - private EntityBoatBOP.Status getUnderwaterStatus() { - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - double d0 = axisalignedbb.maxY + 0.001D; - int i = MathHelper.floor(axisalignedbb.minX); - int j = MathHelper.ceil(axisalignedbb.maxX); - int k = MathHelper.floor(axisalignedbb.maxY); - int l = MathHelper.ceil(d0); - int i1 = MathHelper.floor(axisalignedbb.minZ); - int j1 = MathHelper.ceil(axisalignedbb.maxZ); - boolean flag = false; - - try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { - for(int k1 = i; k1 < j; ++k1) { - for(int l1 = k; l1 < l; ++l1) { - for(int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(k1, l1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); - if (ifluidstate.isTagged(FluidTags.WATER) && d0 < (double)((float)blockpos$pooledmutableblockpos.getY() + ifluidstate.getHeight())) { - if (!ifluidstate.isSource()) { - EntityBoatBOP.Status entityboat$status = EntityBoatBOP.Status.UNDER_FLOWING_WATER; - return entityboat$status; - } - - flag = true; - } - } - } - } - } - - return flag ? EntityBoatBOP.Status.UNDER_WATER : null; - } - - /** - * Update the boat's speed, based on momentum. - */ - private void updateMotion() { - double d0 = (double)-0.04F; - double d1 = this.hasNoGravity() ? 0.0D : (double)-0.04F; - double d2 = 0.0D; - this.momentum = 0.05F; - if (this.previousStatus == EntityBoatBOP.Status.IN_AIR && this.status != EntityBoatBOP.Status.IN_AIR && this.status != EntityBoatBOP.Status.ON_LAND) { - this.waterLevel = this.getBoundingBox().minY + (double)this.height; - this.setPosition(this.posX, (double)(this.getWaterLevelAbove() - this.height) + 0.101D, this.posZ); - this.motionY = 0.0D; - this.lastYd = 0.0D; - this.status = EntityBoatBOP.Status.IN_WATER; - } else { - if (this.status == EntityBoatBOP.Status.IN_WATER) { - d2 = (this.waterLevel - this.getBoundingBox().minY) / (double)this.height; - this.momentum = 0.9F; - } else if (this.status == EntityBoatBOP.Status.UNDER_FLOWING_WATER) { - d1 = -7.0E-4D; - this.momentum = 0.9F; - } else if (this.status == EntityBoatBOP.Status.UNDER_WATER) { - d2 = (double)0.01F; - this.momentum = 0.45F; - } else if (this.status == EntityBoatBOP.Status.IN_AIR) { - this.momentum = 0.9F; - } else if (this.status == EntityBoatBOP.Status.ON_LAND) { - this.momentum = this.boatGlide; - if (this.getControllingPassenger() instanceof EntityPlayer) { - this.boatGlide /= 2.0F; - } - } - - this.motionX *= (double)this.momentum; - this.motionZ *= (double)this.momentum; - this.deltaRotation *= this.momentum; - this.motionY += d1; - if (d2 > 0.0D) { - double d3 = 0.65D; - this.motionY += d2 * 0.06153846016296973D; - double d4 = 0.75D; - this.motionY *= 0.75D; - } - } - - } - - private void controlBoat() { - if (this.isBeingRidden()) { - float f = 0.0F; - if (this.leftInputDown) { - this.deltaRotation += -1.0F; - } - - if (this.rightInputDown) { - ++this.deltaRotation; - } - - if (this.rightInputDown != this.leftInputDown && !this.forwardInputDown && !this.backInputDown) { - f += 0.005F; - } - - this.rotationYaw += this.deltaRotation; - if (this.forwardInputDown) { - f += 0.04F; - } - - if (this.backInputDown) { - f -= 0.005F; - } - - this.motionX += (double)(MathHelper.sin(-this.rotationYaw * ((float)Math.PI / 180F)) * f); - this.motionZ += (double)(MathHelper.cos(this.rotationYaw * ((float)Math.PI / 180F)) * f); - this.setPaddleState(this.rightInputDown && !this.leftInputDown || this.forwardInputDown, this.leftInputDown && !this.rightInputDown || this.forwardInputDown); - } - } - - @Override - public void updatePassenger(Entity passenger) { - if (this.isPassenger(passenger)) { - float f = 0.0F; - float f1 = (float)((this.removed ? (double)0.01F : this.getMountedYOffset()) + passenger.getYOffset()); - if (this.getPassengers().size() > 1) { - int i = this.getPassengers().indexOf(passenger); - if (i == 0) { - f = 0.2F; - } else { - f = -0.6F; - } - - if (passenger instanceof EntityAnimal) { - f = (float)((double)f + 0.2D); - } - } - - Vec3d vec3d = (new Vec3d((double)f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * ((float)Math.PI / 180F) - ((float)Math.PI / 2F)); - passenger.setPosition(this.posX + vec3d.x, this.posY + (double)f1, this.posZ + vec3d.z); - passenger.rotationYaw += this.deltaRotation; - passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); - this.applyYawToEntity(passenger); - if (passenger instanceof EntityAnimal && this.getPassengers().size() > 1) { - int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; - passenger.setRenderYawOffset(((EntityAnimal)passenger).renderYawOffset + (float)j); - passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); - } - - } - } - - /** - * Applies this boat's yaw to the given entity. Used to update the orientation of its passenger. - */ - @Override - protected void applyYawToEntity(Entity entityToUpdate) { - entityToUpdate.setRenderYawOffset(this.rotationYaw); - float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - this.rotationYaw); - float f1 = MathHelper.clamp(f, -105.0F, 105.0F); - entityToUpdate.prevRotationYaw += f1 - f; - entityToUpdate.rotationYaw += f1 - f; - entityToUpdate.setRotationYawHead(entityToUpdate.rotationYaw); - } - - /** - * Applies this entity's orientation (pitch/yaw) to another entity. Used to update passenger orientation. - */ - @OnlyIn(Dist.CLIENT) - public void applyOrientationToEntity(Entity entityToUpdate) { - this.applyYawToEntity(entityToUpdate); - } - - /** - * Writes the extra NBT data specific to this type of entity. Should not be called from outside this class; - * use {@link #writeUnlessPassenger} or {@link #writeWithoutTypeId} instead. - */ - @Override - protected void writeAdditional(NBTTagCompound compound) { - compound.putString("Type", this.getBOPBoatType().getName()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - protected void readAdditional(NBTTagCompound compound) { - if (compound.contains("Type", 8)) { - this.setBoatType(EntityBoatBOP.Type.getTypeFromString(compound.getString("Type"))); - } - - } - - @Override - public boolean processInitialInteract(EntityPlayer player, EnumHand hand) { - if (player.isSneaking()) { - return false; - } else { - if (!this.world.isRemote && this.outOfControlTicks < 60.0F) { - player.startRiding(this); - } - - return true; - } - } - - @Override - protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) { - this.lastYd = this.motionY; - if (!this.isPassenger()) { - if (onGroundIn) { - if (this.fallDistance > 3.0F) { - if (this.status != EntityBoatBOP.Status.ON_LAND) { - this.fallDistance = 0.0F; - return; - } - - this.fall(this.fallDistance, 1.0F); - if (!this.world.isRemote && !this.removed) { - this.remove(); - if (this.world.getGameRules().getBoolean("doEntityDrops")) { - for(int i = 0; i < 3; ++i) { - this.entityDropItem(this.getBOPBoatType().asPlank()); - } - - for(int j = 0; j < 2; ++j) { - this.entityDropItem(Items.STICK); - } - } - } - } - - this.fallDistance = 0.0F; - } else if (!this.world.getFluidState((new BlockPos(this)).down()).isTagged(FluidTags.WATER) && y < 0.0D) { - this.fallDistance = (float)((double)this.fallDistance - y); - } - - } - } - - @Override - public boolean getPaddleState(int side) { - return this.dataManager.get(side == 0 ? field_199704_e : field_199705_f) && this.getControllingPassenger() != null; - } - - /** - * Sets the damage taken from the last hit. - */ - @Override - public void setDamageTaken(float damageTaken) { - this.dataManager.set(DAMAGE_TAKEN, damageTaken); - } - - /** - * Gets the damage taken from the last hit. - */ - @Override - public float getDamageTaken() { - return this.dataManager.get(DAMAGE_TAKEN); - } - - /** - * Sets the time to count down from since the last time entity was hit. - */ - @Override - public void setTimeSinceHit(int timeSinceHit) { - this.dataManager.set(TIME_SINCE_HIT, timeSinceHit); - } - - /** - * Gets the time since the last hit. - */ - @Override - public int getTimeSinceHit() { - return this.dataManager.get(TIME_SINCE_HIT); - } - - private void setRockingTicks(int p_203055_1_) { - this.dataManager.set(ROCKING_TICKS, p_203055_1_); - } - - private int getRockingTicks() { - return this.dataManager.get(ROCKING_TICKS); - } - - @OnlyIn(Dist.CLIENT) - @Override - public float func_203056_b(float p_203056_1_) { - return this.prevRockingAngle + (this.rockingAngle - this.prevRockingAngle) * p_203056_1_; - } - - /** - * Sets the forward direction of the entity. - */ - @Override - public void setForwardDirection(int forwardDirection) { - this.dataManager.set(FORWARD_DIRECTION, forwardDirection); - } - - /** - * Gets the forward direction of the entity. - */ - @Override - public int getForwardDirection() { - return this.dataManager.get(FORWARD_DIRECTION); - } - - public void setBoatType(EntityBoatBOP.Type type) { - this.dataManager.set(BOAT_TYPE, type.ordinal()); - } - - public EntityBoatBOP.Type getBOPBoatType() { - return EntityBoatBOP.Type.byId(this.dataManager.get(BOAT_TYPE)); - } - - @Override - protected boolean canFitPassenger(Entity passenger) { - return this.getPassengers().size() < 2 && !this.areEyesInFluid(FluidTags.WATER); - } - - /** - * For vehicles, the first passenger is generally considered the controller and "drives" the vehicle. For example, - * Pigs, Horses, and Boats are generally "steered" by the controlling passenger. - */ - @Nullable - @Override - public Entity getControllingPassenger() { - List list = this.getPassengers(); - return list.isEmpty() ? null : list.get(0); - } - - @OnlyIn(Dist.CLIENT) - @Override - public void updateInputs(boolean p_184442_1_, boolean p_184442_2_, boolean p_184442_3_, boolean p_184442_4_) { - this.leftInputDown = p_184442_1_; - this.rightInputDown = p_184442_2_; - this.forwardInputDown = p_184442_3_; - this.backInputDown = p_184442_4_; - } - - // Forge: Fix MC-119811 by instantly completing lerp on board - @Override - protected void addPassenger(Entity passenger) { - super.addPassenger(passenger); - if (this.canPassengerSteer() && this.lerpSteps > 0) { - this.lerpSteps = 0; - this.posX = this.lerpX; - this.posY = this.lerpY; - this.posZ = this.lerpZ; - this.rotationYaw = (float)this.lerpYaw; - this.rotationPitch = (float)this.lerpPitch; - } - } - - public static enum Status { - IN_WATER, - UNDER_WATER, - UNDER_FLOWING_WATER, - ON_LAND, - IN_AIR; - } - - public static enum Type { - FIR(BOPBlocks.fir_planks, "fir"), - REDWOOD(BOPBlocks.redwood_planks, "redwood"), - CHERRY(BOPBlocks.cherry_planks, "cherry"), - MAHOGANY(BOPBlocks.mahogany_planks, "mahogany"), - JACARANDA(BOPBlocks.jacaranda_planks, "jacaranda"), - PALM(BOPBlocks.palm_planks, "palm"), - WILLOW(BOPBlocks.willow_planks, "willow"), - DEAD(BOPBlocks.dead_planks, "dead"), - MAGIC(BOPBlocks.magic_planks, "magic"), - UMBRAN(BOPBlocks.umbran_planks, "umbran"), - HELLBARK(BOPBlocks.hellbark_planks, "hellbark"), - ETHEREAL(BOPBlocks.ethereal_planks, "ethereal"); - - private final String name; - private final Block block; - - private Type(Block p_i48146_3_, String p_i48146_4_) { - this.name = p_i48146_4_; - this.block = p_i48146_3_; - } - - public String getName() { - return this.name; - } - - public Block asPlank() { - return this.block; - } - - public String toString() { - return this.name; - } - - /** - * Get a boat type by it's enum ordinal - */ - public static EntityBoatBOP.Type byId(int id) { - EntityBoatBOP.Type[] aentityboat$type = values(); - if (id < 0 || id >= aentityboat$type.length) { - id = 0; - } - - return aentityboat$type[id]; - } - - public static EntityBoatBOP.Type getTypeFromString(String nameIn) { - EntityBoatBOP.Type[] aentityboat$type = values(); - - for(int i = 0; i < aentityboat$type.length; ++i) { - if (aentityboat$type[i].getName().equals(nameIn)) { - return aentityboat$type[i]; - } - } - - return aentityboat$type[0]; - } - } - } \ No newline at end of file + private static final DataParameter TIME_SINCE_HIT = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); + private static final DataParameter FORWARD_DIRECTION = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); + private static final DataParameter DAMAGE_TAKEN = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.FLOAT); + private static final DataParameter BOAT_TYPE = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); + private static final DataParameter field_199704_e = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.BOOLEAN); + private static final DataParameter field_199705_f = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.BOOLEAN); + private static final DataParameter ROCKING_TICKS = EntityDataManager.createKey(EntityBoatBOP.class, DataSerializers.VARINT); + private final float[] paddlePositions = new float[2]; + private float momentum; + private float outOfControlTicks; + private float deltaRotation; + private int lerpSteps; + private double lerpX; + private double lerpY; + private double lerpZ; + private double lerpYaw; + private double lerpPitch; + private boolean leftInputDown; + private boolean rightInputDown; + private boolean forwardInputDown; + private boolean backInputDown; + private double waterLevel; + private float boatGlide; + private EntityBoatBOP.Status status; + private EntityBoatBOP.Status previousStatus; + private double lastYd; + private boolean rocking; + private boolean field_203060_aN; + private float rockingIntensity; + private float rockingAngle; + private float prevRockingAngle; + + public EntityBoatBOP(EntityType p_i50129_1_, World p_i50129_2_) { + super(p_i50129_1_, p_i50129_2_); + this.preventEntitySpawning = true; + } + + public EntityBoatBOP(World worldIn, double x, double y, double z) { + this((EntityType)BOPEntities.boat_bop, worldIn); + this.setPosition(x, y, z); + this.setMotion(Vec3d.ZERO); + this.prevPosX = x; + this.prevPosY = y; + this.prevPosZ = z; + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + protected boolean canTriggerWalking() { + return false; + } + + protected void registerData() { + this.dataManager.register(TIME_SINCE_HIT, 0); + this.dataManager.register(FORWARD_DIRECTION, 1); + this.dataManager.register(DAMAGE_TAKEN, 0.0F); + this.dataManager.register(BOAT_TYPE, EntityBoatBOP.Type.FIR.ordinal()); + this.dataManager.register(field_199704_e, false); + this.dataManager.register(field_199705_f, false); + this.dataManager.register(ROCKING_TICKS, 0); + } + + /** + * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be + * pushable on contact, like boats or minecarts. + */ + @Nullable + public AxisAlignedBB getCollisionBox(Entity entityIn) { + return entityIn.canBePushed() ? entityIn.getBoundingBox() : null; + } + + @Nullable + public AxisAlignedBB getCollisionBoundingBox() { + return this.getBoundingBox(); + } + + /** + * Returns true if this entity should push and be pushed by other entities when colliding. + */ + public boolean canBePushed() { + return true; + } + + /** + * Returns the Y offset from the entity's position for any entity riding this one. + */ + public double getMountedYOffset() { + return -0.1D; + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource source, float amount) { + if (this.isInvulnerableTo(source)) { + return false; + } else if (!this.world.isRemote && !this.removed) { + if (source instanceof IndirectEntityDamageSource && source.getTrueSource() != null && this.isPassenger(source.getTrueSource())) { + return false; + } else { + this.setForwardDirection(-this.getForwardDirection()); + this.setTimeSinceHit(10); + this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); + this.markVelocityChanged(); + boolean flag = source.getTrueSource() instanceof PlayerEntity && ((PlayerEntity)source.getTrueSource()).abilities.isCreativeMode; + if (flag || this.getDamageTaken() > 40.0F) { + if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { + this.entityDropItem(this.getItemBoat()); + } + + this.remove(); + } + + return true; + } + } else { + return true; + } + } + + public void onEnterBubbleColumnWithAirAbove(boolean downwards) { + if (!this.world.isRemote) { + this.rocking = true; + this.field_203060_aN = downwards; + if (this.getRockingTicks() == 0) { + this.setRockingTicks(60); + } + } + + this.world.addParticle(ParticleTypes.SPLASH, this.posX + (double)this.rand.nextFloat(), this.posY + 0.7D, this.posZ + (double)this.rand.nextFloat(), 0.0D, 0.0D, 0.0D); + if (this.rand.nextInt(20) == 0) { + this.world.playSound(this.posX, this.posY, this.posZ, this.getSplashSound(), this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat(), false); + } + + } + + /** + * Applies a velocity to the entities, to push them away from eachother. + */ + public void applyEntityCollision(Entity entityIn) { + if (entityIn instanceof EntityBoatBOP) { + if (entityIn.getBoundingBox().minY < this.getBoundingBox().maxY) { + super.applyEntityCollision(entityIn); + } + } else if (entityIn.getBoundingBox().minY <= this.getBoundingBox().minY) { + super.applyEntityCollision(entityIn); + } + + } + + @Override + public Item getItemBoat() + { + switch(this.getBOPBoatType()) + { + case FIR: + default: + return BOPItems.fir_boat; + case REDWOOD: + return BOPItems.redwood_boat; + case CHERRY: + return BOPItems.cherry_boat; + case MAHOGANY: + return BOPItems.mahogany_boat; + case JACARANDA: + return BOPItems.jacaranda_boat; + case PALM: + return BOPItems.palm_boat; + case WILLOW: + return BOPItems.willow_boat; + case DEAD: + return BOPItems.dead_boat; + case MAGIC: + return BOPItems.magic_boat; + case UMBRAN: + return BOPItems.umbran_boat; + case HELLBARK: + return BOPItems.hellbark_boat; + case ETHEREAL: + return BOPItems.ethereal_boat; + } + } + + /** + * Setups the entity to do the hurt animation. Only used by packets in multiplayer. + */ + @OnlyIn(Dist.CLIENT) + public void performHurtAnimation() { + this.setForwardDirection(-this.getForwardDirection()); + this.setTimeSinceHit(10); + this.setDamageTaken(this.getDamageTaken() * 11.0F); + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + public boolean canBeCollidedWith() { + return !this.removed; + } + + /** + * Sets a target for the client to interpolate towards over the next few ticks + */ + @OnlyIn(Dist.CLIENT) + public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport) { + this.lerpX = x; + this.lerpY = y; + this.lerpZ = z; + this.lerpYaw = (double)yaw; + this.lerpPitch = (double)pitch; + this.lerpSteps = 10; + } + + /** + * Gets the horizontal facing direction of this Entity, adjusted to take specially-treated entity types into account. + */ + public Direction getAdjustedHorizontalFacing() { + return this.getHorizontalFacing().rotateY(); + } + + /** + * Called to update the entity's position/logic. + */ + public void tick() { + this.previousStatus = this.status; + this.status = this.getBoatStatus(); + if (this.status != EntityBoatBOP.Status.UNDER_WATER && this.status != EntityBoatBOP.Status.UNDER_FLOWING_WATER) { + this.outOfControlTicks = 0.0F; + } else { + ++this.outOfControlTicks; + } + + if (!this.world.isRemote && this.outOfControlTicks >= 60.0F) { + this.removePassengers(); + } + + if (this.getTimeSinceHit() > 0) { + this.setTimeSinceHit(this.getTimeSinceHit() - 1); + } + + if (this.getDamageTaken() > 0.0F) { + this.setDamageTaken(this.getDamageTaken() - 1.0F); + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + super.tick(); + this.tickLerp(); + if (this.canPassengerSteer()) { + if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof PlayerEntity)) { + this.setPaddleState(false, false); + } + + this.updateMotion(); + if (this.world.isRemote) { + this.controlBoat(); + this.world.sendPacketToServer(new CSteerBoatPacket(this.getPaddleState(0), this.getPaddleState(1))); + } + + this.move(MoverType.SELF, this.getMotion()); + } else { + this.setMotion(Vec3d.ZERO); + } + + this.updateRocking(); + + for(int i = 0; i <= 1; ++i) { + if (this.getPaddleState(i)) { + if (!this.isSilent() && (double)(this.paddlePositions[i] % ((float)Math.PI * 2F)) <= (double)((float)Math.PI / 4F) && ((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)) % (double)((float)Math.PI * 2F) >= (double)((float)Math.PI / 4F)) { + SoundEvent soundevent = this.getPaddleSound(); + if (soundevent != null) { + Vec3d vec3d = this.getLook(1.0F); + double d0 = i == 1 ? -vec3d.z : vec3d.z; + double d1 = i == 1 ? vec3d.x : -vec3d.x; + this.world.playSound((PlayerEntity)null, this.posX + d0, this.posY, this.posZ + d1, soundevent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat()); + } + } + + this.paddlePositions[i] = (float)((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)); + } else { + this.paddlePositions[i] = 0.0F; + } + } + + this.doBlockCollisions(); + List list = this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox().grow((double)0.2F, (double)-0.01F, (double)0.2F), EntityPredicates.pushableBy(this)); + if (!list.isEmpty()) { + boolean flag = !this.world.isRemote && !(this.getControllingPassenger() instanceof PlayerEntity); + + for(int j = 0; j < list.size(); ++j) { + Entity entity = list.get(j); + if (!entity.isPassenger(this)) { + if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.getWidth() < this.getWidth() && entity instanceof LivingEntity && !(entity instanceof WaterMobEntity) && !(entity instanceof PlayerEntity)) { + entity.startRiding(this); + } else { + this.applyEntityCollision(entity); + } + } + } + } + + } + + private void updateRocking() { + if (this.world.isRemote) { + int i = this.getRockingTicks(); + if (i > 0) { + this.rockingIntensity += 0.05F; + } else { + this.rockingIntensity -= 0.1F; + } + + this.rockingIntensity = MathHelper.clamp(this.rockingIntensity, 0.0F, 1.0F); + this.prevRockingAngle = this.rockingAngle; + this.rockingAngle = 10.0F * (float)Math.sin((double)(0.5F * (float)this.world.getGameTime())) * this.rockingIntensity; + } else { + if (!this.rocking) { + this.setRockingTicks(0); + } + + int k = this.getRockingTicks(); + if (k > 0) { + --k; + this.setRockingTicks(k); + int j = 60 - k - 1; + if (j > 0 && k == 0) { + this.setRockingTicks(0); + Vec3d vec3d = this.getMotion(); + if (this.field_203060_aN) { + this.setMotion(vec3d.add(0.0D, -0.7D, 0.0D)); + this.removePassengers(); + } else { + this.setMotion(vec3d.x, this.isPassenger(PlayerEntity.class) ? 2.7D : 0.6D, vec3d.z); + } + } + + this.rocking = false; + } + } + + } + + @Nullable + protected SoundEvent getPaddleSound() { + switch(this.getBoatStatus()) { + case IN_WATER: + case UNDER_WATER: + case UNDER_FLOWING_WATER: + return SoundEvents.ENTITY_BOAT_PADDLE_WATER; + case ON_LAND: + return SoundEvents.ENTITY_BOAT_PADDLE_LAND; + case IN_AIR: + default: + return null; + } + } + + private void tickLerp() { + if (this.lerpSteps > 0 && !this.canPassengerSteer()) { + double d0 = this.posX + (this.lerpX - this.posX) / (double)this.lerpSteps; + double d1 = this.posY + (this.lerpY - this.posY) / (double)this.lerpSteps; + double d2 = this.posZ + (this.lerpZ - this.posZ) / (double)this.lerpSteps; + double d3 = MathHelper.wrapDegrees(this.lerpYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.lerpSteps); + this.rotationPitch = (float)((double)this.rotationPitch + (this.lerpPitch - (double)this.rotationPitch) / (double)this.lerpSteps); + --this.lerpSteps; + this.setPosition(d0, d1, d2); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + + public void setPaddleState(boolean left, boolean right) { + this.dataManager.set(field_199704_e, left); + this.dataManager.set(field_199705_f, right); + } + + @OnlyIn(Dist.CLIENT) + public float getRowingTime(int side, float limbSwing) { + return this.getPaddleState(side) ? (float)MathHelper.clampedLerp((double)this.paddlePositions[side] - (double)((float)Math.PI / 8F), (double)this.paddlePositions[side], (double)limbSwing) : 0.0F; + } + + /** + * Determines whether the boat is in water, gliding on land, or in air + */ + private EntityBoatBOP.Status getBoatStatus() { + EntityBoatBOP.Status boatentity$status = this.getUnderwaterStatus(); + if (boatentity$status != null) { + this.waterLevel = this.getBoundingBox().maxY; + return boatentity$status; + } else if (this.checkInWater()) { + return EntityBoatBOP.Status.IN_WATER; + } else { + float f = this.getBoatGlide(); + if (f > 0.0F) { + this.boatGlide = f; + return EntityBoatBOP.Status.ON_LAND; + } else { + return EntityBoatBOP.Status.IN_AIR; + } + } + } + + public float getWaterLevelAbove() { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + int i = MathHelper.floor(axisalignedbb.minX); + int j = MathHelper.ceil(axisalignedbb.maxX); + int k = MathHelper.floor(axisalignedbb.maxY); + int l = MathHelper.ceil(axisalignedbb.maxY - this.lastYd); + int i1 = MathHelper.floor(axisalignedbb.minZ); + int j1 = MathHelper.ceil(axisalignedbb.maxZ); + + try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { + label161: + for(int k1 = k; k1 < l; ++k1) { + float f = 0.0F; + + for(int l1 = i; l1 < j; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutableblockpos.setPos(l1, k1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); + if (ifluidstate.isTagged(FluidTags.WATER)) { + f = Math.max(f, ifluidstate.func_215679_a(this.world, blockpos$pooledmutableblockpos)); + } + + if (f >= 1.0F) { + continue label161; + } + } + } + + if (f < 1.0F) { + float f2 = (float)blockpos$pooledmutableblockpos.getY() + f; + return f2; + } + } + + float f1 = (float)(l + 1); + return f1; + } + } + + /** + * Decides how much the boat should be gliding on the land (based on any slippery blocks) + */ + public float getBoatGlide() { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + AxisAlignedBB axisalignedbb1 = new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY - 0.001D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); + int i = MathHelper.floor(axisalignedbb1.minX) - 1; + int j = MathHelper.ceil(axisalignedbb1.maxX) + 1; + int k = MathHelper.floor(axisalignedbb1.minY) - 1; + int l = MathHelper.ceil(axisalignedbb1.maxY) + 1; + int i1 = MathHelper.floor(axisalignedbb1.minZ) - 1; + int j1 = MathHelper.ceil(axisalignedbb1.maxZ) + 1; + VoxelShape voxelshape = VoxelShapes.create(axisalignedbb1); + float f = 0.0F; + int k1 = 0; + + try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { + for(int l1 = i; l1 < j; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + int j2 = (l1 != i && l1 != j - 1 ? 0 : 1) + (i2 != i1 && i2 != j1 - 1 ? 0 : 1); + if (j2 != 2) { + for(int k2 = k; k2 < l; ++k2) { + if (j2 <= 0 || k2 != k && k2 != l - 1) { + blockpos$pooledmutableblockpos.setPos(l1, k2, i2); + BlockState blockstate = this.world.getBlockState(blockpos$pooledmutableblockpos); + if (!(blockstate.getBlock() instanceof LilyPadBlock) && VoxelShapes.compare(blockstate.getCollisionShape(this.world, blockpos$pooledmutableblockpos).withOffset((double)l1, (double)k2, (double)i2), voxelshape, IBooleanFunction.AND)) { + f += blockstate.getSlipperiness(this.world, blockpos$pooledmutableblockpos, this); + ++k1; + } + } + } + } + } + } + } + + return f / (float)k1; + } + + private boolean checkInWater() { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + int i = MathHelper.floor(axisalignedbb.minX); + int j = MathHelper.ceil(axisalignedbb.maxX); + int k = MathHelper.floor(axisalignedbb.minY); + int l = MathHelper.ceil(axisalignedbb.minY + 0.001D); + int i1 = MathHelper.floor(axisalignedbb.minZ); + int j1 = MathHelper.ceil(axisalignedbb.maxZ); + boolean flag = false; + this.waterLevel = Double.MIN_VALUE; + + try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { + for(int k1 = i; k1 < j; ++k1) { + for(int l1 = k; l1 < l; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutableblockpos.setPos(k1, l1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); + if (ifluidstate.isTagged(FluidTags.WATER)) { + float f = (float)l1 + ifluidstate.func_215679_a(this.world, blockpos$pooledmutableblockpos); + this.waterLevel = Math.max((double)f, this.waterLevel); + flag |= axisalignedbb.minY < (double)f; + } + } + } + } + } + + return flag; + } + + /** + * Decides whether the boat is currently underwater. + */ + @Nullable + private EntityBoatBOP.Status getUnderwaterStatus() { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + double d0 = axisalignedbb.maxY + 0.001D; + int i = MathHelper.floor(axisalignedbb.minX); + int j = MathHelper.ceil(axisalignedbb.maxX); + int k = MathHelper.floor(axisalignedbb.maxY); + int l = MathHelper.ceil(d0); + int i1 = MathHelper.floor(axisalignedbb.minZ); + int j1 = MathHelper.ceil(axisalignedbb.maxZ); + boolean flag = false; + + try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { + for(int k1 = i; k1 < j; ++k1) { + for(int l1 = k; l1 < l; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutableblockpos.setPos(k1, l1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); + if (ifluidstate.isTagged(FluidTags.WATER) && d0 < (double)((float)blockpos$pooledmutableblockpos.getY() + ifluidstate.func_215679_a(this.world, blockpos$pooledmutableblockpos))) { + if (!ifluidstate.isSource()) { + EntityBoatBOP.Status boatentity$status = EntityBoatBOP.Status.UNDER_FLOWING_WATER; + return boatentity$status; + } + + flag = true; + } + } + } + } + } + + return flag ? EntityBoatBOP.Status.UNDER_WATER : null; + } + + /** + * Update the boat's speed, based on momentum. + */ + private void updateMotion() { + double d0 = (double)-0.04F; + double d1 = this.hasNoGravity() ? 0.0D : (double)-0.04F; + double d2 = 0.0D; + this.momentum = 0.05F; + if (this.previousStatus == EntityBoatBOP.Status.IN_AIR && this.status != EntityBoatBOP.Status.IN_AIR && this.status != EntityBoatBOP.Status.ON_LAND) { + this.waterLevel = this.getBoundingBox().minY + (double)this.getHeight(); + this.setPosition(this.posX, (double)(this.getWaterLevelAbove() - this.getHeight()) + 0.101D, this.posZ); + this.setMotion(this.getMotion().mul(1.0D, 0.0D, 1.0D)); + this.lastYd = 0.0D; + this.status = EntityBoatBOP.Status.IN_WATER; + } else { + if (this.status == EntityBoatBOP.Status.IN_WATER) { + d2 = (this.waterLevel - this.getBoundingBox().minY) / (double)this.getHeight(); + this.momentum = 0.9F; + } else if (this.status == EntityBoatBOP.Status.UNDER_FLOWING_WATER) { + d1 = -7.0E-4D; + this.momentum = 0.9F; + } else if (this.status == EntityBoatBOP.Status.UNDER_WATER) { + d2 = (double)0.01F; + this.momentum = 0.45F; + } else if (this.status == EntityBoatBOP.Status.IN_AIR) { + this.momentum = 0.9F; + } else if (this.status == EntityBoatBOP.Status.ON_LAND) { + this.momentum = this.boatGlide; + if (this.getControllingPassenger() instanceof PlayerEntity) { + this.boatGlide /= 2.0F; + } + } + + Vec3d vec3d = this.getMotion(); + this.setMotion(vec3d.x * (double)this.momentum, vec3d.y + d1, vec3d.z * (double)this.momentum); + this.deltaRotation *= this.momentum; + if (d2 > 0.0D) { + Vec3d vec3d1 = this.getMotion(); + this.setMotion(vec3d1.x, (vec3d1.y + d2 * 0.06153846016296973D) * 0.75D, vec3d1.z); + } + } + + } + + private void controlBoat() { + if (this.isBeingRidden()) { + float f = 0.0F; + if (this.leftInputDown) { + --this.deltaRotation; + } + + if (this.rightInputDown) { + ++this.deltaRotation; + } + + if (this.rightInputDown != this.leftInputDown && !this.forwardInputDown && !this.backInputDown) { + f += 0.005F; + } + + this.rotationYaw += this.deltaRotation; + if (this.forwardInputDown) { + f += 0.04F; + } + + if (this.backInputDown) { + f -= 0.005F; + } + + this.setMotion(this.getMotion().add((double)(MathHelper.sin(-this.rotationYaw * ((float)Math.PI / 180F)) * f), 0.0D, (double)(MathHelper.cos(this.rotationYaw * ((float)Math.PI / 180F)) * f))); + this.setPaddleState(this.rightInputDown && !this.leftInputDown || this.forwardInputDown, this.leftInputDown && !this.rightInputDown || this.forwardInputDown); + } + } + + public void updatePassenger(Entity passenger) { + if (this.isPassenger(passenger)) { + float f = 0.0F; + float f1 = (float)((this.removed ? (double)0.01F : this.getMountedYOffset()) + passenger.getYOffset()); + if (this.getPassengers().size() > 1) { + int i = this.getPassengers().indexOf(passenger); + if (i == 0) { + f = 0.2F; + } else { + f = -0.6F; + } + + if (passenger instanceof AnimalEntity) { + f = (float)((double)f + 0.2D); + } + } + + Vec3d vec3d = (new Vec3d((double)f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * ((float)Math.PI / 180F) - ((float)Math.PI / 2F)); + passenger.setPosition(this.posX + vec3d.x, this.posY + (double)f1, this.posZ + vec3d.z); + passenger.rotationYaw += this.deltaRotation; + passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); + this.applyYawToEntity(passenger); + if (passenger instanceof AnimalEntity && this.getPassengers().size() > 1) { + int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; + passenger.setRenderYawOffset(((AnimalEntity)passenger).renderYawOffset + (float)j); + passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); + } + + } + } + + /** + * Applies this boat's yaw to the given entity. Used to update the orientation of its passenger. + */ + protected void applyYawToEntity(Entity entityToUpdate) { + entityToUpdate.setRenderYawOffset(this.rotationYaw); + float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - this.rotationYaw); + float f1 = MathHelper.clamp(f, -105.0F, 105.0F); + entityToUpdate.prevRotationYaw += f1 - f; + entityToUpdate.rotationYaw += f1 - f; + entityToUpdate.setRotationYawHead(entityToUpdate.rotationYaw); + } + + /** + * Applies this entity's orientation (pitch/yaw) to another entity. Used to update passenger orientation. + */ + @OnlyIn(Dist.CLIENT) + public void applyOrientationToEntity(Entity entityToUpdate) { + this.applyYawToEntity(entityToUpdate); + } + + protected void writeAdditional(CompoundNBT compound) { + compound.putString("Type", this.getBoatType().getName()); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + protected void readAdditional(CompoundNBT compound) { + if (compound.contains("Type", 8)) { + this.setBoatType(EntityBoatBOP.Type.getTypeFromString(compound.getString("Type"))); + } + + } + + public boolean processInitialInteract(PlayerEntity player, Hand hand) { + if (player.isSneaking()) { + return false; + } else { + if (!this.world.isRemote && this.outOfControlTicks < 60.0F) { + player.startRiding(this); + } + + return true; + } + } + + protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) { + this.lastYd = this.getMotion().y; + if (!this.isPassenger()) { + if (onGroundIn) { + if (this.fallDistance > 3.0F) { + if (this.status != EntityBoatBOP.Status.ON_LAND) { + this.fallDistance = 0.0F; + return; + } + + this.fall(this.fallDistance, 1.0F); + if (!this.world.isRemote && !this.removed) { + this.remove(); + if (this.world.getGameRules().getBoolean("doEntityDrops")) { + for(int i = 0; i < 3; ++i) { + this.entityDropItem(this.getBoatType().asPlank()); + } + + for(int j = 0; j < 2; ++j) { + this.entityDropItem(Items.STICK); + } + } + } + } + + this.fallDistance = 0.0F; + } else if (!this.world.getFluidState((new BlockPos(this)).down()).isTagged(FluidTags.WATER) && y < 0.0D) { + this.fallDistance = (float)((double)this.fallDistance - y); + } + + } + } + + public boolean getPaddleState(int side) { + return this.dataManager.get(side == 0 ? field_199704_e : field_199705_f) && this.getControllingPassenger() != null; + } + + /** + * Sets the damage taken from the last hit. + */ + public void setDamageTaken(float damageTaken) { + this.dataManager.set(DAMAGE_TAKEN, damageTaken); + } + + /** + * Gets the damage taken from the last hit. + */ + public float getDamageTaken() { + return this.dataManager.get(DAMAGE_TAKEN); + } + + /** + * Sets the time to count down from since the last time entity was hit. + */ + public void setTimeSinceHit(int timeSinceHit) { + this.dataManager.set(TIME_SINCE_HIT, timeSinceHit); + } + + /** + * Gets the time since the last hit. + */ + public int getTimeSinceHit() { + return this.dataManager.get(TIME_SINCE_HIT); + } + + private void setRockingTicks(int p_203055_1_) { + this.dataManager.set(ROCKING_TICKS, p_203055_1_); + } + + private int getRockingTicks() { + return this.dataManager.get(ROCKING_TICKS); + } + + @OnlyIn(Dist.CLIENT) + public float getRockingAngle(float partialTicks) { + return MathHelper.lerp(partialTicks, this.prevRockingAngle, this.rockingAngle); + } + + /** + * Sets the forward direction of the entity. + */ + public void setForwardDirection(int forwardDirection) { + this.dataManager.set(FORWARD_DIRECTION, forwardDirection); + } + + /** + * Gets the forward direction of the entity. + */ + public int getForwardDirection() { + return this.dataManager.get(FORWARD_DIRECTION); + } + + public void setBoatType(EntityBoatBOP.Type boatType) { + this.dataManager.set(BOAT_TYPE, boatType.ordinal()); + } + + public EntityBoatBOP.Type getBOPBoatType() + { + return EntityBoatBOP.Type.byId(this.dataManager.get(BOAT_TYPE)); + } + + protected boolean canFitPassenger(Entity passenger) { + return this.getPassengers().size() < 2 && !this.areEyesInFluid(FluidTags.WATER); + } + + /** + * For vehicles, the first passenger is generally considered the controller and "drives" the vehicle. For example, + * Pigs, Horses, and Boats are generally "steered" by the controlling passenger. + */ + @Nullable + public Entity getControllingPassenger() { + List list = this.getPassengers(); + return list.isEmpty() ? null : list.get(0); + } + + @OnlyIn(Dist.CLIENT) + public void updateInputs(boolean p_184442_1_, boolean p_184442_2_, boolean p_184442_3_, boolean p_184442_4_) { + this.leftInputDown = p_184442_1_; + this.rightInputDown = p_184442_2_; + this.forwardInputDown = p_184442_3_; + this.backInputDown = p_184442_4_; + } + + public IPacket createSpawnPacket() { + return new SSpawnObjectPacket(this); + } + + // Forge: Fix MC-119811 by instantly completing lerp on board + @Override + protected void addPassenger(Entity passenger) { + super.addPassenger(passenger); + if (this.canPassengerSteer() && this.lerpSteps > 0) { + this.lerpSteps = 0; + this.posX = this.lerpX; + this.posY = this.lerpY; + this.posZ = this.lerpZ; + this.rotationYaw = (float)this.lerpYaw; + this.rotationPitch = (float)this.lerpPitch; + } + } + + public static enum Status { + IN_WATER, + UNDER_WATER, + UNDER_FLOWING_WATER, + ON_LAND, + IN_AIR; + } + + public static enum Type + { + FIR(BOPBlocks.fir_planks, "fir"), + REDWOOD(BOPBlocks.redwood_planks, "redwood"), + CHERRY(BOPBlocks.cherry_planks, "cherry"), + MAHOGANY(BOPBlocks.mahogany_planks, "mahogany"), + JACARANDA(BOPBlocks.jacaranda_planks, "jacaranda"), + PALM(BOPBlocks.palm_planks, "palm"), + WILLOW(BOPBlocks.willow_planks, "willow"), + DEAD(BOPBlocks.dead_planks, "dead"), + MAGIC(BOPBlocks.magic_planks, "magic"), + UMBRAN(BOPBlocks.umbran_planks, "umbran"), + HELLBARK(BOPBlocks.hellbark_planks, "hellbark"), + ETHEREAL(BOPBlocks.ethereal_planks, "ethereal"); + + private final String name; + private final Block block; + + private Type(Block p_i48146_3_, String p_i48146_4_) { + this.name = p_i48146_4_; + this.block = p_i48146_3_; + } + + public String getName() { + return this.name; + } + + public Block asPlank() { + return this.block; + } + + public String toString() { + return this.name; + } + + /** + * Get a boat type by it's enum ordinal + */ + public static EntityBoatBOP.Type byId(int id) { + EntityBoatBOP.Type[] aentityboat$type = values(); + if (id < 0 || id >= aentityboat$type.length) { + id = 0; + } + + return aentityboat$type[id]; + } + + public static EntityBoatBOP.Type getTypeFromString(String nameIn) { + EntityBoatBOP.Type[] aentityboat$type = values(); + + for(int i = 0; i < aentityboat$type.length; ++i) { + if (aentityboat$type[i].getName().equals(nameIn)) { + return aentityboat$type[i]; + } + } + + return aentityboat$type[0]; + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/item/ModelBoatBOP.java b/src/main/java/biomesoplenty/common/entity/item/ModelBoatBOP.java deleted file mode 100644 index 79f6cfece..000000000 --- a/src/main/java/biomesoplenty/common/entity/item/ModelBoatBOP.java +++ /dev/null @@ -1,107 +0,0 @@ -package biomesoplenty.common.entity.item; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.model.IMultipassModel; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -@OnlyIn(Dist.CLIENT) -public class ModelBoatBOP extends ModelBase implements IMultipassModel { - private final ModelRenderer[] boatSides = new ModelRenderer[5]; - private final ModelRenderer[] paddles = new ModelRenderer[2]; - /** - * An invisible layer that is rendered to make it seem like there's no water in the boat. - * - * @see https://redd.it/3qufgo - * @see https://bugs.mojang.com/browse/MC-47636 - */ - private final ModelRenderer noWater; - - public ModelBoatBOP() { - this.boatSides[0] = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); - this.boatSides[1] = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64); - this.boatSides[2] = (new ModelRenderer(this, 0, 27)).setTextureSize(128, 64); - this.boatSides[3] = (new ModelRenderer(this, 0, 35)).setTextureSize(128, 64); - this.boatSides[4] = (new ModelRenderer(this, 0, 43)).setTextureSize(128, 64); - int i = 32; - int j = 6; - int k = 20; - int l = 4; - int i1 = 28; - this.boatSides[0].addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F); - this.boatSides[0].setRotationPoint(0.0F, 3.0F, 1.0F); - this.boatSides[1].addBox(-13.0F, -7.0F, -1.0F, 18, 6, 2, 0.0F); - this.boatSides[1].setRotationPoint(-15.0F, 4.0F, 4.0F); - this.boatSides[2].addBox(-8.0F, -7.0F, -1.0F, 16, 6, 2, 0.0F); - this.boatSides[2].setRotationPoint(15.0F, 4.0F, 0.0F); - this.boatSides[3].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F); - this.boatSides[3].setRotationPoint(0.0F, 4.0F, -9.0F); - this.boatSides[4].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F); - this.boatSides[4].setRotationPoint(0.0F, 4.0F, 9.0F); - this.boatSides[0].rotateAngleX = ((float)Math.PI / 2F); - this.boatSides[1].rotateAngleY = ((float)Math.PI * 1.5F); - this.boatSides[2].rotateAngleY = ((float)Math.PI / 2F); - this.boatSides[3].rotateAngleY = (float)Math.PI; - this.paddles[0] = this.makePaddle(true); - this.paddles[0].setRotationPoint(3.0F, -5.0F, 9.0F); - this.paddles[1] = this.makePaddle(false); - this.paddles[1].setRotationPoint(3.0F, -5.0F, -9.0F); - this.paddles[1].rotateAngleY = (float)Math.PI; - this.paddles[0].rotateAngleZ = 0.19634955F; - this.paddles[1].rotateAngleZ = 0.19634955F; - this.noWater = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); - this.noWater.addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F); - this.noWater.setRotationPoint(0.0F, -3.0F, 1.0F); - this.noWater.rotateAngleX = ((float)Math.PI / 2F); - } - - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F); - EntityBoatBOP entityboat = (EntityBoatBOP)entityIn; - this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); - - for(int i = 0; i < 5; ++i) { - this.boatSides[i].render(scale); - } - - this.renderPaddle(entityboat, 0, scale, limbSwing); - this.renderPaddle(entityboat, 1, scale, limbSwing); - } - - public void renderMultipass(Entity entityIn, float partialTicks, float p_187054_3_, float p_187054_4_, float p_187054_5_, float p_187054_6_, float scale) { - GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.colorMask(false, false, false, false); - this.noWater.render(scale); - GlStateManager.colorMask(true, true, true, true); - } - - protected ModelRenderer makePaddle(boolean p_187056_1_) { - ModelRenderer modelrenderer = (new ModelRenderer(this, 62, p_187056_1_ ? 0 : 20)).setTextureSize(128, 64); - int i = 20; - int j = 7; - int k = 6; - float f = -5.0F; - modelrenderer.addBox(-1.0F, 0.0F, -5.0F, 2, 2, 18); - modelrenderer.addBox(p_187056_1_ ? -1.001F : 0.001F, -3.0F, 8.0F, 1, 6, 7); - return modelrenderer; - } - - protected void renderPaddle(EntityBoatBOP boat, int paddle, float scale, float limbSwing) { - float f = boat.getRowingTime(paddle, limbSwing); - ModelRenderer modelrenderer = this.paddles[paddle]; - modelrenderer.rotateAngleX = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 3F), (double)-0.2617994F, (double)((MathHelper.sin(-f) + 1.0F) / 2.0F)); - modelrenderer.rotateAngleY = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 4F), (double)((float)Math.PI / 4F), (double)((MathHelper.sin(-f + 1.0F) + 1.0F) / 2.0F)); - if (paddle == 1) { - modelrenderer.rotateAngleY = (float)Math.PI - modelrenderer.rotateAngleY; - } - - modelrenderer.render(scale); - } -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/item/RenderBoatBOP.java b/src/main/java/biomesoplenty/common/entity/item/RenderBoatBOP.java index a50bb1246..c661b51ac 100644 --- a/src/main/java/biomesoplenty/common/entity/item/RenderBoatBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/RenderBoatBOP.java @@ -3,6 +3,7 @@ package biomesoplenty.common.entity.item; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.model.BoatModel; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; @@ -13,7 +14,7 @@ public class RenderBoatBOP extends EntityRenderer { private static final ResourceLocation[] BOAT_TEXTURES = new ResourceLocation[]{new ResourceLocation("biomesoplenty:textures/entity/boat/fir.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/redwood.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/cherry.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/mahogany.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/jacaranda.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/palm.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/willow.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/dead.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/magic.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/umbran.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/hellbark.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/ethereal.png")}; /** instance of ModelBoat for rendering */ - protected ModelBase modelBoat = new ModelBoatBOP(); + protected BoatModel modelBoat = new BoatModel(); public RenderBoatBOP(EntityRendererManager renderManagerIn) { super(renderManagerIn); @@ -30,12 +31,12 @@ public class RenderBoatBOP extends EntityRenderer this.bindEntityTexture(entity); if (this.renderOutlines) { GlStateManager.enableColorMaterial(); - GlStateManager.enableOutlineMode(this.getTeamColor(entity)); + GlStateManager.setupSolidRenderingTextureCombine(this.getTeamColor(entity)); } this.modelBoat.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (this.renderOutlines) { - GlStateManager.disableOutlineMode(); + GlStateManager.tearDownSolidRenderingTextureCombine(); GlStateManager.disableColorMaterial(); } @@ -83,7 +84,7 @@ public class RenderBoatBOP extends EntityRenderer this.setupTranslation(x, y, z); this.setupRotation(entityIn, entityYaw, partialTicks); this.bindEntityTexture(entityIn); - ((IMultipassModel)this.modelBoat).renderMultipass(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + this.modelBoat.renderMultipass(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GlStateManager.popMatrix(); } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/projectile/EntityMudball.java b/src/main/java/biomesoplenty/common/entity/projectile/EntityMudball.java index 8bc1477e9..fa0fca9aa 100644 --- a/src/main/java/biomesoplenty/common/entity/projectile/EntityMudball.java +++ b/src/main/java/biomesoplenty/common/entity/projectile/EntityMudball.java @@ -8,21 +8,26 @@ package biomesoplenty.common.entity.projectile; import biomesoplenty.api.entity.BOPEntities; +import biomesoplenty.api.item.BOPItems; import biomesoplenty.api.particle.BOPParticleTypes; import biomesoplenty.core.BiomesOPlenty; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.ProjectileItemEntity; +import net.minecraft.item.Item; import net.minecraft.util.DamageSource; +import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class EntityMudball extends EntityThrowable +public class EntityMudball extends ProjectileItemEntity { - public EntityMudball(World world) + public EntityMudball(EntityType type, World world) { - super(BOPEntities.mudball, world); + super(type, world); } public EntityMudball(World world, double x, double y, double z) @@ -30,11 +35,17 @@ public class EntityMudball extends EntityThrowable super(BOPEntities.mudball, x, y, z, world); } - public EntityMudball(World world, EntityLivingBase thrower) + public EntityMudball(World world, LivingEntity thrower) { super(BOPEntities.mudball, thrower, world); } + @Override + protected Item func_213885_i() + { + return BOPItems.mudball; + } + @OnlyIn(Dist.CLIENT) @Override public void handleStatusUpdate(byte id) @@ -51,9 +62,10 @@ public class EntityMudball extends EntityThrowable @Override protected void onImpact(RayTraceResult hit) { - if (hit.entity != null) + if (hit.getType() == RayTraceResult.Type.ENTITY) { - hit.entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); + Entity entity = ((EntityRayTraceResult)hit).getEntity(); + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } if (!this.world.isRemote) diff --git a/src/main/java/biomesoplenty/common/item/ItemMudball.java b/src/main/java/biomesoplenty/common/item/ItemMudball.java index 27a50db92..adbea4c06 100644 --- a/src/main/java/biomesoplenty/common/item/ItemMudball.java +++ b/src/main/java/biomesoplenty/common/item/ItemMudball.java @@ -9,15 +9,11 @@ package biomesoplenty.common.item; import biomesoplenty.common.entity.projectile.EntityMudball; import biomesoplenty.common.util.inventory.ItemGroupBOP; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; +import net.minecraft.stats.Stats; +import net.minecraft.util.*; import net.minecraft.world.World; public class ItemMudball extends Item @@ -28,7 +24,7 @@ public class ItemMudball extends Item } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); if (!player.abilities.isCreativeMode) @@ -45,7 +41,7 @@ public class ItemMudball extends Item world.spawnEntity(mudball); } - player.addStat(StatList.ITEM_USED.get(this)); - return new ActionResult(EnumActionResult.SUCCESS, stack); + player.addStat(Stats.ITEM_USED.get(this)); + return new ActionResult(ActionResultType.SUCCESS, stack); } } diff --git a/src/main/java/biomesoplenty/common/item/ItemRecordBOP.java b/src/main/java/biomesoplenty/common/item/ItemRecordBOP.java index 2cbedbd1b..3a45d5352 100644 --- a/src/main/java/biomesoplenty/common/item/ItemRecordBOP.java +++ b/src/main/java/biomesoplenty/common/item/ItemRecordBOP.java @@ -9,10 +9,10 @@ package biomesoplenty.common.item; import biomesoplenty.common.util.inventory.ItemGroupBOP; import net.minecraft.item.Item; -import net.minecraft.item.ItemRecord; +import net.minecraft.item.MusicDiscItem; import net.minecraft.util.SoundEvent; -public class ItemRecordBOP extends ItemRecord +public class ItemRecordBOP extends MusicDiscItem { public ItemRecordBOP(SoundEvent record) { diff --git a/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java b/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java index 44bf32d1f..df8235aef 100644 --- a/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java +++ b/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java @@ -10,10 +10,10 @@ package biomesoplenty.common.world; import biomesoplenty.common.world.layer.*; import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP; import com.google.common.collect.ImmutableList; -import net.minecraft.world.biome.Biomes; import net.minecraft.util.registry.Registry; import net.minecraft.world.WorldType; -import net.minecraft.world.gen.IContextExtended; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.gen.IExtendedNoiseRandom; import net.minecraft.world.gen.OverworldGenSettings; import net.minecraft.world.gen.area.IArea; import net.minecraft.world.gen.area.IAreaFactory; @@ -35,30 +35,30 @@ public class BOPLayerUtil public static final int DEEP_COLD_OCEAN = Registry.BIOME.getId(Biomes.DEEP_COLD_OCEAN); public static final int DEEP_FROZEN_OCEAN = Registry.BIOME.getId(Biomes.DEEP_FROZEN_OCEAN); - public static > IAreaFactory createInitialLandAndSeaFactory(LongFunction contextFactory) + public static > IAreaFactory createInitialLandAndSeaFactory(LongFunction contextFactory) { // NOTE: Normally AddSnow, CoolWarm, HeatIce and Special GenLayers occur here, but we handle those ourselves - IAreaFactory factory = GenLayerIsland.INSTANCE.apply(contextFactory.apply(1L)); - factory = GenLayerZoom.FUZZY.apply(contextFactory.apply(2000L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(1L), factory); - factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2001L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(2L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(50L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(70L), factory); - factory = GenLayerRemoveTooMuchOcean.INSTANCE.apply(contextFactory.apply(2L), factory); + IAreaFactory factory = IslandLayer.INSTANCE.apply(contextFactory.apply(1L)); + factory = ZoomLayer.FUZZY.apply(contextFactory.apply(2000L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(1L), factory); + factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2001L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(2L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(50L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(70L), factory); + factory = RemoveTooMuchOceanLayer.INSTANCE.apply(contextFactory.apply(2L), factory); //factory = GenLayerAddSnow.INSTANCE.apply((IContextExtended)contextFactory.apply(2L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(3L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(3L), factory); //factory = GenLayerEdge.CoolWarm.INSTANCE.apply(contextFactory.apply(2L), factory); //factory = GenLayerEdge.HeatIce.INSTANCE.apply(contextFactory.apply(2L), factory); //factory = GenLayerEdge.Special.INSTANCE.apply(contextFactory.apply(3L), factory); - factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2002L), factory); - factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2003L), factory); - factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(4L), factory); + factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2002L), factory); + factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2003L), factory); + factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(4L), factory); return factory; } // superimpose hot and cold regions an a land and sea layer - public static > IAreaFactory createClimateFactory(LongFunction contextFactory, BOPWorldSettings settings) + public static > IAreaFactory createClimateFactory(LongFunction contextFactory, BOPWorldSettings settings) { IAreaFactory temperatureFactory; @@ -101,15 +101,15 @@ public class BOPLayerUtil return GenLayerClimate.INSTANCE.apply(contextFactory.apply(103L), temperatureFactory, rainfallFactory); } - public static > IAreaFactory createBiomeFactory(IAreaFactory landSeaAreaFactory, IAreaFactory climateAreaFactory, LongFunction contextFactory) + public static > IAreaFactory createBiomeFactory(IAreaFactory landSeaAreaFactory, IAreaFactory climateAreaFactory, LongFunction contextFactory) { IAreaFactory biomeFactory = GenLayerBiomeBOP.INSTANCE.apply(contextFactory.apply(200L), landSeaAreaFactory, climateAreaFactory); - biomeFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, biomeFactory, 2, contextFactory); + biomeFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, biomeFactory, 2, contextFactory); biomeFactory = GenLayerBiomeEdgeBOP.INSTANCE.apply(contextFactory.apply(1000L), biomeFactory); return biomeFactory; } - public static > ImmutableList> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction contextFactory) + public static > ImmutableList> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction contextFactory) { // Create the initial land and sea layer. Is also responsible for adding deep oceans // and mushroom islands @@ -117,7 +117,7 @@ public class BOPLayerUtil // Determines positions for all of the new ocean subbiomes added in 1.13 IAreaFactory oceanBiomeFactory = OceanLayer.INSTANCE.apply(contextFactory.apply(2L)); - oceanBiomeFactory = LayerUtil.repeat(2001L, GenLayerZoom.NORMAL, oceanBiomeFactory, 6, contextFactory); + oceanBiomeFactory = LayerUtil.repeat(2001L, ZoomLayer.NORMAL, oceanBiomeFactory, 6, contextFactory); int biomeSize = 4; int riverSize = biomeSize; @@ -132,60 +132,58 @@ public class BOPLayerUtil IAreaFactory climateFactory = createClimateFactory(contextFactory, new BOPWorldSettings()); // Add islands and deep oceans - landSeaFactory = GenLayerAddMushroomIsland.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory); + landSeaFactory = AddMushroomIslandLayer.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory); landSeaFactory = GenLayerLargeIsland.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory, climateFactory); - landSeaFactory = GenLayerDeepOcean.INSTANCE.apply(contextFactory.apply(4L), landSeaFactory); + landSeaFactory = DeepOceanLayer.INSTANCE.apply(contextFactory.apply(4L), landSeaFactory); // Allocate the biomes IAreaFactory biomesFactory = createBiomeFactory(landSeaFactory, climateFactory, contextFactory); // Fork off a new branch as a seed for rivers and sub biomes - IAreaFactory riverAndSubBiomesInitFactory = GenLayerRiverInit.INSTANCE.apply(contextFactory.apply(100L), landSeaFactory); - riverAndSubBiomesInitFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, riverAndSubBiomesInitFactory, 2, contextFactory); + IAreaFactory riverAndSubBiomesInitFactory = RiverLayer.INSTANCE.apply(contextFactory.apply(100L), landSeaFactory); + riverAndSubBiomesInitFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, riverAndSubBiomesInitFactory, 2, contextFactory); biomesFactory = GenLayerSubBiome.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory, riverAndSubBiomesInitFactory); // Develop the rivers branch - IAreaFactory riversInitFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, riverAndSubBiomesInitFactory, riverSize, contextFactory); - riversInitFactory = GenLayerRiver.INSTANCE.apply(contextFactory.apply(1L), riversInitFactory); - riversInitFactory = GenLayerSmooth.INSTANCE.apply(contextFactory.apply(1000L), riversInitFactory); + IAreaFactory riversInitFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, riverAndSubBiomesInitFactory, riverSize, contextFactory); + riversInitFactory = RiverLayer.INSTANCE.apply(contextFactory.apply(1L), riversInitFactory); + riversInitFactory = SmoothLayer.INSTANCE.apply(contextFactory.apply(1000L), riversInitFactory); // Mix in rare biomes into biomes branch - biomesFactory = GenLayerRareBiome.INSTANCE.apply(contextFactory.apply(1001L), biomesFactory); + biomesFactory = RareBiomeLayer.INSTANCE.apply(contextFactory.apply(1001L), biomesFactory); // Zoom more based on the biome size for (int i = 0; i < biomeSize; ++i) { - biomesFactory = GenLayerZoom.NORMAL.apply(contextFactory.apply((long)(1000 + i)), biomesFactory); - if (i == 0) biomesFactory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(3L), biomesFactory); + biomesFactory = ZoomLayer.NORMAL.apply(contextFactory.apply((long)(1000 + i)), biomesFactory); + if (i == 0) biomesFactory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(3L), biomesFactory); if (i == 1 || biomeSize == 1) biomesFactory = GenLayerShoreBOP.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory); } - biomesFactory = GenLayerSmooth.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory); + biomesFactory = SmoothLayer.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory); // Mix rivers into the biomes branch biomesFactory = GenLayerRiverMixBOP.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, riversInitFactory); - climateFactory = LayerUtil.repeat(2001L, GenLayerZoom.NORMAL, climateFactory, 6, contextFactory); + climateFactory = LayerUtil.repeat(2001L, ZoomLayer.NORMAL, climateFactory, 6, contextFactory); biomesFactory = GenLayerMixOceansBOP.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory, climateFactory); // Finish biomes with Voroni zoom - IAreaFactory voroniZoomBiomesFactory = GenLayerVoronoiZoom.INSTANCE.apply(contextFactory.apply(10L), biomesFactory); + IAreaFactory voroniZoomBiomesFactory = VoroniZoomLayer.INSTANCE.apply(contextFactory.apply(10L), biomesFactory); return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory); } - public static GenLayer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings) + public static Layer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings) { - int[] layerCount = new int[1]; // Do this as an array to enable incrementing it in the lambda ImmutableList> factoryList = createAreaFactories(worldType, settings, (seedModifier) -> { - ++layerCount[0]; - return new LazyAreaLayerContextBOP(1, layerCount[0], seed, seedModifier); + return new LazyAreaLayerContextBOP(1, seed, seedModifier); }); - GenLayer biomesLayer = new GenLayer(factoryList.get(0)); - GenLayer voroniZoomBiomesLayer = new GenLayer(factoryList.get(1)); - GenLayer biomesLayer2 = new GenLayer(factoryList.get(2)); - return new GenLayer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2}; + Layer biomesLayer = new Layer(factoryList.get(0)); + Layer voroniZoomBiomesLayer = new Layer(factoryList.get(1)); + Layer biomesLayer2 = new Layer(factoryList.get(2)); + return new Layer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2}; } public static boolean isOcean(int biomeIn) diff --git a/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java b/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java index 32ff08bd9..3a9fbace9 100644 --- a/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java +++ b/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java @@ -9,10 +9,10 @@ package biomesoplenty.common.world; import net.minecraft.world.IWorld; import net.minecraft.world.biome.provider.BiomeProvider; -import net.minecraft.world.gen.ChunkGeneratorOverworld; +import net.minecraft.world.gen.OverworldChunkGenerator; import net.minecraft.world.gen.OverworldGenSettings; -public class ChunkGeneratorOverworldBOP extends ChunkGeneratorOverworld +public class ChunkGeneratorOverworldBOP extends OverworldChunkGenerator { public ChunkGeneratorOverworldBOP(IWorld world, BiomeProvider provider, OverworldGenSettings settings) { diff --git a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java index 13613a7c5..2cab36393 100644 --- a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java +++ b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java @@ -7,19 +7,11 @@ ******************************************************************************/ package biomesoplenty.common.world; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldType; -import net.minecraft.world.biome.provider.BiomeProviderType; -import net.minecraft.world.biome.provider.EndBiomeProvider; -import net.minecraft.world.biome.provider.EndBiomeProviderSettings; import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings; import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.dimension.EndDimension; -import net.minecraft.world.gen.ChunkGeneratorType; -import net.minecraft.world.gen.EndGenSettings; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.OverworldGenSettings; public class WorldTypeBOP extends WorldType @@ -30,7 +22,7 @@ public class WorldTypeBOP extends WorldType } @Override - public IChunkGenerator createChunkGenerator(World world) + public ChunkGenerator createChunkGenerator(World world) { if (world.getDimension().getType() == DimensionType.OVERWORLD) { diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MangroveSurfaceBuilder.java b/src/main/java/biomesoplenty/common/world/gen/feature/MangroveSurfaceBuilder.java index 4bc7b9361..beb60b898 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MangroveSurfaceBuilder.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MangroveSurfaceBuilder.java @@ -7,42 +7,51 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; -public class MangroveSurfaceBuilder implements ISurfaceBuilder { - public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) { - double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D); - if (d0 > 0.2D) { - int i = x & 15; - int j = z & 15; - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); +import java.util.Random; +import java.util.function.Function; - for(int k = startHeight; k >= 0; --k) { - blockpos$mutableblockpos.setPos(i, k, j); - if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) { - if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) { - chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false); - } - break; - } - } - } - - if (noise > 0.1D) - { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE); - } - else - { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE); - } +public class MangroveSurfaceBuilder extends SurfaceBuilder +{ + public MangroveSurfaceBuilder(Function, ? extends SurfaceBuilderConfig> deserializer) + { + super(deserializer); + } - } - } \ No newline at end of file + @Override + public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) + { + double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D); + if (d0 > 0.2D) { + int i = x & 15; + int j = z & 15; + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for(int k = startHeight; k >= 0; --k) { + blockpos$mutableblockpos.setPos(i, k, j); + if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) { + if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) { + chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false); + } + break; + } + } + } + + if (noise > 0.1D) + { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE); + } + else + { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG); + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MarshSurfaceBuilder.java b/src/main/java/biomesoplenty/common/world/gen/feature/MarshSurfaceBuilder.java index b1c042651..37b22a0aa 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MarshSurfaceBuilder.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MarshSurfaceBuilder.java @@ -7,34 +7,44 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; -public class MarshSurfaceBuilder implements ISurfaceBuilder { - public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) { - double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D); - if (d0 > 0.0D) { - int i = x & 15; - int j = z & 15; - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); +import java.util.Random; +import java.util.function.Function; - for(int k = startHeight; k >= 0; --k) { - blockpos$mutableblockpos.setPos(i, k, j); - if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) { - if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) { - chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false); - } - break; - } - } - } +public class MarshSurfaceBuilder extends SurfaceBuilder +{ + public MarshSurfaceBuilder(Function, ? extends SurfaceBuilderConfig> deserializer) + { + super(deserializer); + } - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, config); - } - } \ No newline at end of file + @Override + public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) + { + double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D); + if (d0 > 0.0D) { + int i = x & 15; + int j = z & 15; + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for(int k = startHeight; k >= 0; --k) { + blockpos$mutableblockpos.setPos(i, k, j); + if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) { + if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) { + chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false); + } + break; + } + } + } + + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, config); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MeadowFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/MeadowFlowersFeature.java index 02e5e513f..964fc6821 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MeadowFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MeadowFlowersFeature.java @@ -7,24 +7,33 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class MeadowFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class MeadowFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{Blocks.OXEYE_DAISY, Blocks.AZURE_BLUET, Blocks.DANDELION, Blocks.POPPY}; + private static final Block[] FLOWERS = new Block[]{Blocks.OXEYE_DAISY, Blocks.AZURE_BLUET, Blocks.DANDELION, Blocks.POPPY}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public MeadowFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MoorFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/MoorFlowersFeature.java index 695198321..1fc0775ef 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MoorFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MoorFlowersFeature.java @@ -7,26 +7,35 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class MoorFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class MoorFlowersFeature extends FlowersFeature { - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - int j = p_202355_1_.nextInt(2); - switch(j) - { - case 0: - return BOPBlocks.violet.getDefaultState(); - case 1: - default: - return Blocks.ALLIUM.getDefaultState(); - } - } + public MoorFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + int j = p_202355_1_.nextInt(2); + switch(j) + { + case 0: + return BOPBlocks.violet.getDefaultState(); + case 1: + default: + return Blocks.ALLIUM.getDefaultState(); + } + } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MudSurfaceBuilder.java b/src/main/java/biomesoplenty/common/world/gen/feature/MudSurfaceBuilder.java index 17a47d357..7e4fece56 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MudSurfaceBuilder.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MudSurfaceBuilder.java @@ -7,24 +7,33 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; -public class MudSurfaceBuilder implements ISurfaceBuilder { - public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) { - if (noise > 1.7D) - { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE); - } - else - { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE); - } +import java.util.Random; +import java.util.function.Function; - } - } \ No newline at end of file +public class MudSurfaceBuilder extends SurfaceBuilder +{ + public MudSurfaceBuilder(Function, ? extends SurfaceBuilderConfig> deserializer) + { + super(deserializer); + } + + @Override + public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) { + if (noise > 1.7D) + { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE); + } + else + { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG); + } + + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/MysticGroveFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/MysticGroveFlowersFeature.java index 3b4842ebb..067ef5d9b 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/MysticGroveFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/MysticGroveFlowersFeature.java @@ -7,25 +7,34 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class MysticGroveFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class MysticGroveFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{BOPBlocks.blue_hydrangea, BOPBlocks.glowflower, BOPBlocks.pink_daffodil, Blocks.OXEYE_DAISY, Blocks.ALLIUM}; + private static final Block[] FLOWERS = new Block[]{BOPBlocks.blue_hydrangea, BOPBlocks.glowflower, BOPBlocks.pink_daffodil, Blocks.OXEYE_DAISY, Blocks.ALLIUM}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public MysticGroveFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/OriginFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/OriginFlowersFeature.java index 0bd6b6a30..19d4f148b 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/OriginFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/OriginFlowersFeature.java @@ -7,18 +7,27 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class OriginFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class OriginFlowersFeature extends FlowersFeature { - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - return p_202355_1_.nextFloat() > 0.6666667F ? Blocks.DANDELION.getDefaultState() : BOPBlocks.rose.getDefaultState(); - } - } \ No newline at end of file + public OriginFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + return p_202355_1_.nextFloat() > 0.6666667F ? Blocks.DANDELION.getDefaultState() : BOPBlocks.rose.getDefaultState(); + } +} diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/PodzolSurfaceBuilder.java b/src/main/java/biomesoplenty/common/world/gen/feature/PodzolSurfaceBuilder.java index a5e680412..da8a05de8 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/PodzolSurfaceBuilder.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/PodzolSurfaceBuilder.java @@ -7,21 +7,30 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; -public class PodzolSurfaceBuilder implements ISurfaceBuilder { - public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) { - if (noise > 1.9D) { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.PODZOL_DIRT_GRAVEL_SURFACE); - } else { - Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE); - } +import java.util.Random; +import java.util.function.Function; - } - } \ No newline at end of file +public class PodzolSurfaceBuilder extends SurfaceBuilder +{ + public PodzolSurfaceBuilder(Function, ? extends SurfaceBuilderConfig> deserializer) + { + super(deserializer); + } + + @Override + public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) + { + if (noise > 1.9D) { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.PODZOL_DIRT_GRAVEL_CONFIG); + } else { + SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG); + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/PrairieFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/PrairieFlowersFeature.java index 7b39da9d2..3067044e8 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/PrairieFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/PrairieFlowersFeature.java @@ -7,24 +7,33 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class PrairieFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class PrairieFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{BOPBlocks.goldenrod}; + private static final Block[] FLOWERS = new Block[]{BOPBlocks.goldenrod}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public PrairieFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/PumpkinPatchFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/PumpkinPatchFeature.java index 358a200a7..113f5e9e2 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/PumpkinPatchFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/PumpkinPatchFeature.java @@ -1,56 +1,64 @@ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - -import net.minecraft.block.BlockCarvedPumpkin; -import net.minecraft.block.BlockLeaves; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Blocks; +import net.minecraft.block.CarvedPumpkinBlock; +import net.minecraft.block.LeavesBlock; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; -import net.minecraft.world.gen.IChunkGenSettings; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.NoFeatureConfig; +import java.util.Random; +import java.util.function.Function; + public class PumpkinPatchFeature extends Feature { - public boolean place(IWorld p_212245_1_, IChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_) - { - int i = 0; + public PumpkinPatchFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } - for(int j = 0; j < 64; ++j) - { - BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8)); - if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK) - { - - if (p_212245_3_.nextInt(3) == 0) - { - int rand = p_212245_3_.nextInt(50); - - if (rand > 10) - { - p_212245_1_.setBlockState(blockpos, Blocks.PUMPKIN.getDefaultState(), 2); - } - else if (rand > 1) - { - p_212245_1_.setBlockState(blockpos, Blocks.CARVED_PUMPKIN.getDefaultState().with(BlockCarvedPumpkin.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2); - } - else - { - p_212245_1_.setBlockState(blockpos, Blocks.JACK_O_LANTERN.getDefaultState().with(BlockCarvedPumpkin.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2); - } - } - else - { - p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, true), 2); - } - - ++i; - } - } + @Override + public boolean place(IWorld p_212245_1_, ChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_) + { + int i = 0; - return i > 0; - } + for(int j = 0; j < 64; ++j) + { + BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8)); + if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK) + { + + if (p_212245_3_.nextInt(3) == 0) + { + int rand = p_212245_3_.nextInt(50); + + if (rand > 10) + { + p_212245_1_.setBlockState(blockpos, Blocks.PUMPKIN.getDefaultState(), 2); + } + else if (rand > 1) + { + p_212245_1_.setBlockState(blockpos, Blocks.CARVED_PUMPKIN.getDefaultState().with(CarvedPumpkinBlock.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2); + } + else + { + p_212245_1_.setBlockState(blockpos, Blocks.JACK_O_LANTERN.getDefaultState().with(CarvedPumpkinBlock.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2); + } + } + else + { + p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, true), 2); + } + + ++i; + } + } + + return i > 0; + } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/RainforestFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/RainforestFlowersFeature.java index 9e8720912..61752af7c 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/RainforestFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/RainforestFlowersFeature.java @@ -7,25 +7,34 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class RainforestFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class RainforestFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_daffodil, BOPBlocks.blue_hydrangea, Blocks.BLUE_ORCHID, Blocks.OXEYE_DAISY, Blocks.DANDELION, Blocks.POPPY}; + private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_daffodil, BOPBlocks.blue_hydrangea, Blocks.BLUE_ORCHID, Blocks.OXEYE_DAISY, Blocks.DANDELION, Blocks.POPPY}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public RainforestFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/ScrubFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/ScrubFeature.java index 80e7ca0a4..62d3fe9ae 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/ScrubFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/ScrubFeature.java @@ -1,19 +1,27 @@ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - -import net.minecraft.block.BlockLeaves; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Blocks; +import net.minecraft.block.LeavesBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; -import net.minecraft.world.gen.IChunkGenSettings; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.NoFeatureConfig; +import java.util.Random; +import java.util.function.Function; + public class ScrubFeature extends Feature { - public boolean place(IWorld p_212245_1_, IChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_) + public ScrubFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public boolean place(IWorld p_212245_1_, ChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_) { int i = 0; @@ -22,7 +30,7 @@ public class ScrubFeature extends Feature BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8)); if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK) { - p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, true), 2); + p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, true), 2); ++i; } diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/ShrublandFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/ShrublandFlowersFeature.java index 02c0915b3..329958ee0 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/ShrublandFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/ShrublandFlowersFeature.java @@ -7,24 +7,33 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class ShrublandFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class ShrublandFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{Blocks.ALLIUM}; + private static final Block[] FLOWERS = new Block[]{Blocks.ALLIUM}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public ShrublandFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/SnowyFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/SnowyFlowersFeature.java index 559ab234d..c1184ed4c 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/SnowyFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/SnowyFlowersFeature.java @@ -7,31 +7,37 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; -import net.minecraft.block.Block; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class SnowyFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class SnowyFlowersFeature extends FlowersFeature { - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - int j = p_202355_1_.nextInt(3); - switch(j) - { - case 0: - return BOPBlocks.violet.getDefaultState(); - case 1: - return Blocks.POPPY.getDefaultState(); - case 2: - default: - return Blocks.DANDELION.getDefaultState(); - } - } + public SnowyFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + int j = p_202355_1_.nextInt(3); + switch(j) + { + case 0: + return BOPBlocks.violet.getDefaultState(); + case 1: + return Blocks.POPPY.getDefaultState(); + case 2: + default: + return Blocks.DANDELION.getDefaultState(); + } + } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/SplotchConfig.java b/src/main/java/biomesoplenty/common/world/gen/feature/SplotchConfig.java index 01d148fa7..141f5c42a 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/SplotchConfig.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/SplotchConfig.java @@ -1,20 +1,33 @@ package biomesoplenty.common.world.gen.feature; +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.DynamicOps; +import net.minecraft.block.BlockState; +import net.minecraft.world.gen.feature.IFeatureConfig; + import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.world.gen.feature.IFeatureConfig; +public class SplotchConfig implements IFeatureConfig +{ + public final BlockState state; + public final int radius; + public final int ySize; + public final List targets; -public class SplotchConfig implements IFeatureConfig { - public final Block block; - public final int radius; - public final int ySize; - public final List targets; + public SplotchConfig(BlockState state, int radius, int ySize, List targets) + { + this.state = state; + this.radius = radius; + this.ySize = ySize; + this.targets = targets; + } - public SplotchConfig(Block p_i48684_1_, int p_i48684_2_, int p_i48684_3_, List p_i48684_4_) { - this.block = p_i48684_1_; - this.radius = p_i48684_2_; - this.ySize = p_i48684_3_; - this.targets = p_i48684_4_; - } - } \ No newline at end of file + @Override + public Dynamic serialize(DynamicOps dynamicOps) + { + return new Dynamic<>(dynamicOps, dynamicOps.createMap(ImmutableMap.of(dynamicOps.createString("state"), BlockState.serialize(dynamicOps, this.state).getValue(), dynamicOps.createString("radius"), dynamicOps.createInt(this.radius), dynamicOps.createString("y_size"), dynamicOps.createInt(this.ySize), dynamicOps.createString("targets"), dynamicOps.createList(this.targets.stream().map((p_214692_1_) -> { + return BlockState.serialize(dynamicOps, p_214692_1_).getValue(); + }))))); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/SplotchFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/SplotchFeature.java index 514bd7a2c..ec346002e 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/SplotchFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/SplotchFeature.java @@ -1,58 +1,66 @@ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; -import net.minecraft.world.gen.IChunkGenSettings; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.Feature; +import java.util.Random; +import java.util.function.Function; + public class SplotchFeature extends Feature { - public boolean place(IWorld p_212245_1_, IChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, SplotchConfig p_212245_5_) + public SplotchFeature(Function, ? extends SplotchConfig> deserializer) { - int i = 0; - int j = p_212245_3_.nextInt(p_212245_5_.radius - 2) + 2; + super(deserializer); + } - for(int k = p_212245_4_.getX() - j; k <= p_212245_4_.getX() + j; ++k) { - for(int l = p_212245_4_.getZ() - j; l <= p_212245_4_.getZ() + j; ++l) { - int i1 = k - p_212245_4_.getX(); - int j1 = l - p_212245_4_.getZ(); - if (i1 * i1 + j1 * j1 <= j * j) { - for(int k1 = p_212245_4_.getY() - p_212245_5_.ySize; k1 <= p_212245_4_.getY() + p_212245_5_.ySize; ++k1) { - BlockPos blockpos = new BlockPos(k, k1, l); - BlockPos blockpos1 = blockpos.north(); - BlockPos blockpos2 = blockpos.south(); - BlockPos blockpos3 = blockpos.east(); - BlockPos blockpos4 = blockpos.west(); - BlockPos blockpos5 = blockpos.north().east(); - BlockPos blockpos6 = blockpos.south().east(); - BlockPos blockpos7 = blockpos.north().west(); - BlockPos blockpos8 = blockpos.south().west(); - BlockPos blockpos9 = blockpos.down(); - Block block = p_212245_1_.getBlockState(blockpos).getBlock(); - Block block1 = p_212245_1_.getBlockState(blockpos1).getBlock(); - Block block2 = p_212245_1_.getBlockState(blockpos2).getBlock(); - Block block3 = p_212245_1_.getBlockState(blockpos3).getBlock(); - Block block4 = p_212245_1_.getBlockState(blockpos4).getBlock(); - Block block5 = p_212245_1_.getBlockState(blockpos5).getBlock(); - Block block6 = p_212245_1_.getBlockState(blockpos6).getBlock(); - Block block7 = p_212245_1_.getBlockState(blockpos7).getBlock(); - Block block8 = p_212245_1_.getBlockState(blockpos8).getBlock(); - Block block9 = p_212245_1_.getBlockState(blockpos9).getBlock(); - - if (p_212245_5_.targets.contains(block) && p_212245_5_.targets.contains(block1) && p_212245_5_.targets.contains(block2) && p_212245_5_.targets.contains(block3) && p_212245_5_.targets.contains(block4) && p_212245_5_.targets.contains(block5) && p_212245_5_.targets.contains(block6) && p_212245_5_.targets.contains(block7) && p_212245_5_.targets.contains(block8) && p_212245_5_.targets.contains(block9)) - { - p_212245_1_.setBlockState(blockpos, p_212245_5_.block.getDefaultState(), 2); - ++i; - } - } - } - } - } + @Override + public boolean place(IWorld p_212245_1_, ChunkGenerator p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, SplotchConfig p_212245_5_) + { + int i = 0; + int j = p_212245_3_.nextInt(p_212245_5_.radius - 2) + 2; - return i > 0; + for(int k = p_212245_4_.getX() - j; k <= p_212245_4_.getX() + j; ++k) { + for(int l = p_212245_4_.getZ() - j; l <= p_212245_4_.getZ() + j; ++l) { + int i1 = k - p_212245_4_.getX(); + int j1 = l - p_212245_4_.getZ(); + if (i1 * i1 + j1 * j1 <= j * j) { + for(int k1 = p_212245_4_.getY() - p_212245_5_.ySize; k1 <= p_212245_4_.getY() + p_212245_5_.ySize; ++k1) { + BlockPos blockpos = new BlockPos(k, k1, l); + BlockPos blockpos1 = blockpos.north(); + BlockPos blockpos2 = blockpos.south(); + BlockPos blockpos3 = blockpos.east(); + BlockPos blockpos4 = blockpos.west(); + BlockPos blockpos5 = blockpos.north().east(); + BlockPos blockpos6 = blockpos.south().east(); + BlockPos blockpos7 = blockpos.north().west(); + BlockPos blockpos8 = blockpos.south().west(); + BlockPos blockpos9 = blockpos.down(); + Block block = p_212245_1_.getBlockState(blockpos).getBlock(); + Block block1 = p_212245_1_.getBlockState(blockpos1).getBlock(); + Block block2 = p_212245_1_.getBlockState(blockpos2).getBlock(); + Block block3 = p_212245_1_.getBlockState(blockpos3).getBlock(); + Block block4 = p_212245_1_.getBlockState(blockpos4).getBlock(); + Block block5 = p_212245_1_.getBlockState(blockpos5).getBlock(); + Block block6 = p_212245_1_.getBlockState(blockpos6).getBlock(); + Block block7 = p_212245_1_.getBlockState(blockpos7).getBlock(); + Block block8 = p_212245_1_.getBlockState(blockpos8).getBlock(); + Block block9 = p_212245_1_.getBlockState(blockpos9).getBlock(); + + if (p_212245_5_.targets.contains(block) && p_212245_5_.targets.contains(block1) && p_212245_5_.targets.contains(block2) && p_212245_5_.targets.contains(block3) && p_212245_5_.targets.contains(block4) && p_212245_5_.targets.contains(block5) && p_212245_5_.targets.contains(block6) && p_212245_5_.targets.contains(block7) && p_212245_5_.targets.contains(block8) && p_212245_5_.targets.contains(block9)) + { + p_212245_1_.setBlockState(blockpos, p_212245_5_.state, 2); + ++i; + } + } + } + } + } + + return i > 0; } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/StandardGrassFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/StandardGrassFeature.java index 3bb8b20d3..c87696f22 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/StandardGrassFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/StandardGrassFeature.java @@ -7,47 +7,54 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - +import com.mojang.datafixers.Dynamic; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.tags.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; -import net.minecraft.world.gen.IChunkGenSettings; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.NoFeatureConfig; +import java.util.Random; +import java.util.function.Function; + public class StandardGrassFeature extends Feature { - public BlockState chooseGrassState(Random rand) - { - return Blocks.GRASS.getDefaultState(); - } + public StandardGrassFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } - @Override - public boolean place(IWorld world, IChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) - { - BlockState BlockState = this.chooseGrassState(rand); + public BlockState chooseGrassState(Random rand) + { + return Blocks.GRASS.getDefaultState(); + } - for (BlockState BlockState1 = world.getBlockState(pos); (BlockState1.isAir(world, pos) || BlockState1.isIn(BlockTags.LEAVES)) && pos.getY() > 0; BlockState1 = world.getBlockState(pos)) - { - pos = pos.down(); - } + @Override + public boolean place(IWorld world, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) + { + BlockState BlockState = this.chooseGrassState(rand); - int i = 0; + for (BlockState BlockState1 = world.getBlockState(pos); (BlockState1.isAir(world, pos) || BlockState1.isIn(BlockTags.LEAVES)) && pos.getY() > 0; BlockState1 = world.getBlockState(pos)) + { + pos = pos.down(); + } - for (int j = 0; j < 128; ++j) - { - BlockPos blockpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); - if (world.isAirBlock(blockpos) && BlockState.isValidPosition(world, blockpos)) - { - world.setBlockState(blockpos, BlockState, 2); - ++i; - } - } + int i = 0; - return i > 0; - } - } \ No newline at end of file + for (int j = 0; j < 128; ++j) + { + BlockPos blockpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); + if (world.isAirBlock(blockpos) && BlockState.isValidPosition(world, blockpos)) + { + world.setBlockState(blockpos, BlockState, 2); + ++i; + } + } + + return i > 0; + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/TropicsFlowersFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/TropicsFlowersFeature.java index f89efe6c3..c0f25677d 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/TropicsFlowersFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/TropicsFlowersFeature.java @@ -7,25 +7,34 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature; -import java.util.Random; - import biomesoplenty.api.block.BOPBlocks; +import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.AbstractFlowersFeature; +import net.minecraft.world.gen.feature.FlowersFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; -public class TropicsFlowersFeature extends AbstractFlowersFeature +import java.util.Random; +import java.util.function.Function; + +public class TropicsFlowersFeature extends FlowersFeature { - private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_hibiscus, BOPBlocks.blue_hydrangea, Blocks.DANDELION, Blocks.POPPY}; + private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_hibiscus, BOPBlocks.blue_hydrangea, Blocks.DANDELION, Blocks.POPPY}; - public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) - { - double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); - Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; - return block.getDefaultState(); - } - } \ No newline at end of file + public TropicsFlowersFeature(Function, ? extends NoFeatureConfig> deserializer) + { + super(deserializer); + } + + @Override + public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_) + { + double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D); + Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)]; + return block.getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BasicTreeFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BasicTreeFeature.java index 1d3f892e7..748670ce3 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BasicTreeFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BasicTreeFeature.java @@ -11,16 +11,16 @@ import java.util.Random; import java.util.Set; import biomesoplenty.common.util.block.IBlockPosQuery; -import net.minecraft.block.Block; +import net.minecraft.block.*; import net.minecraft.block.BlockCocoa; import net.minecraft.block.BlockSapling; import net.minecraft.block.BlockVine; import net.minecraft.block.material.Material; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MutableBoundingBox; import net.minecraft.world.IWorld; +import net.minecraft.world.gen.IWorldGenerationReader; public class BasicTreeFeature extends TreeFeatureBase { @@ -289,7 +289,7 @@ public class BasicTreeFeature extends TreeFeatureBase } } - protected void generateTrunk(Set changedBlocks, IWorld world, BlockPos start, int height) + protected void generateTrunk(Set changedBlocks, MutableBoundingBox boundingBox, IWorld world, BlockPos start, int height) { //Create the trunk from the bottom up, using < to ensure it is covered with one layer of leaves for (int layer = 0; layer < height; ++layer) @@ -297,7 +297,7 @@ public class BasicTreeFeature extends TreeFeatureBase BlockPos blockpos2 = start.up(layer); if (this.replace.matches(world, blockpos2)) { - this.setLog(changedBlocks, world, start.up(layer)); + this.setLog(changedBlocks, world, start.up(layer), boundingBox); } } } @@ -325,17 +325,17 @@ public class BasicTreeFeature extends TreeFeatureBase { if (this.trunkFruit == Blocks.COCOA.getDefaultState()) { - this.setBlockState(world, pos, this.trunkFruit.with(BlockCocoa.AGE, Integer.valueOf(age)).with(BlockCocoa.HORIZONTAL_FACING, direction)); + this.setBlockState(world, pos, this.trunkFruit.with(CocoaBlock.AGE, Integer.valueOf(age)).with(CocoaBlock.HORIZONTAL_FACING, direction)); } else { - this.setBlockState(world, pos, this.trunkFruit.with(BlockCocoa.HORIZONTAL_FACING, direction)); + this.setBlockState(world, pos, this.trunkFruit.with(CocoaBlock.HORIZONTAL_FACING, direction)); } } private BlockState getVineStateForSide(Direction side) { - return this.vine.getBlock() instanceof BlockVine ? this.vine.with(BlockVine.getPropertyFor(side), Boolean.valueOf(true)) : this.vine; + return this.vine.getBlock() instanceof VineBlock ? this.vine.with(VineBlock.getPropertyFor(side), Boolean.valueOf(true)) : this.vine; } private void extendVines(IWorld world, BlockPos pos, Direction side) diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java index 7ef1101c5..6fd044b32 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java @@ -7,20 +7,20 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature.tree; -import java.util.List; -import java.util.Random; -import java.util.Set; - -import com.google.common.collect.Lists; - import biomesoplenty.common.util.block.IBlockPosQuery; -import net.minecraft.block.BlockSapling; +import com.google.common.collect.Lists; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.MutableBoundingBox; import net.minecraft.world.IWorld; +import net.minecraft.world.gen.IWorldGenerationReader; + +import java.util.List; +import java.util.Random; +import java.util.Set; /*This class is heavily based on https://gist.github.com/grum/62cfdec0537e8db24eb3#file-bigtreefeature-java additional information has been added from http://pastebin.com/XBLdGqXQ. This class has been cross-checked*/ @@ -259,7 +259,7 @@ public class BigTreeFeature extends TreeFeatureBase } } - private void limb(Set changedBlocks, BlockPos startPos, BlockPos endPos, BlockState state) + private void limb(Set changedBlocks, MutableBoundingBox boundingBox, BlockPos startPos, BlockPos endPos, BlockState state) { // Create a limb from the start position to the end position. // Used for creating the branches and trunk. @@ -285,7 +285,7 @@ public class BigTreeFeature extends TreeFeatureBase BlockPos blockPos = startPos.add(.5f + i * dx, .5f + i * dy, .5f + i * dz); Direction.Axis logAxis = getLogAxis(startPos, blockPos); - this.setLog(changedBlocks, this.world, blockPos, logAxis); + this.setLog(changedBlocks, this.world, blockPos, logAxis, boundingBox); } } @@ -362,39 +362,39 @@ public class BigTreeFeature extends TreeFeatureBase return localY >= height * 0.2; } - private void makeTrunk(Set changedBlocks) + private void makeTrunk(Set changedBlocks, MutableBoundingBox boundingBox) { // Create the trunk of the tree. BlockPos start = origin; BlockPos end = origin.up(trunkHeight); BlockState materialState = this.log; - limb(changedBlocks, start, end, materialState); + limb(changedBlocks, boundingBox, start, end, materialState); if (trunkWidth == 2) { - limb(changedBlocks, start.east(), end.east(), materialState); - limb(changedBlocks, start.east().south(), end.east().south(), materialState); - limb(changedBlocks, start.south(), end.south(), materialState); + limb(changedBlocks, boundingBox, start.east(), end.east(), materialState); + limb(changedBlocks, boundingBox, start.east().south(), end.east().south(), materialState); + limb(changedBlocks, boundingBox, start.south(), end.south(), materialState); } if (trunkWidth == 4) { - limb(changedBlocks, start.east(), end.east(), materialState); - limb(changedBlocks, start.east().south(), end.east().south(), materialState); - limb(changedBlocks, start.south(), end.south(), materialState); - limb(changedBlocks, start.north(), end.north(), materialState); - limb(changedBlocks, start.north().east(), end.north().east(), materialState); - limb(changedBlocks, start.east().east(), end.east().east(), materialState); - limb(changedBlocks, start.south().east().east(), end.south().east().east(), materialState); - limb(changedBlocks, start.south().south().east(), end.south().south().east(), materialState); - limb(changedBlocks, start.south().south(), end.south().south(), materialState); - limb(changedBlocks, start.west().south(), end.west().south(), materialState); - limb(changedBlocks, start.west(), end.west(), materialState); + limb(changedBlocks, boundingBox, start.east(), end.east(), materialState); + limb(changedBlocks, boundingBox, start.east().south(), end.east().south(), materialState); + limb(changedBlocks, boundingBox, start.south(), end.south(), materialState); + limb(changedBlocks, boundingBox, start.north(), end.north(), materialState); + limb(changedBlocks, boundingBox, start.north().east(), end.north().east(), materialState); + limb(changedBlocks, boundingBox, start.east().east(), end.east().east(), materialState); + limb(changedBlocks, boundingBox, start.south().east().east(), end.south().east().east(), materialState); + limb(changedBlocks, boundingBox, start.south().south().east(), end.south().south().east(), materialState); + limb(changedBlocks, boundingBox, start.south().south(), end.south().south(), materialState); + limb(changedBlocks, boundingBox, start.west().south(), end.west().south(), materialState); + limb(changedBlocks, boundingBox, start.west(), end.west(), materialState); } } - private void makeBranches(Set changedBlocks) + private void makeBranches(Set changedBlocks, MutableBoundingBox boundingBox) { for (FoliageCoords endCoord : foliageCoords) { @@ -403,7 +403,7 @@ public class BigTreeFeature extends TreeFeatureBase if (this.trimBranches(branchBase - this.origin.getY())) { - this.limb(changedBlocks, baseCoord, endCoord, this.log); + this.limb(changedBlocks, boundingBox, baseCoord, endCoord, this.log); } } } @@ -453,12 +453,10 @@ public class BigTreeFeature extends TreeFeatureBase return -1; } - - @Override - protected boolean place(Set changedBlocks, IWorld world, Random random, BlockPos startPos) + protected boolean place(Set changedBlocks, IWorldGenerationReader world, Random random, BlockPos startPos, MutableBoundingBox boundingBox) { - this.world = world; + this.world = (IWorld)world; // Fuck this bullshit, we want an IWorld this.origin = startPos; this.random = new Random(random.nextLong()); @@ -474,8 +472,8 @@ public class BigTreeFeature extends TreeFeatureBase try { prepare(); makeFoliage(); - makeTrunk(changedBlocks); - makeBranches(changedBlocks); + makeTrunk(changedBlocks, boundingBox); + makeBranches(changedBlocks, boundingBox); } catch (RuntimeException e) { // TODO: deal with this. } diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/TreeFeatureBase.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/TreeFeatureBase.java index f12aef0e0..4a3bd2690 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/tree/TreeFeatureBase.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/TreeFeatureBase.java @@ -7,22 +7,24 @@ ******************************************************************************/ package biomesoplenty.common.world.gen.feature.tree; -import java.util.Random; -import java.util.Set; - import biomesoplenty.common.util.block.BlockUtil; import biomesoplenty.common.util.block.IBlockPosQuery; -import net.minecraft.block.BlockSapling; -import net.minecraft.block.BlockVine; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.SaplingBlock; +import net.minecraft.block.VineBlock; import net.minecraft.state.IProperty; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MutableBoundingBox; import net.minecraft.world.IWorld; +import net.minecraft.world.gen.IWorldGenerationReader; import net.minecraft.world.gen.feature.AbstractTreeFeature; import net.minecraft.world.gen.feature.NoFeatureConfig; +import java.util.Random; +import java.util.Set; + public abstract class TreeFeatureBase extends AbstractTreeFeature { protected static abstract class BuilderBase @@ -41,7 +43,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature world.getBlockState(pos).canSustainPlant(world, pos, Direction.UP, (BlockSapling)Blocks.OAK_SAPLING); + this.placeOn = (world, pos) -> world.getBlockState(pos).canSustainPlant(world, pos, Direction.UP, (SaplingBlock)Blocks.OAK_SAPLING); this.replace = (world, pos) -> world.getBlockState(pos).canBeReplacedByLeaves(world, pos); this.log = Blocks.OAK_LOG.getDefaultState(); this.leaves = Blocks.OAK_LEAVES.getDefaultState(); @@ -103,7 +105,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature changedBlocks, IWorld world, BlockPos pos) + public boolean setLog(Set changedBlocks, IWorld world, BlockPos pos, MutableBoundingBox boundingBox) { - return this.setLog(changedBlocks, world, pos, null); + return this.setLog(changedBlocks, world, pos, null, boundingBox); } - public boolean setLog(Set changedBlocks, IWorld world, BlockPos pos, Direction.Axis axis) + public boolean setLog(Set changedBlocks, IWorld world, BlockPos pos, Direction.Axis axis, MutableBoundingBox boundingBox) { BlockState directedLog = (axis != null && this.logAxisProperty != null) ? this.log.with(this.logAxisProperty, axis) : this.log; if (this.replace.matches(world, pos)) { // Logs must be added to the "changedBlocks" so that the leaves have their distance property updated, // preventing incorrect decay - this.setLogState(changedBlocks, world, pos, directedLog); + this.func_208520_a(changedBlocks, world, pos, directedLog, boundingBox); return true; } return false; @@ -148,7 +150,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature 0 && rand.nextInt(12) > 0) { @@ -188,4 +190,15 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature changedBlocks, IWorldGenerationReader world, Random rand, BlockPos position, MutableBoundingBox boundingBox) + { + return place(changedBlocks, world, rand, position, boundingBox); + } + + protected boolean place(Set changedBlocks, IWorld world, Random rand, BlockPos position, MutableBoundingBox boundingBox) + { + return false; + } } diff --git a/src/main/java/biomesoplenty/core/ClientProxy.java b/src/main/java/biomesoplenty/core/ClientProxy.java index 0a700b90e..73e3ed791 100644 --- a/src/main/java/biomesoplenty/core/ClientProxy.java +++ b/src/main/java/biomesoplenty/core/ClientProxy.java @@ -15,11 +15,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; -import net.minecraft.init.Particles; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.particles.ItemParticleData; +import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.MathHelper; import net.minecraft.world.FoliageColors; import net.minecraft.world.GrassColors; @@ -52,7 +52,7 @@ public class ClientProxy extends CommonProxy //Item Coloring itemColors.register((stack, tintIndex) -> { - BlockState BlockState = ((ItemBlock)stack.getItem()).getBlock().getDefaultState(); + BlockState BlockState = ((BlockItem)stack.getItem()).getBlock().getDefaultState(); return blockColors.getColor(BlockState, null, null, tintIndex); }, BOPBlocks.bush, BOPBlocks.flowering_oak_leaves, BOPBlocks.mahogany_leaves, BOPBlocks.palm_leaves, BOPBlocks.willow_leaves, BOPBlocks.willow_vine); @@ -67,7 +67,7 @@ public class ClientProxy extends CommonProxy { case MUD: int itemId = Item.getIdFromItem(BOPItems.mudball); - minecraft.world.addParticle(new ItemParticleData(Particles.ITEM, new ItemStack(BOPItems.mudball)), x, y, z, MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D)); + minecraft.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, new ItemStack(BOPItems.mudball)), x, y, z, MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D)); return; /*case PLAYER_TRAIL: if (info.length < 1) diff --git a/src/main/java/biomesoplenty/init/ModEntities.java b/src/main/java/biomesoplenty/init/ModEntities.java index da1dc3b92..e7ce10f65 100644 --- a/src/main/java/biomesoplenty/init/ModEntities.java +++ b/src/main/java/biomesoplenty/init/ModEntities.java @@ -7,38 +7,35 @@ ******************************************************************************/ package biomesoplenty.init; -import static biomesoplenty.api.entity.BOPEntities.boat_bop; -import static biomesoplenty.api.entity.BOPEntities.mudball; - -import java.util.function.Function; - -import biomesoplenty.api.item.BOPItems; import biomesoplenty.common.entity.item.EntityBoatBOP; import biomesoplenty.common.entity.item.RenderBoatBOP; import biomesoplenty.common.entity.projectile.EntityMudball; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderSprite; +import net.minecraft.client.renderer.entity.SpriteRenderer; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.registries.ForgeRegistries; +import static biomesoplenty.api.entity.BOPEntities.boat_bop; +import static biomesoplenty.api.entity.BOPEntities.mudball; + public class ModEntities { public static void init() { - mudball = createEntity(EntityMudball.class, EntityMudball::new, "mudball", 64, 10, true); - boat_bop = createEntity(EntityBoatBOP.class, EntityBoatBOP::new, "boat_bop", 80, 3, true); + mudball = createEntity(EntityMudball::new, EntityClassification.MISC, "mudball", 64, 10, true); + boat_bop = createEntity(EntityBoatBOP::new, EntityClassification.MISC, "boat_bop", 80, 3, true); } - public static EntityType createEntity(Class entityClass, Function entityInstance, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) + public static EntityType createEntity(EntityType.IFactory factory, EntityClassification classification, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) { ResourceLocation location = new ResourceLocation("biomesoplenty", name); - EntityType type = EntityType.Builder.create(entityClass, entityInstance).tracker(trackingRange, updateFrequency, sendsVelocityUpdates).build(location.toString()); + EntityType type = EntityType.Builder.create(factory, classification).setTrackingRange(trackingRange).setUpdateInterval(updateFrequency).setShouldReceiveVelocityUpdates(sendsVelocityUpdates).build(location.toString()); type.setRegistryName(name); ForgeRegistries.ENTITIES.register(type); return type; @@ -47,7 +44,7 @@ public class ModEntities @OnlyIn(Dist.CLIENT) public static void registerRendering() { - RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, manager -> new RenderSprite<>(manager, BOPItems.mudball, Minecraft.getInstance().getItemRenderer())); + RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, manager -> new SpriteRenderer<>(manager, Minecraft.getInstance().getItemRenderer())); RenderingRegistry.registerEntityRenderingHandler(EntityBoatBOP.class, manager -> new RenderBoatBOP(manager)); } }