Fixed ridiculous client updates when GUI is open, fancy active sorter rendering, sorter eject sound effect :)

This commit is contained in:
Aidan Brady 2013-11-01 23:51:10 -04:00
parent 8db9c734d7
commit 799142198a
19 changed files with 141 additions and 24 deletions

View file

@ -1,5 +1,6 @@
package mekanism.client.model; package mekanism.client.model;
import mekanism.client.render.MekanismRenderer;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -189,7 +190,7 @@ public class ModelLogisticalSorter extends ModelBase
setRotation(DecorPlate, 0F, 0F, 0F); setRotation(DecorPlate, 0F, 0F, 0F);
} }
public void render(float size) public void render(float size, boolean active)
{ {
LeftThing.render(size); LeftThing.render(size);
RightThing.render(size); RightThing.render(size);
@ -197,6 +198,12 @@ public class ModelLogisticalSorter extends ModelBase
TopPlate.render(size); TopPlate.render(size);
LeftPlate.render(size); LeftPlate.render(size);
RightPlate.render(size); RightPlate.render(size);
if(active)
{
MekanismRenderer.glowOn();
}
BR1Block1.render(size); BR1Block1.render(size);
BL1Block1.render(size); BL1Block1.render(size);
TL1Block1.render(size); TL1Block1.render(size);
@ -205,6 +212,12 @@ public class ModelLogisticalSorter extends ModelBase
BL1Block2.render(size); BL1Block2.render(size);
TL1Block2.render(size); TL1Block2.render(size);
TR1Block2.render(size); TR1Block2.render(size);
if(active)
{
MekanismRenderer.glowOff();
}
PoleBR.render(size); PoleBR.render(size);
PoleTL.render(size); PoleTL.render(size);
PoleTR.render(size); PoleTR.render(size);

View file

@ -71,7 +71,7 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.85F, -0.15F); GL11.glTranslatef(0.0F, -0.85F, -0.15F);
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png")); Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png"));
logisticalSorter.render(0.0625F); logisticalSorter.render(0.0625F, false);
} }
else { else {
MekanismRenderer.renderItem(renderer, metadata, block); MekanismRenderer.renderItem(renderer, metadata, block);

View file

@ -24,7 +24,7 @@ public class RenderLogisticalSorter extends TileEntitySpecialRenderer
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png")); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter" + (tileEntity.isActive ? "On" : "") + ".png"));
switch(tileEntity.facing) switch(tileEntity.facing)
{ {
@ -47,7 +47,7 @@ public class RenderLogisticalSorter extends TileEntitySpecialRenderer
} }
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F); model.render(0.0625F, tileEntity.isActive);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -37,6 +37,8 @@ public class SoundHandler
/** The current base volume Minecraft is using. */ /** The current base volume Minecraft is using. */
public float masterVolume = 0; public float masterVolume = 0;
public Minecraft mc = Minecraft.getMinecraft();
/** /**
* SoundHandler -- a class that handles all Sounds used by Mekanism. * SoundHandler -- a class that handles all Sounds used by Mekanism.
*/ */
@ -59,6 +61,8 @@ public class SoundHandler
preloadSound(file.getName()); preloadSound(file.getName());
} }
} }
mc.sndManager.addSound("mekanism:etc/Click.ogg");
} }
private void preloadSound(String sound) private void preloadSound(String sound)

View file

@ -23,5 +23,7 @@ public interface IActiveState
* Whether or not this block has a visual effect when it is on it's active state. Used for rendering. * Whether or not this block has a visual effect when it is on it's active state. Used for rendering.
* @return if the block has a visual effect in it's active state * @return if the block has a visual effect in it's active state
*/ */
public boolean hasVisual(); public boolean renderUpdate();
public boolean lightUpdate();
} }

View file

@ -187,7 +187,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
public void randomDisplayTick(World world, int x, int y, int z, Random random) public void randomDisplayTick(World world, int x, int y, int z, Random random)
{ {
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z);
if(MekanismUtils.isActive(world, x, y, z) && !(tileEntity instanceof TileEntityChargepad)) if(MekanismUtils.isActive(world, x, y, z) && !(tileEntity instanceof TileEntityChargepad) && !(tileEntity instanceof TileEntityLogisticalSorter))
{ {
float xRandom = (float)x + 0.5F; float xRandom = (float)x + 0.5F;
float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F;
@ -225,7 +225,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
if(tileEntity instanceof IActiveState) if(tileEntity instanceof IActiveState)
{ {
if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).hasVisual()) if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate())
{ {
return 15; return 15;
} }

View file

@ -96,6 +96,16 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
if(worldObj.isRemote) if(worldObj.isRemote)
{ {
Mekanism.proxy.registerSound(this); Mekanism.proxy.registerSound(this);
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0)
{
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
} }
if(!worldObj.isRemote) if(!worldObj.isRemote)
@ -161,7 +171,11 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
sideConfig[i] = dataStream.readByte(); sideConfig[i] = dataStream.readByte();
} }
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); if(updateDelay == 0)
{
updateDelay = Mekanism.UPDATE_DELAY;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
@Override @Override
@ -377,7 +391,13 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{ {
return true; return true;
} }

View file

@ -297,7 +297,13 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{ {
return true; return true;
} }

View file

@ -111,6 +111,16 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
if(worldObj.isRemote) if(worldObj.isRemote)
{ {
Mekanism.proxy.registerSound(this); Mekanism.proxy.registerSound(this);
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0)
{
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
} }
if(!worldObj.isRemote) if(!worldObj.isRemote)
@ -414,7 +424,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
sideConfig[i] = dataStream.readByte(); sideConfig[i] = dataStream.readByte();
} }
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); if(updateDelay == 0)
{
updateDelay = Mekanism.UPDATE_DELAY;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
@Override @Override
@ -721,7 +735,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{ {
return true; return true;
} }

View file

@ -61,7 +61,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
{ {
delayTicks = Math.max(0, delayTicks-1); delayTicks = Math.max(0, delayTicks-1);
if(delayTicks == 8) if(delayTicks == 6)
{ {
setActive(false); setActive(false);
} }
@ -94,6 +94,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
if(TransporterUtils.insert(this, transporter, inInventory.itemStack, filterColor)) if(TransporterUtils.insert(this, transporter, inInventory.itemStack, filterColor))
{ {
inventory.setInventorySlotContents(inInventory.slotID, null); inventory.setInventorySlotContents(inInventory.slotID, null);
setActive(true);
} }
else { else {
inventory.setInventorySlotContents(inInventory.slotID, inInventory.itemStack); inventory.setInventorySlotContents(inInventory.slotID, inInventory.itemStack);
@ -361,6 +362,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
{ {
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList()))); PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
if(active)
{
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "mekanism:etc.Click", 0.3F, 1);
}
clientActive = active; clientActive = active;
} }
} }
@ -372,11 +378,17 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{ {
return true; return true;
} }
@Override
public boolean lightUpdate()
{
return false;
}
@Override @Override
protected EnumSet<ForgeDirection> getConsumingSides() protected EnumSet<ForgeDirection> getConsumingSides()
{ {

View file

@ -105,6 +105,16 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
if(worldObj.isRemote) if(worldObj.isRemote)
{ {
Mekanism.proxy.registerSound(this); Mekanism.proxy.registerSound(this);
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0)
{
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
} }
if(!worldObj.isRemote) if(!worldObj.isRemote)
@ -409,7 +419,11 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
sideConfig[i] = dataStream.readByte(); sideConfig[i] = dataStream.readByte();
} }
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); if(updateDelay == 0)
{
updateDelay = Mekanism.UPDATE_DELAY;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
@Override @Override
@ -616,7 +630,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{ {
return true; return true;
} }

View file

@ -604,13 +604,15 @@ public final class MekanismUtils
*/ */
public static void updateBlock(World world, int x, int y, int z) public static void updateBlock(World world, int x, int y, int z)
{ {
if(world.getBlockTileEntity(x, y, z) instanceof IActiveState && !((IActiveState)world.getBlockTileEntity(x, y, z)).hasVisual()) if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).renderUpdate())
{ {
return; world.markBlockForRenderUpdate(x, y, z);
} }
world.markBlockForRenderUpdate(x, y, z); if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).lightUpdate())
world.updateAllLightTypes(x, y, z); {
world.updateAllLightTypes(x, y, z);
}
} }
/** /**

View file

@ -149,7 +149,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator))
{ {
if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).hasVisual()) if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate())
{ {
return 15; return 15;
} }

View file

@ -390,7 +390,13 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{ {
return true; return true;
} }

View file

@ -175,7 +175,13 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{ {
return false; return false;
} }

View file

@ -106,7 +106,13 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
} }
@Override @Override
public boolean hasVisual() public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{ {
return false; return false;
} }

Binary file not shown.

Before

(image error) Size: 4 KiB

After

(image error) Size: 6.7 KiB

Binary file not shown.

After

(image error) Size: 6.6 KiB

Binary file not shown.