Merge branch 'master' into fix/same-network-multiple-extract-only-storage-bus

This commit is contained in:
Martin Robertz authored and GitHub committed 2025-01-05 01:04:50 +01:00
commit 880c5d3d70
3 files changed
+111 -25

No files matched your search

@@ -10,6 +10,7 @@ import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft; import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
public class RenderBlockWalrus extends TileEntitySpecialRenderer { public class RenderBlockWalrus extends TileEntitySpecialRenderer {
@@ -19,16 +20,28 @@ public class RenderBlockWalrus extends TileEntitySpecialRenderer {
@Override @Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) { public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus); Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
if (!(tileentity instanceof TileWalrus Tile)) return;
float scale = Tile.getWalrusScale();
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5); int orientation = Tile.getBlockMetadata();
int orientation = tileentity.getBlockMetadata(); switch (orientation) {
if (orientation == 4) { case 2:
GL11.glRotatef(90, 0, 1, 0); GL11.glTranslated(x + 0.5, y, z + 1 - scale * .655); // centering walrus model
} else if (orientation == 5) { break;
GL11.glRotatef(-90, 0, 1, 0); case 3:
} else if (orientation == 3) { GL11.glTranslated(x + 0.5, y, z + scale * .655);
GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(180, 0, 1, 0);
break;
case 4:
GL11.glTranslated(x + 1 - scale * .655, y, z + 0.5);
GL11.glRotatef(90, 0, 1, 0);
break;
case 5:
GL11.glTranslated(x + scale * .655, y, z + 0.5);
GL11.glRotatef(-90, 0, 1, 0);
break;
} }
GL11.glScalef(scale, scale, scale);
this.modelWalrus.renderAll(); this.modelWalrus.renderAll();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@@ -52,20 +52,20 @@ public class BlockWalrus extends BaseBlockContainer {
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if (l == 0) { if (l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2); world.setBlockMetadataWithNotify(x, y, z, 3, 2);
} }
if (l == 3) { if (l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2); world.setBlockMetadataWithNotify(x, y, z, 4, 2);
} }
if (l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
} }
@Override @Override
@@ -75,12 +75,28 @@ public class BlockWalrus extends BaseBlockContainer {
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) { TileEntity tileentity = blockAccess.getTileEntity(x, y, z);
case NORTH -> setBlockBounds(0.0F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F); if (tileentity instanceof TileWalrus Tile) {
case EAST -> setBlockBounds(0.0F, 0.0F, 0.0F, 2.0F, 1.0F, 1.0F); float scale = Tile.getWalrusScale();
case SOUTH -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F); switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) {
case WEST -> setBlockBounds(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); case NORTH -> setBlockBounds(
default -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); -(scale / 2 - 0.5F),
0.0F,
-scale * 2F + 1.0F,
(scale / 2 + 0.5f),
scale,
1.0F);
case EAST -> setBlockBounds(0.0F, 0.0F, -(scale / 2 - 0.5F), 2.0F * scale, scale, (scale / 2 + 0.5f));
case SOUTH -> setBlockBounds(-(scale / 2 - 0.5F), 0.F, 0.F, (scale / 2 + 0.5f), scale, 2.0F * scale);
case WEST -> setBlockBounds(
-scale * 2F + 1.0F,
0.0F,
-(scale / 2 - 0.5F),
1.0F,
scale,
(scale / 2 + 0.5f));
default -> setBlockBounds(0.0F, 0.0F, 0.0F, scale, scale, scale);
}
} }
} }
@@ -102,4 +118,17 @@ public class BlockWalrus extends BaseBlockContainer {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE)); toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
} }
} }
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID,
float offsetX, float offsetY, float offsetZ) {
TileEntity tileentity = worldObj.getTileEntity(x, y, z);
if (!(tileentity instanceof TileWalrus Tile)) return false;
if (entityplayer.isSneaking()) {
Tile.setWalrusScale(Tile.getWalrusScale() / 2);
} else {
Tile.setWalrusScale(Tile.getWalrusScale() * 2);
}
return true;
}
} }
@@ -1,11 +1,55 @@
package com.glodblock.github.common.tile; package com.glodblock.github.common.tile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
public class TileWalrus extends TileEntity { public class TileWalrus extends TileEntity {
private float scale = 1f;
@Override @Override
public boolean canUpdate() { public void readFromNBT(NBTTagCompound data) {
return false; super.readFromNBT(data);
if (data.hasKey("scale")) {
scale = data.getFloat("scale");
}
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setFloat("scale", scale);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
@Override
public double getMaxRenderDistanceSquared() {
return 102400;
}
public float getWalrusScale() {
return scale;
}
public void setWalrusScale(float f) {
if (f > 256f) f = 256f;
if (f < 0.03f) f = 0.03f;
scale = f;
markDirty();
} }
} }