Gave all Mekanism multiblocks the sparkle animation when formed, gave Fusion Reactor a big loud sound effect, also lowered the energy required to ignite the reactor yet again (may bump up before release)

This commit is contained in:
Aidan C. Brady 2015-02-27 22:49:48 -06:00
parent 24935dd51e
commit 4aa032717e
10 changed files with 178 additions and 20 deletions

View file

@ -6,6 +6,7 @@ import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.client;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.Pos3D; import mekanism.api.Pos3D;
import mekanism.client.ThreadSparkle.INodeChecker;
import mekanism.client.entity.EntityLaser; import mekanism.client.entity.EntityLaser;
import mekanism.client.gui.GuiAmbientAccumulator; import mekanism.client.gui.GuiAmbientAccumulator;
import mekanism.client.gui.GuiChemicalCrystallizer; import mekanism.client.gui.GuiChemicalCrystallizer;
@ -112,6 +113,7 @@ import mekanism.common.entity.EntityRobit;
import mekanism.common.inventory.InventoryElectricChest; import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.item.ItemPortableTeleporter; import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.item.ItemSeismicReader; import mekanism.common.item.ItemSeismicReader;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedElectricMachine;
import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityAdvancedFactory;
import mekanism.common.tile.TileEntityAmbientAccumulator; import mekanism.common.tile.TileEntityAmbientAccumulator;
@ -164,6 +166,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -494,9 +497,30 @@ public class ClientProxy extends CommonProxy
} }
@Override @Override
public void doAnimation(TileEntityMultiblock<?> tileEntity) public void addHitEffects(Coord4D coord, MovingObjectPosition mop)
{ {
new ThreadMultiblockSparkle(tileEntity).start(); if(Minecraft.getMinecraft().theWorld != null)
{
Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(coord.xCoord, coord.yCoord, coord.zCoord, mop);
}
}
@Override
public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker)
{
new ThreadSparkle(tileEntity, checker).start();
}
@Override
public void doMultiblockSparkle(TileEntityMultiblock<?> tileEntity)
{
new ThreadSparkle(tileEntity, new INodeChecker() {
@Override
public boolean isNode(TileEntity tile)
{
return MultiblockManager.areEqual(tile, tileEntity);
}
}).start();
} }
@Override @Override

View file

@ -6,9 +6,6 @@ import java.util.Set;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.tile.TileEntityMultiblock;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -16,17 +13,20 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ThreadMultiblockSparkle extends Thread public class ThreadSparkle extends Thread
{ {
public TileEntityMultiblock<?> pointer; public TileEntity pointer;
public Random random = new Random(); public Random random = new Random();
public Set<TileEntity> iteratedNodes = new HashSet<TileEntity>(); public Set<TileEntity> iteratedNodes = new HashSet<TileEntity>();
public ThreadMultiblockSparkle(TileEntityMultiblock<?> tileEntity) public INodeChecker nodeChecker;
public ThreadSparkle(TileEntity tileEntity, INodeChecker checker)
{ {
pointer = tileEntity; pointer = tileEntity;
nodeChecker = checker;
} }
@Override @Override
@ -42,7 +42,7 @@ public class ThreadMultiblockSparkle extends Thread
} catch(Exception e) {} } catch(Exception e) {}
} }
public void loop(TileEntityMultiblock<?> tileEntity) public void loop(TileEntity tileEntity)
{ {
World world = pointer.getWorldObj(); World world = pointer.getWorldObj();
@ -85,10 +85,20 @@ public class ThreadMultiblockSparkle extends Thread
{ {
TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.getWorldObj()); TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.getWorldObj());
if(MultiblockManager.areEqual(tile, pointer) && !iteratedNodes.contains(tile)) if(tile != null && isNode(tile) && !iteratedNodes.contains(tile))
{ {
loop((TileEntityMultiblock<?>)tile); loop(tile);
} }
} }
} }
public boolean isNode(TileEntity tile)
{
return nodeChecker.isNode(tile);
}
public static interface INodeChecker
{
public boolean isNode(TileEntity tile);
}
} }

View file

@ -2,12 +2,14 @@ package mekanism.common;
import java.io.File; import java.io.File;
import mekanism.api.Coord4D;
import mekanism.api.MekanismAPI; import mekanism.api.MekanismAPI;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.usage; import mekanism.api.MekanismConfig.usage;
import mekanism.api.Pos3D; import mekanism.api.Pos3D;
import mekanism.api.util.UnitDisplayUtils.EnergyType; import mekanism.api.util.UnitDisplayUtils.EnergyType;
import mekanism.api.util.UnitDisplayUtils.TempType; import mekanism.api.util.UnitDisplayUtils.TempType;
import mekanism.client.ThreadSparkle.INodeChecker;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.entity.EntityRobit; import mekanism.common.entity.EntityRobit;
@ -97,6 +99,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -321,10 +324,20 @@ public class CommonProxy
return false; return false;
} }
/**
* Adds block hit effects on the client side.
*/
public void addHitEffects(Coord4D coord, MovingObjectPosition mop) {}
/**
* Does a generic creation animation, starting from the rendering block.
*/
public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker) {}
/** /**
* Does the multiblock creation animation, starting from the rendering block. * Does the multiblock creation animation, starting from the rendering block.
*/ */
public void doAnimation(TileEntityMultiblock<?> tileEntity) {} public void doMultiblockSparkle(TileEntityMultiblock<?> tileEntity) {}
/** /**
* Get the actual interface for a GUI. Client-only. * Get the actual interface for a GUI. Client-only.

View file

@ -13,7 +13,6 @@ import mekanism.common.base.IRedstoneControl;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
@ -99,6 +98,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
Block blockHit = hitCoord.getBlock(worldObj); Block blockHit = hitCoord.getBlock(worldObj);
TileEntity tileHit = hitCoord.getTileEntity(worldObj); TileEntity tileHit = hitCoord.getTileEntity(worldObj);
float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord);
if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig())))
{ {
diggingProgress += firing; diggingProgress += firing;
@ -109,7 +109,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
diggingProgress = 0; diggingProgress = 0;
} }
else { else {
Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord, mop); Mekanism.proxy.addHitEffects(hitCoord, mop);
} }
} }
} }

View file

@ -56,7 +56,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
{ {
if(!prevStructure) if(!prevStructure)
{ {
Mekanism.proxy.doAnimation(this); Mekanism.proxy.doMultiblockSparkle(this);
} }
} }

View file

@ -9,6 +9,7 @@ import java.util.Set;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.ISalinationSolar; import mekanism.api.ISalinationSolar;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.client.ThreadSparkle.INodeChecker;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.base.IDropperHandler; import mekanism.common.base.IDropperHandler;
@ -686,6 +687,17 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora
{ {
inputTank.setCapacity(getMaxWater()); inputTank.setCapacity(getMaxWater());
worldObj.func_147479_m(xCoord, yCoord, zCoord); worldObj.func_147479_m(xCoord, yCoord, zCoord);
if(structured)
{
Mekanism.proxy.doGenericSparkle(this, new INodeChecker() {
@Override
public boolean isNode(TileEntity tile)
{
return tile instanceof TileEntitySolarEvaporationBlock;
}
});
}
} }
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);

View file

@ -82,7 +82,7 @@ public class FusionReactor implements IFusionReactor
@Override @Override
public void addTemperatureFromEnergyInput(double energyAdded) public void addTemperatureFromEnergyInput(double energyAdded)
{ {
plasmaTemperature += energyAdded / plasmaHeatCapacity * (isBurning() ? 1 : 10); plasmaTemperature += energyAdded / plasmaHeatCapacity * (isBurning() ? 1 : 100);
} }
public boolean hasHohlraum() public boolean hasHohlraum()

View file

@ -1,20 +1,32 @@
package mekanism.generators.common.tile.reactor; package mekanism.generators.common.tile.reactor;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.client;
import mekanism.api.Pos3D;
import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.client.ThreadSparkle.INodeChecker;
import mekanism.client.sound.IHasSound;
import mekanism.client.sound.IResettableSound;
import mekanism.client.sound.ISoundSource;
import mekanism.client.sound.SoundHandler;
import mekanism.client.sound.TileSound;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.FusionReactor; import mekanism.generators.common.FusionReactor;
import net.minecraft.client.audio.ISound.AttenuationType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -22,9 +34,7 @@ import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf; public class TileEntityReactorController extends TileEntityReactorBlock implements IActiveState, IHasSound, ISoundSource
public class TileEntityReactorController extends TileEntityReactorBlock implements IActiveState
{ {
public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME; public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME;
@ -40,6 +50,10 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
public AxisAlignedBB box; public AxisAlignedBB box;
public ResourceLocation soundURL = new ResourceLocation("mekanism", "tile.machine.fusionreactor");
public IResettableSound sound;
public double clientTemp = 0; public double clientTemp = 0;
public boolean clientBurning = false; public boolean clientBurning = false;
@ -92,6 +106,12 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
{ {
super.onUpdate(); super.onUpdate();
if(worldObj.isRemote && shouldPlaySound() && SoundHandler.canRestartSound(getSound()) && client.enableMachineSounds)
{
getSound().reset();
SoundHandler.playSound(getSound());
}
if(isFormed()) if(isFormed())
{ {
getReactor().simulate(); getReactor().simulate();
@ -219,6 +239,17 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
if(formed) if(formed)
{ {
if(getReactor() == null || !((FusionReactor)getReactor()).formed)
{
Mekanism.proxy.doGenericSparkle(this, new INodeChecker() {
@Override
public boolean isNode(TileEntity tile)
{
return tile instanceof TileEntityReactorBlock;
}
});
}
if(getReactor() == null) if(getReactor() == null)
{ {
setReactor(new FusionReactor(this)); setReactor(new FusionReactor(this));
@ -291,4 +322,71 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
return box; return box;
} }
@Override
public IResettableSound getSound()
{
return sound;
}
@Override
public boolean shouldPlaySound()
{
return isBurning() && !isInvalid();
}
@Override
public ResourceLocation getSoundLocation()
{
return soundURL;
}
@Override
public float getVolume()
{
return 2F;
}
@Override
public float getPitch()
{
return 1F;
}
@Override
public Pos3D getSoundPosition()
{
return new Pos3D(xCoord+0.5, yCoord+0.5, zCoord+0.5);
}
@Override
public boolean shouldRepeat()
{
return true;
}
@Override
public int getRepeatDelay()
{
return 0;
}
@Override
public AttenuationType getAttenuation()
{
return AttenuationType.LINEAR;
}
@Override
public void validate()
{
super.validate();
initSounds();
}
public void initSounds()
{
sound = new TileSound(this, this);
}
} }

View file

@ -36,6 +36,7 @@
"tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber", "stream": false}]}, "tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber", "stream": false}]},
"tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter", "stream": false}]}, "tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter", "stream": false}]},
"tile.machine.laser": {"category": "block", "sounds": [{"name": "Laser", "stream": false}]}, "tile.machine.laser": {"category": "block", "sounds": [{"name": "Laser", "stream": false}]},
"tile.machine.fusionreactor": {"category": "block", "sounds": [{"name": "FusionReactor", "stream": false}]},
"tile.gen.bio": {"category": "block", "sounds": [{"name": "BioGenerator", "stream": false}]}, "tile.gen.bio": {"category": "block", "sounds": [{"name": "BioGenerator", "stream": false}]},
"tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator", "stream": false}]}, "tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator", "stream": false}]},