mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-18 11:29:30 +00:00
Improve model block lighting
This commit is contained in:
1 parent
1239a5a17a
commit
05f2c28afd
3 files changed
+34
-13
No files matched your search
@@ -81,18 +81,13 @@ public class BlockFarmStation extends AbstractMachineBlock<TileFarmStation> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof TileFarmStation) {
|
||||
// int res = ((TileFarmStation)te).isActive() ? 15 : 0;
|
||||
// return res;
|
||||
// }
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileFarmStation) {
|
||||
int res = ((TileFarmStation) te).isActive() ? 15 : 0;
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemShears;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -102,6 +103,8 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
|
||||
public String notification = "";
|
||||
public boolean sendNotification = false;
|
||||
|
||||
private boolean wasActive;
|
||||
|
||||
public TileFarmStation() {
|
||||
super(new SlotDefinition(7, 4, 1));
|
||||
@@ -326,6 +329,15 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
return (inventory[i] != null || !isSlotLocked(i)) && FarmersCommune.instance.canPlant(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if(isActive() != wasActive) {
|
||||
wasActive = isActive();
|
||||
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkProgress(boolean redstoneChecksPassed) {
|
||||
if(canTick(redstoneChecksPassed) && redstoneChecksPassed) {
|
||||
|
||||
@@ -204,8 +204,15 @@ public class TechneUtil {
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes) {
|
||||
renderWithIcon(model, icon, override, tes, null);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, VertexTransform vt) {
|
||||
renderWithIcon(model, icon, override, tes, null, 0, 0, 0, vt);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z) {
|
||||
renderWithIcon(model, icon, override, tes, world, x, y, z, null);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z, VertexTransform vt) {
|
||||
for (GroupObject go : model) {
|
||||
for (Face f : go.faces) {
|
||||
Vertex n = f.faceNormal;
|
||||
@@ -217,6 +224,13 @@ public class TechneUtil {
|
||||
}
|
||||
ForgeDirection down = normal.getRotation(right.getOpposite());
|
||||
|
||||
if(world != null && world.getBlock(x, y, z).getLightOpacity() > 0) {
|
||||
int bx = x + normal.offsetX;
|
||||
int by = y + normal.offsetY;
|
||||
int bz = z + normal.offsetZ;
|
||||
tes.setBrightness(world.getBlock(bx, by, bz).getMixedBrightnessForBlock(world, bx, by, bz));
|
||||
}
|
||||
|
||||
for (int i = 0; i < f.vertices.length; i++) {
|
||||
Vertex vert = f.vertices[i];
|
||||
Vector3d v = new Vector3d(vert);
|
||||
@@ -225,6 +239,7 @@ public class TechneUtil {
|
||||
}
|
||||
|
||||
TextureCoordinate t = f.textureCoordinates[i];
|
||||
|
||||
if(override != null) {
|
||||
|
||||
Vector3d tv = new Vector3d(v);
|
||||
@@ -239,7 +254,6 @@ public class TechneUtil {
|
||||
if(normal != ForgeDirection.UP && normal != ForgeDirection.DOWN) {
|
||||
interpV = 1 - interpV;
|
||||
}
|
||||
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, override.getInterpolatedU(interpU * 16), override.getInterpolatedV(interpV * 16));
|
||||
} else {
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 8));
|
||||
@@ -282,7 +296,7 @@ public class TechneUtil {
|
||||
tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(x + .5F, y + 0.0375f, z + .5F);
|
||||
renderWithIcon(model, icon, rb.overrideBlockTexture, tes, vt);
|
||||
renderWithIcon(model, icon, rb.overrideBlockTexture, tes, world, x, y, z, vt);
|
||||
tes.addTranslation(-x - .5F, -y - 0.0375f, -z - .5F);
|
||||
resetVT();
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user