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.renderer.IRenderTypeBuffer;
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.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
@ -25,7 +24,8 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.AxisAlignedBB;
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;
public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEntity> {
@ -49,7 +49,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
return;
MatrixStacker msr = MatrixStacker.of(ms);
Vec3d itemPosition = VecHelper.getCenterOf(te.getPos());
Vector3d itemPosition = VecHelper.getCenterOf(te.getPos());
Direction insertedFrom = transported.insertedFrom;
if (!insertedFrom.getAxis()
@ -62,8 +62,9 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition);
float sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset);
Vec3d offsetVec = new Vec3d(insertedFrom.getOpposite()
.getDirectionVec()).scale(.5f - offset);
Vector3d offsetVec = Vector3d.of(insertedFrom.getOpposite()
.getDirectionVec())
.scale(.5f - offset);
ms.translate(offsetVec.x, offsetVec.y, offsetVec.z);
boolean alongX = insertedFrom.rotateY()
.getAxis() == Axis.X;
@ -94,9 +95,9 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
if (renderUpright) {
Entity renderViewEntity = Minecraft.getInstance().renderViewEntity;
if (renderViewEntity != null) {
Vec3d positionVec = renderViewEntity.getPositionVec();
Vec3d vectorForOffset = itemPosition.add(offsetVec);
Vec3d diff = vectorForOffset.subtract(positionVec);
Vector3d positionVec = renderViewEntity.getPositionVec();
Vector3d vectorForOffset = itemPosition.add(offsetVec);
Vector3d diff = vectorForOffset.subtract(positionVec);
if (insertedFrom.getAxis() != 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);
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++) {

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.behaviour.belt.DirectBeltInputBehaviour;
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.Pair;
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.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
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.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
@ -116,12 +117,15 @@ public class ItemDrainTileEntity extends SmartTileEntity {
DirectBeltInputBehaviour directBeltInputBehaviour =
TileEntityBehaviour.get(world, nextPosition, DirectBeltInputBehaviour.TYPE);
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;
Vec3d outPos = VecHelper.getCenterOf(pos)
.add(new Vec3d(side.getDirectionVec()).scale(.75));
Vector3d outPos = VecHelper.getCenterOf(pos)
.add(Vector3d.of(side.getDirectionVec())
.scale(.75));
float movementSpeed = itemMovementPerTick();
Vec3d outMotion = new Vec3d(side.getDirectionVec()).scale(movementSpeed)
Vector3d outMotion = Vector3d.of(side.getDirectionVec())
.scale(movementSpeed)
.add(0, 1 / 8f, 0);
outPos.add(outMotion.normalize());
ItemEntity entity = new ItemEntity(world, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected);
@ -232,14 +236,14 @@ public class ItemDrainTileEntity extends SmartTileEntity {
}
@Override
protected void read(CompoundNBT compound, boolean clientPacket) {
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
heldItem = null;
processingTicks = compound.getInt("ProcessingTicks");
if (compound.contains("HeldItem"))
heldItem = TransportedItemStack.read(compound.getCompound("HeldItem"));
super.read(compound, clientPacket);
super.fromTag(state, compound, clientPacket);
}
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (side != null && side.getAxis()