Port changes to 1.16

This commit is contained in:
simibubi 2020-10-30 19:47:40 +01:00
parent d26139576c
commit 910bdf5d19
2 changed files with 23 additions and 18 deletions

View file

@ -16,7 +16,6 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -25,7 +24,8 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEntity> { public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEntity> {
@ -49,7 +49,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
return; return;
MatrixStacker msr = MatrixStacker.of(ms); MatrixStacker msr = MatrixStacker.of(ms);
Vec3d itemPosition = VecHelper.getCenterOf(te.getPos()); Vector3d itemPosition = VecHelper.getCenterOf(te.getPos());
Direction insertedFrom = transported.insertedFrom; Direction insertedFrom = transported.insertedFrom;
if (!insertedFrom.getAxis() if (!insertedFrom.getAxis()
@ -62,8 +62,9 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition); float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition);
float sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset); float sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset);
Vec3d offsetVec = new Vec3d(insertedFrom.getOpposite() Vector3d offsetVec = Vector3d.of(insertedFrom.getOpposite()
.getDirectionVec()).scale(.5f - offset); .getDirectionVec())
.scale(.5f - offset);
ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); ms.translate(offsetVec.x, offsetVec.y, offsetVec.z);
boolean alongX = insertedFrom.rotateY() boolean alongX = insertedFrom.rotateY()
.getAxis() == Axis.X; .getAxis() == Axis.X;
@ -94,9 +95,9 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
if (renderUpright) { if (renderUpright) {
Entity renderViewEntity = Minecraft.getInstance().renderViewEntity; Entity renderViewEntity = Minecraft.getInstance().renderViewEntity;
if (renderViewEntity != null) { if (renderViewEntity != null) {
Vec3d positionVec = renderViewEntity.getPositionVec(); Vector3d positionVec = renderViewEntity.getPositionVec();
Vec3d vectorForOffset = itemPosition.add(offsetVec); Vector3d vectorForOffset = itemPosition.add(offsetVec);
Vec3d diff = vectorForOffset.subtract(positionVec); Vector3d diff = vectorForOffset.subtract(positionVec);
if (insertedFrom.getAxis() != Axis.X) if (insertedFrom.getAxis() != Axis.X)
diff = VecHelper.rotate(diff, verticalAngle, Axis.X); diff = VecHelper.rotate(diff, verticalAngle, Axis.X);
@ -106,7 +107,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
float yRot = (float) MathHelper.atan2(diff.z, -diff.x); float yRot = (float) MathHelper.atan2(diff.z, -diff.x);
ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float) (yRot - Math.PI / 2))); ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float) (yRot - Math.PI / 2)));
} }
ms.translate(0, 0, -1/16f); ms.translate(0, 0, -1 / 16f);
} }
for (int i = 0; i <= count; i++) { for (int i = 0; i <= count; i++) {

View file

@ -10,18 +10,19 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.Block; import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -116,12 +117,15 @@ public class ItemDrainTileEntity extends SmartTileEntity {
DirectBeltInputBehaviour directBeltInputBehaviour = DirectBeltInputBehaviour directBeltInputBehaviour =
TileEntityBehaviour.get(world, nextPosition, DirectBeltInputBehaviour.TYPE); TileEntityBehaviour.get(world, nextPosition, DirectBeltInputBehaviour.TYPE);
if (directBeltInputBehaviour == null) { if (directBeltInputBehaviour == null) {
if (!Block.hasSolidSide(world.getBlockState(nextPosition), world, nextPosition, side.getOpposite())) { if (!BlockHelper.hasBlockSolidSide(world.getBlockState(nextPosition), world, nextPosition,
side.getOpposite())) {
ItemStack ejected = heldItem.stack; ItemStack ejected = heldItem.stack;
Vec3d outPos = VecHelper.getCenterOf(pos) Vector3d outPos = VecHelper.getCenterOf(pos)
.add(new Vec3d(side.getDirectionVec()).scale(.75)); .add(Vector3d.of(side.getDirectionVec())
.scale(.75));
float movementSpeed = itemMovementPerTick(); float movementSpeed = itemMovementPerTick();
Vec3d outMotion = new Vec3d(side.getDirectionVec()).scale(movementSpeed) Vector3d outMotion = Vector3d.of(side.getDirectionVec())
.scale(movementSpeed)
.add(0, 1 / 8f, 0); .add(0, 1 / 8f, 0);
outPos.add(outMotion.normalize()); outPos.add(outMotion.normalize());
ItemEntity entity = new ItemEntity(world, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); ItemEntity entity = new ItemEntity(world, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected);
@ -232,12 +236,12 @@ public class ItemDrainTileEntity extends SmartTileEntity {
} }
@Override @Override
protected void read(CompoundNBT compound, boolean clientPacket) { protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
heldItem = null; heldItem = null;
processingTicks = compound.getInt("ProcessingTicks"); processingTicks = compound.getInt("ProcessingTicks");
if (compound.contains("HeldItem")) if (compound.contains("HeldItem"))
heldItem = TransportedItemStack.read(compound.getCompound("HeldItem")); heldItem = TransportedItemStack.read(compound.getCompound("HeldItem"));
super.read(compound, clientPacket); super.fromTag(state, compound, clientPacket);
} }
@Override @Override