Merge pull request #1448 from Corail31/BOP-1.14.x-9.x.x
fix #1446 & add dispenser behavior for bop boats
This commit is contained in:
commit
a4e70ccc71
5 changed files with 56 additions and 25 deletions
|
@ -59,12 +59,6 @@ public class BoatEntityBOP extends BoatEntity {
|
|||
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;
|
||||
|
@ -80,8 +74,8 @@ public class BoatEntityBOP extends BoatEntity {
|
|||
private float rockingAngle;
|
||||
private float prevRockingAngle;
|
||||
|
||||
public BoatEntityBOP(EntityType<? extends BoatEntity> p_i50129_1_, World p_i50129_2_) {
|
||||
super(p_i50129_1_, p_i50129_2_);
|
||||
public BoatEntityBOP(EntityType<? extends BoatEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
this.preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
|
@ -231,7 +225,7 @@ public class BoatEntityBOP extends BoatEntity {
|
|||
}
|
||||
baseTick();
|
||||
|
||||
this.tickLerp();
|
||||
super.tickLerp();
|
||||
if (this.canPassengerSteer()) {
|
||||
if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof PlayerEntity)) {
|
||||
this.setPaddleState(false, false);
|
||||
|
@ -340,20 +334,6 @@ public class BoatEntityBOP extends BoatEntity {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package biomesoplenty.common.item;
|
||||
|
||||
import biomesoplenty.common.entity.item.BoatEntityBOP;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -26,6 +27,7 @@ public class BoatItemBOP extends Item {
|
|||
public BoatItemBOP(BoatEntityBOP.Type typeIn, Item.Properties properties) {
|
||||
super(properties);
|
||||
this.type = typeIn;
|
||||
DispenserBlock.registerDispenseBehavior(this, new DispenserBoatBehaviorBOP(typeIn));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package biomesoplenty.common.item;
|
||||
|
||||
import biomesoplenty.common.entity.item.BoatEntityBOP;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DispenserBoatBehaviorBOP extends DefaultDispenseItemBehavior {
|
||||
private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior();
|
||||
private final BoatEntityBOP.Type type;
|
||||
|
||||
public DispenserBoatBehaviorBOP(BoatEntityBOP.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ItemStack dispenseStack(IBlockSource iBlockSource, ItemStack stack) {
|
||||
Direction direction = iBlockSource.getBlockState().get(DispenserBlock.FACING);
|
||||
World world = iBlockSource.getWorld();
|
||||
double x = iBlockSource.getX() + (double) ((float) direction.getXOffset() * 1.125f);
|
||||
double y = iBlockSource.getY() + (double) ((float) direction.getYOffset() * 1.125f);
|
||||
double z = iBlockSource.getZ() + (double) ((float) direction.getZOffset() * 1.125f);
|
||||
BlockPos pos = iBlockSource.getBlockPos().offset(direction);
|
||||
double adjustY;
|
||||
if (world.getFluidState(pos).isTagged(FluidTags.WATER)) {
|
||||
adjustY = 1d;
|
||||
} else {
|
||||
if (!world.getBlockState(pos).isAir() || !world.getFluidState(pos.down()).isTagged(FluidTags.WATER)) {
|
||||
return this.defaultDispenseItemBehavior.dispense(iBlockSource, stack);
|
||||
}
|
||||
adjustY = 0d;
|
||||
}
|
||||
BoatEntityBOP boat = new BoatEntityBOP(world, x, y + adjustY, z);
|
||||
boat.setBoatModel(this.type);
|
||||
boat.rotationYaw = direction.getHorizontalAngle();
|
||||
world.addEntity(boat);
|
||||
stack.shrink(1);
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected void playDispenseSound(IBlockSource iBlockSource) {
|
||||
iBlockSource.getWorld().playEvent(1000, iBlockSource.getBlockPos(), 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,13 +7,11 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.init;
|
||||
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
import biomesoplenty.api.sound.BOPSounds;
|
||||
import biomesoplenty.common.entity.item.BoatEntityBOP;
|
||||
import biomesoplenty.common.item.BoatItemBOP;
|
||||
import biomesoplenty.common.item.MusicDiscItemBOP;
|
||||
import biomesoplenty.common.util.inventory.ItemGroupBOP;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
|
|
@ -16,3 +16,5 @@ public-f net.minecraft.item.AxeItem field_203176_a # BLOCK_STRIPPING_MAP
|
|||
# server.properties world type hackery
|
||||
public-f net.minecraft.server.dedicated.ServerProperties *
|
||||
public net.minecraft.server.dedicated.PropertyManager *
|
||||
|
||||
protected net.minecraft.entity.item.BoatEntity func_184447_s()V #tickLerp
|
||||
|
|
Loading…
Reference in a new issue