package com.dairymoose.entity; import com.dairymoose.modernlife.core.CustomBlocks; import com.dairymoose.modernlife.core.ModernLifeNetwork; import com.dairymoose.modernlife.network.play.client.ServerboundFuelLevelPacket; import com.google.common.collect.Lists; import com.google.common.collect.UnmodifiableIterator; import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; import net.minecraft.BlockUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.player.Input; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.FloatTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; import net.minecraft.world.Container; import net.minecraft.world.ContainerHelper; import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.SlotAccess; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.WaterAnimal; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.vehicle.DismountHelper; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.WaterlilyBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; /* loaded from: outputsrg.jar:com/dairymoose/entity/MotorboatEntity.class */ public class MotorboatEntity extends Entity implements Container, MenuProvider { public static final EntityType MOTORBOAT_ENTITY = EntityType.Builder.of(MotorboatEntity::new, MobCategory.MISC).sized(1.375f, 0.5625f).clientTrackingRange(10).build(new ResourceLocation("modernlife", "motorboat").toString()); private static final EntityDataAccessor DATA_ID_HURT = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_ID_HURTDIR = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_ID_DAMAGE = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.FLOAT); private static final EntityDataAccessor DATA_ID_TYPE = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_ID_BUBBLE_TIME = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_ID_ADDED_FREE_GAS = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_ID_FUEL_LEVEL = SynchedEntityData.defineId(MotorboatEntity.class, EntityDataSerializers.FLOAT); public static final int PADDLE_LEFT = 0; public static final int PADDLE_RIGHT = 1; private static final int TIME_TO_EJECT = 60; private static final double PADDLE_SPEED = 0.39269909262657166d; public static final double PADDLE_SOUND_TIME = 0.7853981852531433d; public static final int BUBBLE_TIME = 60; private final float[] paddlePositions; private float invFriction; private float outOfControlTicks; private float deltaRotation; private int lerpSteps; private double lerpX; private double lerpY; private double lerpZ; private double lerpYRot; private double lerpXRot; private boolean inputLeft; private boolean inputRight; private boolean inputUp; private boolean inputDown; private double waterLevel; private float landFriction; public Status status; private Status oldStatus; private double lastYd; private boolean isAboveBubbleColumn; private boolean bubbleColumnDirectionIsDown; private float bubbleMultiplier; private float bubbleAngle; private float bubbleAngleO; private float curAccel; private float maxAccel; private float currentFuelLevelClientOnly; public int tickCount; private boolean backingUp; private NonNullList itemStacks; private static final int MINUTES_UNTIL_EMPTY = 20; private static final int TICKS_PER_SEC = 20; private static final int SECS_PER_MINUTE = 60; public static final int FULL_FUEL_LEVEL = 24000; /* loaded from: outputsrg.jar:com/dairymoose/entity/MotorboatEntity$Status.class */ public enum Status { IN_WATER, UNDER_WATER, UNDER_FLOWING_WATER, ON_LAND, IN_AIR } public MotorboatEntity(EntityType p_38290_, Level p_38291_) { super(p_38290_, p_38291_); this.paddlePositions = new float[2]; this.maxAccel = 0.1f; this.currentFuelLevelClientOnly = -10.0f; this.tickCount = 0; this.backingUp = false; this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); this.blocksBuilding = true; } public void onSyncedDataUpdated(EntityDataAccessor p_20059_) { if (p_20059_ == DATA_ID_FUEL_LEVEL) { this.currentFuelLevelClientOnly = ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue(); } } public MotorboatEntity(Level p_38293_, double p_38294_, double p_38295_, double p_38296_) { this(MOTORBOAT_ENTITY, p_38293_); setPos(p_38294_, p_38295_, p_38296_); this.xo = p_38294_; this.yo = p_38295_; this.zo = p_38296_; } public float getCurrentFuelLevel() { if (this.currentFuelLevelClientOnly <= -10.0f) { float fuelLevel = ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue(); if (fuelLevel < 0.0f) { fuelLevel = 1.0f; } this.currentFuelLevelClientOnly = fuelLevel; } return this.currentFuelLevelClientOnly; } public boolean isOutOfFuel() { float fuelLevel = getCurrentFuelLevel(); return fuelLevel <= 0.0f; } public void setSyncedFuelLevel(float newLevel) { if (newLevel < 0.0f) { newLevel = 0.0f; } this.entityData.set(DATA_ID_FUEL_LEVEL, Float.valueOf(newLevel)); this.currentFuelLevelClientOnly = newLevel; } public int getContainerSize() { return 27; } public float getCurAccel() { return this.curAccel; } public float getMaxAccel() { return this.maxAccel; } protected float getEyeHeight(Pose p_38327_, EntityDimensions p_38328_) { return p_38328_.height; } protected MovementEmission getMovementEmission() { return MovementEmission.NONE; } protected void defineSynchedData() { this.entityData.define(DATA_ID_HURT, 0); this.entityData.define(DATA_ID_HURTDIR, 1); this.entityData.define(DATA_ID_DAMAGE, Float.valueOf(0.0f)); this.entityData.define(DATA_ID_PADDLE_LEFT, false); this.entityData.define(DATA_ID_PADDLE_RIGHT, false); this.entityData.define(DATA_ID_ADDED_FREE_GAS, false); this.entityData.define(DATA_ID_BUBBLE_TIME, 0); this.entityData.define(DATA_ID_FUEL_LEVEL, Float.valueOf(1.0f)); } public boolean canCollideWith(Entity p_38376_) { return canVehicleCollide(this, p_38376_); } public static boolean canVehicleCollide(Entity p_38324_, Entity p_38325_) { return (p_38325_.canBeCollidedWith() || p_38325_.isPushable()) && !p_38324_.isPassengerOfSameVehicle(p_38325_); } public boolean canBeCollidedWith() { return true; } public boolean isPushable() { return true; } public boolean isBackingUp() { return this.backingUp; } protected Vec3 getRelativePortalPosition(Direction.Axis p_38335_, BlockUtil.FoundRectangle p_38336_) { return LivingEntity.resetForwardDirectionOfRelativePortalPosition(super.getRelativePortalPosition(p_38335_, p_38336_)); } public double getPassengersRidingOffset() { return -0.1d; } public boolean hurt(DamageSource p_38319_, float p_38320_) { if (isInvulnerableTo(p_38319_)) { return false; } if (!this.level.isClientSide && !isRemoved()) { setHurtDir(-getHurtDir()); setHurtTime(10); setDamage(getDamage() + (p_38320_ * 10.0f)); markHurt(); gameEvent(GameEvent.ENTITY_DAMAGED, p_38319_.getEntity()); boolean flag = (p_38319_.getEntity() instanceof Player) && p_38319_.getEntity().getAbilities().instabuild; if (flag || getDamage() > 40.0f) { if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ItemStack boatToSpawn = new ItemStack(new ItemLike() { // from class: com.dairymoose.entity.MotorboatEntity.1 public Item asItem() { return MotorboatEntity.this.getDropItem(); } }); float fuelLevel = ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue(); boatToSpawn.addTagElement("FuelLevel", FloatTag.valueOf(fuelLevel)); spawnAtLocation(boatToSpawn); } discard(); return true; } return true; } return true; } public void onAboveBubbleCol(boolean p_38381_) { if (!this.level.isClientSide) { this.isAboveBubbleColumn = true; this.bubbleColumnDirectionIsDown = p_38381_; if (getBubbleTime() == 0) { setBubbleTime(60); } } this.level.addParticle(ParticleTypes.SPLASH, getX() + this.random.nextFloat(), getY() + 0.7d, getZ() + this.random.nextFloat(), 0.0d, 0.0d, 0.0d); if (this.random.nextInt(20) == 0) { this.level.playLocalSound(getX(), getY(), getZ(), getSwimSplashSound(), getSoundSource(), 1.0f, 0.8f + (0.4f * this.random.nextFloat()), false); } gameEvent(GameEvent.SPLASH, getControllingPassenger()); } public void push(Entity p_38373_) { if (p_38373_ instanceof MotorboatEntity) { if (p_38373_.getBoundingBox().minY < getBoundingBox().maxY) { super.push(p_38373_); } } else if (p_38373_.getBoundingBox().minY <= getBoundingBox().minY) { super.push(p_38373_); } } public Item getDropItem() { return CustomBlocks.ITEM_MOTORBOAT.get(); } public void animateHurt() { setHurtDir(-getHurtDir()); setHurtTime(10); setDamage(getDamage() * 11.0f); } public boolean isPickable() { return !isRemoved(); } public void lerpTo(double p_38299_, double p_38300_, double p_38301_, float p_38302_, float p_38303_, int p_38304_, boolean p_38305_) { this.lerpX = p_38299_; this.lerpY = p_38300_; this.lerpZ = p_38301_; this.lerpYRot = p_38302_; this.lerpXRot = p_38303_; this.lerpSteps = 10; } public Direction getMotionDirection() { return getDirection().getClockWise(); } private void motorboatSound(Level world, Player player, int count) { if (count % 4 != 0 || this.status != Status.IN_WATER || isOutOfFuel()) { return; } float volumeDiff = 1.0f - 0.7f; float currentVolume = 0.7f + ((this.curAccel / this.maxAccel) * volumeDiff); float pitchDiff = 1.8f - 1.0f; float currentPitch = 1.0f + ((this.curAccel / this.maxAccel) * pitchDiff); if (currentVolume < 0.7f) { currentVolume = 0.7f; } if (currentPitch < 1.0f) { currentPitch = 1.0f; } if (player == null) { if (isControlledByLocalInstance()) { Minecraft.getInstance().player.playSound(CustomBlocks.SOUND_BOAT_MOTOR.get(), currentVolume, currentPitch); return; } return; } world.playSound(player, player.blockPosition(), CustomBlocks.SOUND_BOAT_MOTOR.get(), SoundSource.BLOCKS, currentVolume, currentPitch); } public void tick() { SoundEvent soundevent; this.tickCount++; if (this.level.isClientSide && isControlledByLocalInstance()) { if (Minecraft.getInstance().player != null) { Input pInput = Minecraft.getInstance().player.input; setInput(pInput.left, pInput.right, pInput.up, pInput.down); } } else { setInput(false, false, false, false); } this.oldStatus = this.status; this.status = getStatus(); if (this.status == Status.UNDER_WATER || this.status == Status.UNDER_FLOWING_WATER) { this.outOfControlTicks += 1.0f; } else { this.outOfControlTicks = 0.0f; } if (!this.level.isClientSide && this.outOfControlTicks >= 60.0f) { ejectPassengers(); } if (getHurtTime() > 0) { setHurtTime(getHurtTime() - 1); } if (getDamage() > 0.0f) { setDamage(getDamage() - 1.0f); } super.tick(); tickLerp(); Entity controller = getControllingPassenger(); Player controllingPlayer = null; if (controller instanceof Player) { controllingPlayer = (Player) controller; } if (controllingPlayer != null) { Vec3 currentPos = new Vec3(getX(), getY(), getZ()); Vec3 deltaMov = new Vec3(0.8d, 0.0d, 0.0d).yRot(((-(getYRot() - 30.0f)) * 0.017453292f) - 1.5707964f); Vec3 deltaMov2 = new Vec3(0.8d, 0.0d, 0.0d).yRot(((-(getYRot() + 30.0f)) * 0.017453292f) - 1.5707964f); Vec3 scaled1_left = currentPos.add(deltaMov.scale(1.0d)); Vec3 scaled1_right = currentPos.add(deltaMov2.scale(1.0d)); BlockPos posToCheck1_left = new BlockPos(scaled1_left.x, scaled1_left.y, scaled1_left.z).above(); BlockPos posToCheck1_right = new BlockPos(scaled1_right.x, scaled1_right.y, scaled1_right.z).above(); BlockState state1 = this.level.getBlockState(posToCheck1_left); BlockState state2 = this.level.getBlockState(posToCheck1_right); if (state1.is(Blocks.LILY_PAD) || state2.is(Blocks.LILY_PAD)) { if ((this.level instanceof ServerLevel) && state1.is(Blocks.LILY_PAD)) { this.level.m_46961_(posToCheck1_left, true); } if ((this.level instanceof ServerLevel) && state2.is(Blocks.LILY_PAD)) { this.level.m_46961_(posToCheck1_right, true); } } if (this.level.isClientSide) { motorboatSound(this.level, null, this.tickCount); } else { motorboatSound(this.level, controllingPlayer, this.tickCount); } } if (isControlledByLocalInstance()) { if (!(getFirstPassenger() instanceof Player)) { setPaddleState(false, false); } floatMotorboatEntity(); if (this.level.isClientSide) { controlMotorboatEntity(); } move(MoverType.SELF, getDeltaMovement()); if (this.horizontalCollision) { this.curAccel = 0.0f; } } else { setDeltaMovement(Vec3.ZERO); } tickBubbleColumn(); int i = 0; while (i <= 1) { if (getPaddleState(i)) { if (!isSilent() && this.paddlePositions[i] % 6.2831855f <= 0.7853981852531433d && (this.paddlePositions[i] + PADDLE_SPEED) % 6.2831854820251465d >= 0.7853981852531433d && (soundevent = getPaddleSound()) != null) { Vec3 vec3 = getViewVector(1.0f); double d0 = i == 1 ? -vec3.z : vec3.z; double d1 = i == 1 ? vec3.x : -vec3.x; this.level.playSound((Player) null, getX() + d0, getY(), getZ() + d1, soundevent, getSoundSource(), 1.0f, 0.8f + (0.4f * this.random.nextFloat())); this.level.gameEvent(getControllingPassenger(), GameEvent.SPLASH, new BlockPos(getX() + d0, getY(), getZ() + d1)); } this.paddlePositions[i] = (float) (this.paddlePositions[i] + PADDLE_SPEED); } else { this.paddlePositions[i] = 0.0f; } i++; } checkInsideBlocks(); List list = this.level.getEntities(this, getBoundingBox().inflate(0.20000000298023224d, -0.009999999776482582d, 0.20000000298023224d), EntitySelector.pushableBy(this)); if (!list.isEmpty()) { boolean flag = (this.level.isClientSide || (getControllingPassenger() instanceof Player)) ? false : true; for (int j = 0; j < list.size(); j++) { Entity entity = list.get(j); if (!entity.hasPassenger(this)) { if (flag && getPassengers().size() < 4 && !entity.isPassenger() && entity.getBbWidth() < getBbWidth() && (entity instanceof LivingEntity) && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { entity.startRiding(this); } else { push(entity); } } } } } private void tickBubbleColumn() { if (this.level.isClientSide) { int i = getBubbleTime(); if (i > 0) { this.bubbleMultiplier += 0.05f; } else { this.bubbleMultiplier -= 0.1f; } this.bubbleMultiplier = Mth.clamp(this.bubbleMultiplier, 0.0f, 1.0f); this.bubbleAngleO = this.bubbleAngle; this.bubbleAngle = 10.0f * ((float) Math.sin(0.5f * ((float) this.level.getGameTime()))) * this.bubbleMultiplier; return; } if (!this.isAboveBubbleColumn) { setBubbleTime(0); } int k = getBubbleTime(); if (k > 0) { int k2 = k - 1; setBubbleTime(k2); int j = (60 - k2) - 1; if (j > 0 && k2 == 0) { setBubbleTime(0); Vec3 vec3 = getDeltaMovement(); if (this.bubbleColumnDirectionIsDown) { setDeltaMovement(vec3.add(0.0d, -0.7d, 0.0d)); ejectPassengers(); } else { setDeltaMovement(vec3.x, hasPassenger(p_150274_ -> { return p_150274_ instanceof Player; }) ? 2.7d : 0.6d, vec3.z); } } this.isAboveBubbleColumn = false; } } @Nullable protected SoundEvent getPaddleSound() { switch (getStatus()) { case IN_WATER: case UNDER_WATER: case UNDER_FLOWING_WATER: return SoundEvents.BOAT_PADDLE_WATER; case ON_LAND: return SoundEvents.BOAT_PADDLE_LAND; case IN_AIR: default: return null; } } private void tickLerp() { if (isControlledByLocalInstance()) { this.lerpSteps = 0; setPacketCoordinates(getX(), getY(), getZ()); } if (this.lerpSteps > 0) { double d0 = getX() + ((this.lerpX - getX()) / this.lerpSteps); double d1 = getY() + ((this.lerpY - getY()) / this.lerpSteps); double d2 = getZ() + ((this.lerpZ - getZ()) / this.lerpSteps); double d3 = Mth.wrapDegrees(this.lerpYRot - getYRot()); setYRot(getYRot() + (((float) d3) / this.lerpSteps)); setXRot(getXRot() + (((float) (this.lerpXRot - getXRot())) / this.lerpSteps)); this.lerpSteps--; setPos(d0, d1, d2); setRot(getYRot(), getXRot()); } } public void setPaddleState(boolean p_38340_, boolean p_38341_) { this.entityData.set(DATA_ID_PADDLE_LEFT, Boolean.valueOf(p_38340_)); this.entityData.set(DATA_ID_PADDLE_RIGHT, Boolean.valueOf(p_38341_)); } public float getRowingTime(int p_38316_, float p_38317_) { if (getPaddleState(p_38316_)) { return (float) Mth.clampedLerp(this.paddlePositions[p_38316_] - PADDLE_SPEED, this.paddlePositions[p_38316_], p_38317_); } return 0.0f; } public Status getStatus() { Status boat$status = isUnderwater(); if (boat$status != null) { this.waterLevel = getBoundingBox().maxY; return boat$status; } if (checkInWater()) { return Status.IN_WATER; } float f = getGroundFriction(); if (f > 0.0f) { this.landFriction = f; return Status.ON_LAND; } return Status.IN_AIR; } /* JADX WARN: Code restructure failed: missing block: B:17:0x00c4, code lost: r14 = r14 + 1; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public float getWaterLevelAbove() { /* r5 = this; r0 = r5 net.minecraft.world.phys.AABB r0 = r0.getBoundingBox() r6 = r0 r0 = r6 double r0 = r0.minX int r0 = net.minecraft.util.Mth.floor(r0) r7 = r0 r0 = r6 double r0 = r0.maxX int r0 = net.minecraft.util.Mth.ceil(r0) r8 = r0 r0 = r6 double r0 = r0.maxY int r0 = net.minecraft.util.Mth.floor(r0) r9 = r0 r0 = r6 double r0 = r0.maxY r1 = r5 double r1 = r1.lastYd double r0 = r0 - r1 int r0 = net.minecraft.util.Mth.ceil(r0) r10 = r0 r0 = r6 double r0 = r0.minZ int r0 = net.minecraft.util.Mth.floor(r0) r11 = r0 r0 = r6 double r0 = r0.maxZ int r0 = net.minecraft.util.Mth.ceil(r0) r12 = r0 net.minecraft.core.BlockPos$MutableBlockPos r0 = new net.minecraft.core.BlockPos$MutableBlockPos r1 = r0 r1.() r13 = r0 r0 = r9 r14 = r0 L4b: r0 = r14 r1 = r10 if (r0 >= r1) goto Lca r0 = 0 r15 = r0 r0 = r7 r16 = r0 L58: r0 = r16 r1 = r8 if (r0 >= r1) goto Lb3 r0 = r11 r17 = r0 L62: r0 = r17 r1 = r12 if (r0 >= r1) goto Lad r0 = r13 r1 = r16 r2 = r14 r3 = r17 net.minecraft.core.BlockPos$MutableBlockPos r0 = r0.set(r1, r2, r3) r0 = r5 net.minecraft.world.level.Level r0 = r0.level r1 = r13 net.minecraft.world.level.material.FluidState r0 = r0.getFluidState(r1) r18 = r0 r0 = r18 net.minecraft.tags.TagKey r1 = net.minecraft.tags.FluidTags.WATER boolean r0 = r0.is(r1) if (r0 == 0) goto L9d r0 = r15 r1 = r18 r2 = r5 net.minecraft.world.level.Level r2 = r2.level r3 = r13 float r1 = r1.getHeight(r2, r3) float r0 = java.lang.Math.max(r0, r1) r15 = r0 L9d: r0 = r15 r1 = 1065353216(0x3f800000, float:1.0) int r0 = (r0 > r1 ? 1 : (r0 == r1 ? 0 : -1)) if (r0 < 0) goto La7 goto Lc4 La7: int r17 = r17 + 1 goto L62 Lad: int r16 = r16 + 1 goto L58 Lb3: r0 = r15 r1 = 1065353216(0x3f800000, float:1.0) int r0 = (r0 > r1 ? 1 : (r0 == r1 ? 0 : -1)) if (r0 >= 0) goto Lc4 r0 = r13 int r0 = r0.getY() float r0 = (float) r0 r1 = r15 float r0 = r0 + r1 return r0 Lc4: int r14 = r14 + 1 goto L4b Lca: r0 = r10 r1 = 1 int r0 = r0 + r1 float r0 = (float) r0 return r0 */ throw new UnsupportedOperationException("Method not decompiled: com.dairymoose.entity.MotorboatEntity.getWaterLevelAbove():float"); } public float getGroundFriction() { AABB aabb = getBoundingBox(); AABB aabb1 = new AABB(aabb.minX, aabb.minY - 0.001d, aabb.minZ, aabb.maxX, aabb.minY, aabb.maxZ); int i = Mth.floor(aabb1.minX) - 1; int j = Mth.ceil(aabb1.maxX) + 1; int k = Mth.floor(aabb1.minY) - 1; int l = Mth.ceil(aabb1.maxY) + 1; int i1 = Mth.floor(aabb1.minZ) - 1; int j1 = Mth.ceil(aabb1.maxZ) + 1; VoxelShape voxelshape = Shapes.create(aabb1); float f = 0.0f; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); int l1 = i; while (l1 < j) { int i2 = i1; while (i2 < j1) { int j2 = ((l1 == i || l1 == j - 1) ? 1 : 0) + ((i2 == i1 || i2 == j1 - 1) ? 1 : 0); if (j2 != 2) { for (int k2 = k; k2 < l; k2++) { if (j2 <= 0 || (k2 != k && k2 != l - 1)) { blockpos$mutableblockpos.set(l1, k2, i2); BlockState blockstate = this.level.getBlockState(blockpos$mutableblockpos); if (!(blockstate.getBlock() instanceof WaterlilyBlock) && Shapes.joinIsNotEmpty(blockstate.m_60812_(this.level, blockpos$mutableblockpos).move(l1, k2, i2), voxelshape, BooleanOp.AND)) { f += blockstate.getFriction(this.level, blockpos$mutableblockpos, this); k1++; } } } } i2++; } l1++; } return f / k1; } private boolean checkInWater() { AABB aabb = getBoundingBox(); int i = Mth.floor(aabb.minX); int j = Mth.ceil(aabb.maxX); int k = Mth.floor(aabb.minY); int l = Mth.ceil(aabb.minY + 0.001d); int i1 = Mth.floor(aabb.minZ); int j1 = Mth.ceil(aabb.maxZ); boolean flag = false; this.waterLevel = -1.7976931348623157E308d; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int k1 = i; k1 < j; k1++) { for (int l1 = k; l1 < l; l1++) { for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level.getFluidState(blockpos$mutableblockpos); if (fluidstate.is(FluidTags.WATER)) { float f = l1 + fluidstate.getHeight(this.level, blockpos$mutableblockpos); this.waterLevel = Math.max(f, this.waterLevel); flag |= aabb.minY < ((double) f); } } } } return flag; } @Nullable private Status isUnderwater() { AABB aabb = getBoundingBox(); double d0 = aabb.maxY + 0.001d; int i = Mth.floor(aabb.minX); int j = Mth.ceil(aabb.maxX); int k = Mth.floor(aabb.maxY); int l = Mth.ceil(d0); int i1 = Mth.floor(aabb.minZ); int j1 = Mth.ceil(aabb.maxZ); boolean flag = false; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int k1 = i; k1 < j; k1++) { for (int l1 = k; l1 < l; l1++) { for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level.getFluidState(blockpos$mutableblockpos); if (fluidstate.is(FluidTags.WATER) && d0 < blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level, blockpos$mutableblockpos)) { if (!fluidstate.isSource()) { return Status.UNDER_FLOWING_WATER; } flag = true; } } } } if (flag) { return Status.UNDER_WATER; } return null; } private void floatMotorboatEntity() { double d1 = isNoGravity() ? 0.0d : -0.03999999910593033d; double d2 = 0.0d; this.invFriction = 0.05f; if (this.oldStatus == Status.IN_AIR && this.status != Status.IN_AIR && this.status != Status.ON_LAND) { this.curAccel = 0.0f; this.waterLevel = getY(1.0d); setPos(getX(), (getWaterLevelAbove() - getBbHeight()) + 0.101d, getZ()); setDeltaMovement(getDeltaMovement().multiply(1.0d, 0.0d, 1.0d)); this.lastYd = 0.0d; this.status = Status.IN_WATER; return; } if (this.status == Status.IN_WATER) { d2 = (this.waterLevel - getY()) / getBbHeight(); this.invFriction = 0.9f; } else if (this.status == Status.UNDER_FLOWING_WATER) { d1 = -7.0E-4d; this.invFriction = 0.9f; } else if (this.status == Status.UNDER_WATER) { d2 = 0.009999999776482582d; this.invFriction = 0.45f; } else if (this.status == Status.IN_AIR) { this.invFriction = 0.9f; } else if (this.status == Status.ON_LAND) { this.invFriction = this.landFriction; if (getControllingPassenger() instanceof Player) { this.landFriction /= 2.0f; } } Vec3 vec3 = getDeltaMovement(); setDeltaMovement(vec3.x * this.invFriction, vec3.y + d1, vec3.z * this.invFriction); this.deltaRotation *= this.invFriction; if (d2 > 0.0d) { Vec3 vec31 = getDeltaMovement(); setDeltaMovement(vec31.x, (vec31.y + (d2 * 0.06153846016296973d)) * 0.75d, vec31.z); } } private void controlMotorboatEntity() { if (isVehicle()) { float accel = 0.0f; if (this.inputLeft) { this.deltaRotation -= 1.0f; } if (this.inputRight) { this.deltaRotation += 1.0f; } if (this.status == Status.ON_LAND) { this.curAccel = 0.0f; if (this.inputRight != this.inputLeft && !this.inputUp && !this.inputDown) { this.curAccel = 0.005f; } setYRot(getYRot() + this.deltaRotation); if (this.inputUp) { this.curAccel = 0.04f; } this.backingUp = false; if (this.inputDown) { this.curAccel = -0.04f; } } else { if (this.inputRight != this.inputLeft && !this.inputUp && !this.inputDown) { accel = 0.0f + (0.005f / 70.0f); } setYRot(getYRot() + this.deltaRotation); if (this.inputUp) { if (this.curAccel != 0.0f) { accel += 0.04f / 70.0f; } else { accel += 0.03f; } } this.backingUp = false; if (this.inputDown) { if (this.curAccel > 0.0f) { accel -= 0.15f / 70.0f; } else { this.backingUp = true; accel -= 0.04f / 70.0f; } } if (!this.inputUp && !this.inputDown) { if (this.curAccel > 0.0f) { this.curAccel -= 0.015f / 70.0f; } else if (this.curAccel < 0.0f) { this.curAccel += 0.015f / 70.0f; } if (this.curAccel > 0.0f && this.curAccel <= 0.015f) { this.curAccel = 0.0f; } if (this.curAccel < 0.0f && this.curAccel >= (-0.015f)) { this.curAccel = 0.0f; } } this.curAccel += accel; if (this.curAccel > this.maxAccel) { this.curAccel = this.maxAccel; } float maxNegativeAccel = (-this.maxAccel) / 3.0f; if (this.curAccel < maxNegativeAccel) { this.curAccel = maxNegativeAccel; } if (isOutOfFuel()) { this.curAccel = Math.min(this.curAccel, 0.005f); this.curAccel = Math.max(this.curAccel, -0.005f); } float newFuelLevel = this.currentFuelLevelClientOnly - (Math.abs(this.curAccel) * 4.1666665E-4f); if (newFuelLevel < 0.0f) { newFuelLevel = 0.0f; } this.currentFuelLevelClientOnly = newFuelLevel; if (this.tickCount % 100 == 0) { setSyncedFuelLevel(this.currentFuelLevelClientOnly); ModernLifeNetwork.INSTANCE.sendToServer(new ServerboundFuelLevelPacket(this.currentFuelLevelClientOnly, getId())); } } setDeltaMovement(getDeltaMovement().add(Mth.sin((-getYRot()) * 0.017453292f) * this.curAccel, 0.0d, Mth.cos(getYRot() * 0.017453292f) * this.curAccel)); setPaddleState((this.inputRight && !this.inputLeft) || this.inputUp, (this.inputLeft && !this.inputRight) || this.inputUp); } } public void positionRider(Entity entity) { if (hasPassenger(entity)) { float f = 0.0f; float f1 = (float) ((isRemoved() ? 0.009999999776482582d : getPassengersRidingOffset()) + entity.getMyRidingOffset()); if (getPassengers().size() > 0) { getPassengers().indexOf(entity); f = 0.5f; } int i = getPassengers().indexOf(entity); float[] passengerAngles = {-47.5f, 47.5f, 227.5f, 132.5f}; Vec3 vec3 = new Vec3(f, 0.0d, 0.0d).yRot(((-(getYRot() + passengerAngles[i % 4])) * 0.017453292f) - 1.5707964f); entity.setPos(getX() + vec3.x, getY() + f1, getZ() + vec3.z); entity.setYRot(entity.getYRot() + this.deltaRotation); entity.setYHeadRot(entity.getYHeadRot() + this.deltaRotation); clampRotation(entity); if ((entity instanceof Animal) && getPassengers().size() > 1) { int j = entity.getId() % 2 == 0 ? 90 : 270; entity.setYBodyRot(((Animal) entity).f_20883_ + j); entity.setYHeadRot(entity.getYHeadRot() + j); } } } protected void removePassenger(Entity entity) { if (this.level.isClientSide) { if (entity.hasCustomName()) { entity.setCustomNameVisible(true); } if (this.level.isClientSide && getControllingPassenger().getId() == entity.getId() && isControlledByLocalInstance()) { setSyncedFuelLevel(this.currentFuelLevelClientOnly); ModernLifeNetwork.INSTANCE.sendToServer(new ServerboundFuelLevelPacket(this.currentFuelLevelClientOnly, getId())); } } super.removePassenger(entity); } public Vec3 getDismountLocationForPassenger(LivingEntity entity) { Vec3 vec3 = Entity.getCollisionHorizontalEscapeVector(getBbWidth() * Mth.SQRT_OF_TWO, entity.getBbWidth(), entity.getYRot()); double d0 = getX() + vec3.x; double d1 = getZ() + vec3.z; BlockPos blockpos = new BlockPos(d0, getBoundingBox().maxY, d1); BlockPos blockpos1 = blockpos.below(); if (!this.level.isWaterAt(blockpos1)) { List list = Lists.newArrayList(); double d2 = this.level.getBlockFloorHeight(blockpos); if (DismountHelper.isBlockFloorValid(d2)) { list.add(new Vec3(d0, blockpos.getY() + d2, d1)); } double d3 = this.level.getBlockFloorHeight(blockpos1); if (DismountHelper.isBlockFloorValid(d3)) { list.add(new Vec3(d0, blockpos1.getY() + d3, d1)); } UnmodifiableIterator it = entity.getDismountPoses().iterator(); while (it.hasNext()) { Pose pose = (Pose) it.next(); for (Vec3 vec31 : list) { if (DismountHelper.canDismountTo(this.level, vec31, entity, pose)) { entity.setPose(pose); return vec31; } } } } return super.getDismountLocationForPassenger(entity); } protected void clampRotation(Entity p_38322_) { p_38322_.setYBodyRot(getYRot()); float f = Mth.wrapDegrees(p_38322_.getYRot() - getYRot()); float f1 = Mth.clamp(f, -105.0f, 105.0f); p_38322_.yRotO += f1 - f; p_38322_.setYRot((p_38322_.getYRot() + f1) - f); p_38322_.setYHeadRot(p_38322_.getYRot()); } public void onPassengerTurned(Entity p_38383_) { clampRotation(p_38383_); } public InteractionResult interact(Player player, InteractionHand p_38331_) { if (player.isSecondaryUseActive()) { if (!this.level.isClientSide) { return InteractionResult.CONSUME; } return InteractionResult.SUCCESS; } if (this.outOfControlTicks < 60.0f) { if (!this.level.isClientSide) { ItemStack mainItem = player.getMainHandItem(); if (!mainItem.is(CustomBlocks.ITEM_GAS_CAN.get())) { return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; } float fuelLevel = ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue(); int fuelAsInteger = (int) (fuelLevel * 24000.0f); int deficit = FULL_FUEL_LEVEL - fuelAsInteger; int remainingDurability = mainItem.getMaxDamage() - mainItem.getDamageValue(); int durabilityToConsume = Math.min(deficit, remainingDurability); if (durabilityToConsume > 0) { mainItem.hurtAndBreak(durabilityToConsume, player, p -> { }); this.level.playSound((Player) null, player.blockPosition(), SoundEvents.BUCKET_FILL, SoundSource.BLOCKS, 1.0f, 1.0f); float fuelAsFloat = (fuelAsInteger + durabilityToConsume) / 24000.0f; setSyncedFuelLevel(fuelAsFloat); } return InteractionResult.CONSUME; } return InteractionResult.SUCCESS; } return InteractionResult.PASS; } protected void checkFallDamage(double p_38307_, boolean p_38308_, BlockState p_38309_, BlockPos p_38310_) { this.lastYd = getDeltaMovement().y; if (!isPassenger()) { if (p_38308_) { if (this.fallDistance > 3.0f) { if (this.status != Status.ON_LAND) { resetFallDistance(); return; } causeFallDamage(this.fallDistance, 1.0f, DamageSource.FALL); if (!this.level.isClientSide && !isRemoved()) { kill(); if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { for (int i = 0; i < 3; i++) { spawnAtLocation(new ItemLike() { // from class: com.dairymoose.entity.MotorboatEntity.2 public Item asItem() { return Items.IRON_BLOCK; } }); } for (int j = 0; j < 2; j++) { spawnAtLocation(Items.STICK); } } } } resetFallDistance(); return; } if (!this.level.getFluidState(blockPosition().below()).is(FluidTags.WATER) && p_38307_ < 0.0d) { this.fallDistance = (float) (this.fallDistance - p_38307_); } } } public boolean getPaddleState(int p_38314_) { return ((Boolean) this.entityData.get(p_38314_ == 0 ? DATA_ID_PADDLE_LEFT : DATA_ID_PADDLE_RIGHT)).booleanValue() && getControllingPassenger() != null; } public void setDamage(float p_38312_) { this.entityData.set(DATA_ID_DAMAGE, Float.valueOf(p_38312_)); } public float getDamage() { return ((Float) this.entityData.get(DATA_ID_DAMAGE)).floatValue(); } public void setHurtTime(int p_38355_) { this.entityData.set(DATA_ID_HURT, Integer.valueOf(p_38355_)); } public int getHurtTime() { return ((Integer) this.entityData.get(DATA_ID_HURT)).intValue(); } private void setBubbleTime(int p_38367_) { this.entityData.set(DATA_ID_BUBBLE_TIME, Integer.valueOf(p_38367_)); } private int getBubbleTime() { return ((Integer) this.entityData.get(DATA_ID_BUBBLE_TIME)).intValue(); } public float getBubbleAngle(float p_38353_) { return Mth.lerp(p_38353_, this.bubbleAngleO, this.bubbleAngle); } public void setHurtDir(int p_38363_) { this.entityData.set(DATA_ID_HURTDIR, Integer.valueOf(p_38363_)); } public int getHurtDir() { return ((Integer) this.entityData.get(DATA_ID_HURTDIR)).intValue(); } protected boolean canAddPassenger(Entity p_38390_) { return getPassengers().size() < 4 && !isEyeInFluid(FluidTags.WATER); } @Nullable public Entity getControllingPassenger() { return getFirstPassenger(); } public void setInput(boolean p_38343_, boolean p_38344_, boolean p_38345_, boolean p_38346_) { this.inputLeft = p_38343_; this.inputRight = p_38344_; this.inputUp = p_38345_; this.inputDown = p_38346_; } public Packet getAddEntityPacket() { return new ClientboundAddEntityPacket(this); } public boolean isUnderWater() { return this.status == Status.UNDER_WATER || this.status == Status.UNDER_FLOWING_WATER; } protected void addPassenger(Entity passenger) { if (passenger.hasCustomName()) { passenger.setCustomNameVisible(false); } super.addPassenger(passenger); if (hasExactlyOnePlayerPassenger()) { if (this.level.isClientSide) { this.currentFuelLevelClientOnly = ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue(); } this.curAccel = 0.0f; } if (isControlledByLocalInstance() && this.lerpSteps > 0) { this.lerpSteps = 0; absMoveTo(this.lerpX, this.lerpY, this.lerpZ, (float) this.lerpYRot, (float) this.lerpXRot); } } public ItemStack getPickResult() { return new ItemStack(getDropItem()); } public void m_6211_() { this.itemStacks.clear(); } /* renamed from: createMenu */ public AbstractContainerMenu createMenu(int var1, Inventory var2, Player var3) { if (var3.isSpectator()) { return null; } return ChestMenu.threeRows(var1, var2, this); } public Component getDisplayName() { return new TextComponent("Motorboat"); } public boolean isEmpty() { Iterator it = this.itemStacks.iterator(); while (it.hasNext()) { ItemStack itemstack = (ItemStack) it.next(); if (!itemstack.isEmpty()) { return false; } } return true; } public ItemStack getItem(int p_38218_) { return (ItemStack) this.itemStacks.get(p_38218_); } public ItemStack removeItem(int p_38220_, int p_38221_) { return ContainerHelper.removeItem(this.itemStacks, p_38220_, p_38221_); } public ItemStack removeItemNoUpdate(int p_38244_) { ItemStack itemstack = (ItemStack) this.itemStacks.get(p_38244_); if (itemstack.isEmpty()) { return ItemStack.EMPTY; } this.itemStacks.set(p_38244_, ItemStack.EMPTY); return itemstack; } public void setItem(int p_38225_, ItemStack p_38226_) { this.itemStacks.set(p_38225_, p_38226_); if (!p_38226_.isEmpty() && p_38226_.getCount() > getMaxStackSize()) { p_38226_.setCount(getMaxStackSize()); } } public SlotAccess getSlot(final int p_150257_) { return (p_150257_ < 0 || p_150257_ >= getContainerSize()) ? super.getSlot(p_150257_) : new SlotAccess() { // from class: com.dairymoose.entity.MotorboatEntity.3 public ItemStack get() { return MotorboatEntity.this.getItem(p_150257_); } public boolean set(ItemStack p_150265_) { MotorboatEntity.this.setItem(p_150257_, p_150265_); return true; } }; } public void setChanged() { } public boolean stillValid(Player p_38230_) { return !isRemoved() && p_38230_.distanceToSqr(this) <= 64.0d; } public void remove(RemovalReason p_150255_) { if (!this.level.isClientSide && p_150255_.shouldDestroy()) { Containers.dropContents(this.level, this, this); } super.remove(p_150255_); } protected void addAdditionalSaveData(CompoundTag p_38248_) { if (p_38248_ != null) { ContainerHelper.saveAllItems(p_38248_, this.itemStacks); p_38248_.putFloat("FuelLevel", ((Float) this.entityData.get(DATA_ID_FUEL_LEVEL)).floatValue()); } } protected void readAdditionalSaveData(CompoundTag p_38235_) { if (p_38235_ != null) { ContainerHelper.loadAllItems(p_38235_, this.itemStacks); this.entityData.set(DATA_ID_FUEL_LEVEL, Float.valueOf(p_38235_.getFloat("FuelLevel"))); } } }