mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
misc pipe frame fixes
This commit is contained in:
parent
3e10688a96
commit
871995e807
2 changed files with 17 additions and 3 deletions
|
@ -14,6 +14,7 @@ import net.minecraft.item.FilledMapItem;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
|
@ -25,12 +26,13 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.MapData;
|
||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class PipeFrameEntity extends ItemFrameEntity {
|
||||
public class PipeFrameEntity extends ItemFrameEntity implements IEntityAdditionalSpawnData {
|
||||
|
||||
private static final DataParameter<Integer> AMOUNT = EntityDataManager.createKey(PipeFrameEntity.class, DataSerializers.VARINT);
|
||||
|
||||
|
@ -157,4 +159,16 @@ public class PipeFrameEntity extends ItemFrameEntity {
|
|||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(PacketBuffer buffer) {
|
||||
buffer.writeBlockPos(this.hangingPosition);
|
||||
buffer.writeInt(this.facingDirection.getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(PacketBuffer additionalData) {
|
||||
this.hangingPosition = additionalData.readBlockPos();
|
||||
this.updateFacingWithBoundingBox(Direction.values()[additionalData.readInt()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class PipeFrameRenderer extends ItemFrameRenderer {
|
|||
Direction direction = entityIn.getHorizontalFacing();
|
||||
Vec3d vec3d = this.getRenderOffset(entityIn, partialTicks);
|
||||
matrixStackIn.translate(-vec3d.getX(), -vec3d.getY(), -vec3d.getZ());
|
||||
matrixStackIn.translate(direction.getXOffset() * 0.05, direction.getYOffset() * 0.05, direction.getZOffset() * 0.05);
|
||||
matrixStackIn.translate(direction.getXOffset() * 0.46875, direction.getYOffset() * 0.46875, direction.getZOffset() * 0.46875);
|
||||
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(entityIn.rotationPitch));
|
||||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F - entityIn.rotationYaw));
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class PipeFrameRenderer extends ItemFrameRenderer {
|
|||
String ammountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
float x = 0.5F - font.getStringWidth(ammountStrg) / 2F;
|
||||
Matrix4f matrix4f = matrixStackIn.getLast().getPositionMatrix();
|
||||
matrixStackIn.translate(0, 0.285F, 0);
|
||||
matrixStackIn.translate(0, 0.285F, 0.415F);
|
||||
matrixStackIn.scale(-0.02F, -0.02F, 0.02F);
|
||||
font.renderString(ammountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, false, 0, packedLightIn);
|
||||
|
||||
|
|
Loading…
Reference in a new issue