Merge branch 'master' into multipart-experimental-new
Conflicts: common/mekanism/common/Mekanism.java
|
@ -17,8 +17,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class ClientConnectionHandler implements IConnectionHandler
|
||||
{
|
||||
public VoiceClient voiceClient;
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {}
|
||||
|
||||
|
@ -35,8 +33,8 @@ public class ClientConnectionHandler implements IConnectionHandler
|
|||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
try {
|
||||
voiceClient = new VoiceClient(server, Mekanism.VOICE_PORT);
|
||||
voiceClient.run();
|
||||
MekanismClient.voiceClient = new VoiceClient(server, Mekanism.VOICE_PORT);
|
||||
MekanismClient.voiceClient.start();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
|
@ -48,28 +46,14 @@ public class ClientConnectionHandler implements IConnectionHandler
|
|||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
try {
|
||||
voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), Mekanism.VOICE_PORT);
|
||||
voiceClient.run();
|
||||
MekanismClient.voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), Mekanism.VOICE_PORT);
|
||||
MekanismClient.voiceClient.start();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager)
|
||||
{
|
||||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
if(voiceClient != null)
|
||||
{
|
||||
voiceClient.disconnect();
|
||||
voiceClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
Mekanism.jetpackOn.clear();
|
||||
Mekanism.proxy.unloadSoundHandler();
|
||||
}
|
||||
public void connectionClosed(INetworkManager manager) {}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {}
|
||||
|
|
|
@ -1,235 +0,0 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemElectricBow;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.network.PacketConfiguratorState;
|
||||
import mekanism.common.network.PacketElectricBowState;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketJetpackData.PacketType;
|
||||
import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientPlayerTickHandler implements ITickHandler
|
||||
{
|
||||
public boolean lastTickUpdate = false;
|
||||
public Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
if(tickData[0] instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)tickData[0];
|
||||
|
||||
ItemStack stack = entityPlayer.getCurrentEquippedItem();
|
||||
|
||||
if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
||||
{
|
||||
ItemConfigurator item = (ItemConfigurator)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0));
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack)));
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack))));
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
||||
{
|
||||
ItemElectricBow item = (ItemElectricBow)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
item.setFireState(stack, !item.getFireState(stack));
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricBowState().setParams(item.getFireState(stack)));
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Fire Mode: " + (item.getFireState(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF"))));
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
||||
{
|
||||
ItemWalkieTalkie item = (ItemWalkieTalkie)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
int newChan = item.getChannel(stack) < 9 ? item.getChannel(stack)+1 : 1;
|
||||
item.setChannel(stack, newChan);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketWalkieTalkieState().setParams(newChan));
|
||||
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
ItemStack jetpack = entityPlayer.getCurrentItemOrArmor(3);
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
((ItemJetpack)jetpack.getItem()).incrementMode(jetpack);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.MODE));
|
||||
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
|
||||
if(Mekanism.jetpackOn.contains(entityPlayer) != isJetpackOn(entityPlayer))
|
||||
{
|
||||
if(isJetpackOn(entityPlayer))
|
||||
{
|
||||
Mekanism.jetpackOn.add(entityPlayer);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(entityPlayer);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.UPDATE, entityPlayer, isJetpackOn(entityPlayer)));
|
||||
}
|
||||
|
||||
for(EntityPlayer entry : Mekanism.jetpackOn)
|
||||
{
|
||||
Mekanism.proxy.registerSound(entry);
|
||||
}
|
||||
|
||||
if(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
MekanismClient.updateKey(entityPlayer, Keyboard.KEY_SPACE);
|
||||
MekanismClient.updateKey(entityPlayer, Keyboard.KEY_LSHIFT);
|
||||
}
|
||||
|
||||
if(isJetpackOn(entityPlayer))
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)entityPlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL)
|
||||
{
|
||||
entityPlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D);
|
||||
entityPlayer.fallDistance = 0.0F;
|
||||
}
|
||||
else if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.HOVER)
|
||||
{
|
||||
if((!Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)))
|
||||
{
|
||||
if(entityPlayer.motionY > 0)
|
||||
{
|
||||
entityPlayer.motionY = Math.max(entityPlayer.motionY - 0.15D, 0);
|
||||
}
|
||||
else if(entityPlayer.motionY < 0)
|
||||
{
|
||||
entityPlayer.motionY = Math.min(entityPlayer.motionY + 0.15D, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE))
|
||||
{
|
||||
entityPlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D);
|
||||
}
|
||||
else if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
entityPlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
|
||||
entityPlayer.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
jetpack.useGas(entityPlayer.getCurrentItemOrArmor(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cacheJetpackOn(EntityPlayer player)
|
||||
{
|
||||
return Mekanism.jetpackOn.contains(player);
|
||||
}
|
||||
|
||||
public static boolean isJetpackOn(EntityPlayer player)
|
||||
{
|
||||
ItemStack stack = player.inventory.armorInventory[2];
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(stack.getItem() instanceof ItemJetpack)
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)stack.getItem();
|
||||
|
||||
if(jetpack.getGas(stack) != null)
|
||||
{
|
||||
if((Keyboard.isKeyDown(Keyboard.KEY_SPACE) && jetpack.getMode(stack) == JetpackMode.NORMAL))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "MekanismClientPlayer";
|
||||
}
|
||||
}
|
45
common/mekanism/client/ClientPlayerTracker.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package mekanism.client;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
|
||||
public class ClientPlayerTracker implements IPlayerTracker
|
||||
{
|
||||
@Override
|
||||
public void onPlayerLogin(EntityPlayer player) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout(EntityPlayer player)
|
||||
{
|
||||
Mekanism.jetpackOn.remove(player);
|
||||
|
||||
if(player.username.equals(Minecraft.getMinecraft().thePlayer.username))
|
||||
{
|
||||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
if(MekanismClient.voiceClient != null)
|
||||
{
|
||||
MekanismClient.voiceClient.disconnect();
|
||||
MekanismClient.voiceClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
Mekanism.proxy.unloadSoundHandler();
|
||||
|
||||
Mekanism.jetpackOn.clear();
|
||||
Mekanism.gasmaskOn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension(EntityPlayer player)
|
||||
{
|
||||
Mekanism.jetpackOn.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(EntityPlayer player) {}
|
||||
}
|
|
@ -4,10 +4,12 @@ package mekanism.client;
|
|||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.client.gui.GuiChemicalFormulator;
|
||||
import mekanism.client.gui.GuiCombiner;
|
||||
import mekanism.client.gui.GuiConfiguration;
|
||||
import mekanism.client.gui.GuiCredits;
|
||||
import mekanism.client.gui.GuiCrusher;
|
||||
import mekanism.client.gui.GuiDictionary;
|
||||
import mekanism.client.gui.GuiDigitalMiner;
|
||||
import mekanism.client.gui.GuiDynamicTank;
|
||||
import mekanism.client.gui.GuiElectricChest;
|
||||
|
@ -55,6 +57,7 @@ import mekanism.client.render.tileentity.RenderMetallurgicInfuser;
|
|||
import mekanism.client.render.tileentity.RenderObsidianTNT;
|
||||
import mekanism.client.render.tileentity.RenderPressurizedTube;
|
||||
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
|
||||
import mekanism.client.render.tileentity.RenderTeleporter;
|
||||
import mekanism.client.render.tileentity.RenderUniversalCable;
|
||||
import mekanism.client.sound.Sound;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
|
@ -71,6 +74,7 @@ import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
|
|||
import mekanism.common.tileentity.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tileentity.TileEntityBin;
|
||||
import mekanism.common.tileentity.TileEntityChargepad;
|
||||
import mekanism.common.tileentity.TileEntityChemicalFormulator;
|
||||
import mekanism.common.tileentity.TileEntityCombiner;
|
||||
import mekanism.common.tileentity.TileEntityCrusher;
|
||||
import mekanism.common.tileentity.TileEntityDigitalMiner;
|
||||
|
@ -110,6 +114,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
|||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -134,6 +139,7 @@ public class ClientProxy extends CommonProxy
|
|||
Mekanism.configuration.load();
|
||||
MekanismClient.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true);
|
||||
MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true);
|
||||
MekanismClient.baseSoundVolume = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SoundVolume", 1).getDouble(1);
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
|
@ -256,6 +262,7 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
|
||||
ClientRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner());
|
||||
ClientRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator", new RenderRotaryCondensentrator());
|
||||
ClientRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -295,6 +302,8 @@ public class ClientProxy extends CommonProxy
|
|||
|
||||
switch(ID)
|
||||
{
|
||||
case 0:
|
||||
return new GuiDictionary(player.inventory);
|
||||
case 1:
|
||||
return new GuiCredits();
|
||||
case 2:
|
||||
|
@ -323,6 +332,7 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiTeleporter(player.inventory, (TileEntityTeleporter)tileEntity);
|
||||
case 14:
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter)
|
||||
{
|
||||
return new GuiPortableTeleporter(player, itemStack);
|
||||
|
@ -341,6 +351,7 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiPasswordModify((TileEntityElectricChest)tileEntity);
|
||||
case 21:
|
||||
EntityRobit robit = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit != null)
|
||||
{
|
||||
return new GuiRobitMain(player.inventory, robit);
|
||||
|
@ -349,18 +360,22 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiRobitCrafting(player.inventory, world, x);
|
||||
case 23:
|
||||
EntityRobit robit1 = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit1 != null)
|
||||
{
|
||||
return new GuiRobitInventory(player.inventory, robit1);
|
||||
}
|
||||
case 24:
|
||||
EntityRobit robit2 = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit2 != null)
|
||||
{
|
||||
return new GuiRobitSmelting(player.inventory, robit2);
|
||||
}
|
||||
case 25:
|
||||
return new GuiRobitRepair(player.inventory, world, x);
|
||||
case 29:
|
||||
return new GuiChemicalFormulator(player.inventory, (TileEntityChemicalFormulator)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -378,12 +393,13 @@ public class ClientProxy extends CommonProxy
|
|||
super.loadUtilities();
|
||||
|
||||
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
||||
TickRegistry.registerTickHandler(new ClientPlayerTickHandler(), Side.CLIENT);
|
||||
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
|
||||
|
||||
NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler());
|
||||
|
||||
KeyBindingRegistry.registerKeyBinding(new MekanismKeyHandler());
|
||||
|
||||
GameRegistry.registerPlayerTracker(new ClientPlayerTracker());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,14 +8,38 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.client.sound.GasMaskSound;
|
||||
import mekanism.client.sound.JetpackSound;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemElectricBow;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.network.PacketConfiguratorState;
|
||||
import mekanism.common.network.PacketElectricBowState;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
||||
import mekanism.common.network.PacketScubaTankData;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
@ -34,7 +58,9 @@ public class ClientTickHandler implements ITickHandler
|
|||
|
||||
public boolean preloadedSounds = false;
|
||||
|
||||
public Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
public boolean lastTickUpdate;
|
||||
|
||||
public static Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
public static final String MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png";
|
||||
public static final String DONATE_CAPE = "https://dl.dropboxusercontent.com/u/90411166/donate.png";
|
||||
|
@ -160,9 +186,257 @@ public class ClientTickHandler implements ITickHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
|
||||
|
||||
if(mc.currentScreen == null)
|
||||
{
|
||||
if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
||||
{
|
||||
ItemConfigurator item = (ItemConfigurator)mc.thePlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0));
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack)));
|
||||
mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack))));
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
||||
{
|
||||
ItemElectricBow item = (ItemElectricBow)mc.thePlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
item.setFireState(stack, !item.getFireState(stack));
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricBowState().setParams(item.getFireState(stack)));
|
||||
mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Fire Mode: " + (item.getFireState(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF"))));
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
||||
{
|
||||
ItemWalkieTalkie item = (ItemWalkieTalkie)mc.thePlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
int newChan = item.getChannel(stack) < 9 ? item.getChannel(stack)+1 : 1;
|
||||
item.setChannel(stack, newChan);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketWalkieTalkieState().setParams(newChan));
|
||||
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
ItemStack jetpack = mc.thePlayer.getCurrentItemOrArmor(3);
|
||||
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
((ItemJetpack)jetpack.getItem()).incrementMode(jetpack);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(JetpackPacket.MODE));
|
||||
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
||||
lastTickUpdate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(Mekanism.jetpackOn.contains(mc.thePlayer.username) != isJetpackOn(mc.thePlayer))
|
||||
{
|
||||
if(isJetpackOn(mc.thePlayer))
|
||||
{
|
||||
Mekanism.jetpackOn.add(mc.thePlayer.username);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(mc.thePlayer.username);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(JetpackPacket.UPDATE, mc.thePlayer.username, isJetpackOn(mc.thePlayer)));
|
||||
}
|
||||
|
||||
if(Mekanism.gasmaskOn.contains(mc.thePlayer.username) != isGasMaskOn(mc.thePlayer))
|
||||
{
|
||||
if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null)
|
||||
{
|
||||
Mekanism.gasmaskOn.add(mc.thePlayer.username);
|
||||
}
|
||||
else {
|
||||
Mekanism.gasmaskOn.remove(mc.thePlayer.username);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(JetpackPacket.UPDATE, mc.thePlayer.username, isGasMaskOn(mc.thePlayer)));
|
||||
}
|
||||
|
||||
if(MekanismClient.audioHandler != null)
|
||||
{
|
||||
for(String username : Mekanism.jetpackOn)
|
||||
{
|
||||
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String username : Mekanism.gasmaskOn)
|
||||
{
|
||||
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
MekanismClient.updateKey(Keyboard.KEY_SPACE);
|
||||
MekanismClient.updateKey(Keyboard.KEY_LSHIFT);
|
||||
}
|
||||
|
||||
if(isJetpackOn(mc.thePlayer))
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)mc.thePlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
if(jetpack.getMode(mc.thePlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL)
|
||||
{
|
||||
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D);
|
||||
mc.thePlayer.fallDistance = 0.0F;
|
||||
}
|
||||
else if(jetpack.getMode(mc.thePlayer.getCurrentItemOrArmor(3)) == JetpackMode.HOVER)
|
||||
{
|
||||
if((!Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || mc.currentScreen != null)
|
||||
{
|
||||
if(mc.thePlayer.motionY > 0)
|
||||
{
|
||||
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, 0);
|
||||
}
|
||||
else if(mc.thePlayer.motionY < 0)
|
||||
{
|
||||
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && mc.currentScreen == null)
|
||||
{
|
||||
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D);
|
||||
}
|
||||
else if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && mc.currentScreen == null)
|
||||
{
|
||||
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
|
||||
mc.thePlayer.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
jetpack.useGas(mc.thePlayer.getCurrentItemOrArmor(3));
|
||||
}
|
||||
|
||||
if(isGasMaskOn(mc.thePlayer))
|
||||
{
|
||||
ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
tank.useGas(mc.thePlayer.getCurrentItemOrArmor(3));
|
||||
mc.thePlayer.setAir(300);
|
||||
mc.thePlayer.clearActivePotions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isJetpackOn(EntityPlayer player)
|
||||
{
|
||||
if(player != mc.thePlayer)
|
||||
{
|
||||
return Mekanism.jetpackOn.contains(player.username);
|
||||
}
|
||||
|
||||
ItemStack stack = player.inventory.armorInventory[2];
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(stack.getItem() instanceof ItemJetpack)
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)stack.getItem();
|
||||
|
||||
if(jetpack.getGas(stack) != null)
|
||||
{
|
||||
if((Keyboard.isKeyDown(Keyboard.KEY_SPACE) && jetpack.getMode(stack) == JetpackMode.NORMAL) && mc.currentScreen == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGasMaskOn(EntityPlayer player)
|
||||
{
|
||||
if(player != mc.thePlayer)
|
||||
{
|
||||
return Mekanism.gasmaskOn.contains(player.username);
|
||||
}
|
||||
|
||||
ItemStack tank = player.inventory.armorInventory[2];
|
||||
ItemStack mask = player.inventory.armorInventory[3];
|
||||
|
||||
if(tank != null && mask != null)
|
||||
{
|
||||
if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask)
|
||||
{
|
||||
ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem();
|
||||
|
||||
if(scubaTank.getGas(tank) != null)
|
||||
{
|
||||
if(scubaTank.getFlowing(tank))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package mekanism.client;
|
||||
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.client.voice.VoiceClient;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketKey;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
|
@ -18,18 +19,23 @@ public class MekanismClient extends Mekanism
|
|||
/** The main SoundHandler instance that is used by all audio sources */
|
||||
public static SoundHandler audioHandler;
|
||||
|
||||
public static VoiceClient voiceClient;
|
||||
|
||||
//General Configuration
|
||||
public static boolean enableSounds = true;
|
||||
public static boolean fancyUniversalCableRender = true;
|
||||
public static double baseSoundVolume = 1;
|
||||
|
||||
public static long ticksPassed = 0;
|
||||
|
||||
public static void updateKey(EntityPlayer player, int key)
|
||||
public static void updateKey(int key)
|
||||
{
|
||||
if(Keyboard.isKeyDown(key) != keyMap.has(player, key))
|
||||
boolean down = Minecraft.getMinecraft().currentScreen == null ? Keyboard.isKeyDown(key) : false;
|
||||
|
||||
if(down != keyMap.has(Minecraft.getMinecraft().thePlayer, key))
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketKey().setParams(key, Keyboard.isKeyDown(key)));
|
||||
keyMap.update(player, key, Keyboard.isKeyDown(key));
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketKey().setParams(key, down));
|
||||
keyMap.update(Minecraft.getMinecraft().thePlayer, key, down);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
128
common/mekanism/client/gui/GuiChemicalFormulator.java
Normal file
|
@ -0,0 +1,128 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.inventory.container.ContainerChemicalFormulator;
|
||||
import mekanism.common.tileentity.TileEntityChemicalFormulator;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiChemicalFormulator extends GuiMekanism
|
||||
{
|
||||
public TileEntityChemicalFormulator tileEntity;
|
||||
|
||||
public GuiChemicalFormulator(InventoryPlayer inventory, TileEntityChemicalFormulator tentity)
|
||||
{
|
||||
super(tentity, new ContainerChemicalFormulator(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalFormulator.png")));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
|
||||
{
|
||||
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
||||
}
|
||||
|
||||
if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72)
|
||||
{
|
||||
drawCreativeTabHoveringText(tileEntity.gasTank != null ? tileEntity.gasTank.getGas().getLocalizedName() + ": " + tileEntity.gasTank.amount : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalFormulator.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = mouseX - guiWidth;
|
||||
int yAxis = mouseY - guiHeight;
|
||||
|
||||
int displayInt;
|
||||
|
||||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
||||
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4);
|
||||
|
||||
displayInt = tileEntity.getScaledProgress(48);
|
||||
drawTexturedModalRect(guiWidth + 64, guiHeight + 40, 176, 63, displayInt + 1, 8);
|
||||
|
||||
if(tileEntity.getScaledGasLevel(58) > 0)
|
||||
{
|
||||
displayGauge(134, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
|
||||
{
|
||||
if(fluid == null && gas == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
int renderRemaining = 0;
|
||||
|
||||
if(scale > 16)
|
||||
{
|
||||
renderRemaining = 16;
|
||||
scale -= 16;
|
||||
}
|
||||
else {
|
||||
renderRemaining = scale;
|
||||
scale = 0;
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(fluid != null)
|
||||
{
|
||||
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
else if(gas != null)
|
||||
{
|
||||
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
|
||||
start+=16;
|
||||
|
||||
if(renderRemaining == 0 || scale == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalFormulator.png"));
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 40, 16, 59);
|
||||
}
|
||||
}
|
6
common/mekanism/client/gui/GuiChemicalInfuser.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
public class GuiChemicalInfuser
|
||||
{
|
||||
|
||||
}
|
155
common/mekanism/client/gui/GuiDictionary.java
Normal file
|
@ -0,0 +1,155 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.common.inventory.container.ContainerDictionary;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiDictionary extends GuiMekanism
|
||||
{
|
||||
public ItemStack itemType;
|
||||
|
||||
public String oreDictName;
|
||||
|
||||
public GuiDictionary(InventoryPlayer inventory)
|
||||
{
|
||||
super(new ContainerDictionary(inventory));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
if(itemType != null)
|
||||
{
|
||||
if(oreDictName != null && !oreDictName.isEmpty())
|
||||
{
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + oreDictName, 9, 57, 0x00CD00);
|
||||
}
|
||||
else {
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00);
|
||||
}
|
||||
}
|
||||
|
||||
if(itemType != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), itemType, 80, 23);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDictionary.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = mouseX - guiWidth;
|
||||
int yAxis = mouseY - guiHeight;
|
||||
|
||||
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
int x = guiWidth + 80;
|
||||
int y = guiHeight + 23;
|
||||
drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
Slot hovering = null;
|
||||
|
||||
for(int i = 0; i < inventorySlots.inventorySlots.size(); i++)
|
||||
{
|
||||
Slot slot = (Slot)inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if(isMouseOverSlot(slot, mouseX, mouseY))
|
||||
{
|
||||
hovering = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(hovering != null)
|
||||
{
|
||||
ItemStack stack = hovering.getStack();
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
itemType = stack.copy();
|
||||
itemType.stackSize = 1;
|
||||
|
||||
oreDictName = MekanismUtils.getOreDictName(itemType);
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39)
|
||||
{
|
||||
ItemStack stack = mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
itemType = stack.copy();
|
||||
itemType.stackSize = 1;
|
||||
|
||||
oreDictName = MekanismUtils.getOreDictName(itemType);
|
||||
}
|
||||
else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
itemType = null;
|
||||
oreDictName = null;
|
||||
}
|
||||
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
|
@ -19,9 +19,6 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
{
|
||||
public TileEntityDynamicTank tileEntity;
|
||||
|
||||
private int guiWidth;
|
||||
private int guiHeight;
|
||||
|
||||
public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity)
|
||||
{
|
||||
super(new ContainerDynamicTank(inventory, tentity));
|
||||
|
@ -59,8 +56,8 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiWidth = (width - xSize) / 2;
|
||||
guiHeight = (height - ySize) / 2;
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
if(tileEntity.getScaledFluidLevel(58) > 0)
|
||||
|
@ -70,9 +67,6 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Credit to BuildCraft for both the gauge texture and parts of the code.
|
||||
*/
|
||||
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/)
|
||||
{
|
||||
if(fluid == null)
|
||||
|
@ -80,6 +74,9 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
|
|
|
@ -3,7 +3,6 @@ package mekanism.client.gui;
|
|||
import mekanism.common.inventory.container.ContainerElectricMachine;
|
||||
import mekanism.common.tileentity.TileEntityElectricMachine;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -37,9 +36,7 @@ public class GuiElectricMachine extends GuiMekanism
|
|||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.inventory.container.ContainerElectricPump;
|
||||
import mekanism.common.tileentity.TileEntityElectricPump;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -19,9 +18,6 @@ public class GuiElectricPump extends GuiMekanism
|
|||
{
|
||||
public TileEntityElectricPump tileEntity;
|
||||
|
||||
private int guiWidth;
|
||||
private int guiHeight;
|
||||
|
||||
public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity)
|
||||
{
|
||||
super(new ContainerElectricPump(inventory, tentity));
|
||||
|
@ -59,8 +55,8 @@ public class GuiElectricPump extends GuiMekanism
|
|||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiWidth = (width - xSize) / 2;
|
||||
guiHeight = (height - ySize) / 2;
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
int displayInt;
|
||||
|
||||
|
@ -73,9 +69,6 @@ public class GuiElectricPump extends GuiMekanism
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Credit to BuildCraft for both the gauge texture and parts of the code.
|
||||
*/
|
||||
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid)
|
||||
{
|
||||
if(fluid == null)
|
||||
|
@ -83,6 +76,9 @@ public class GuiElectricPump extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
|
|
|
@ -26,9 +26,6 @@ public class GuiRotaryCondensentrator extends GuiMekanism
|
|||
{
|
||||
public TileEntityRotaryCondensentrator tileEntity;
|
||||
|
||||
private int guiWidth;
|
||||
private int guiHeight;
|
||||
|
||||
public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity)
|
||||
{
|
||||
super(new ContainerRotaryCondensentrator(inventory, tentity));
|
||||
|
@ -76,8 +73,8 @@ public class GuiRotaryCondensentrator extends GuiMekanism
|
|||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiWidth = (width - xSize) / 2;
|
||||
guiHeight = (height - ySize) / 2;
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
int displayInt;
|
||||
|
||||
|
@ -143,6 +140,9 @@ public class GuiRotaryCondensentrator extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
|
|
|
@ -46,11 +46,6 @@ public class ModelCustomArmor extends ModelBiped
|
|||
bipedBody.isHidden = false;
|
||||
bipedBody.showModel = true;
|
||||
}
|
||||
else if(modelType.armorSlot == 2)
|
||||
{
|
||||
bipedRightLeg.showModel = true;
|
||||
bipedLeftLeg.showModel = true;
|
||||
}
|
||||
|
||||
setRotationAngles(f, f1, f2, f3, f4, size, entity);
|
||||
}
|
||||
|
@ -109,9 +104,20 @@ public class ModelCustomArmor extends ModelBiped
|
|||
|
||||
mc.renderEngine.bindTexture(modelType.resource);
|
||||
|
||||
if(ModelCustomArmor.this.modelType == ArmorModel.JETPACK && biped.bipedBody == partRender)
|
||||
if(useModel(biped.modelType, partRender, biped))
|
||||
{
|
||||
ArmorModel.jetpackModel.render(0.0625F);
|
||||
if(biped.modelType == ArmorModel.JETPACK)
|
||||
{
|
||||
ArmorModel.jetpackModel.render(0.0625F);
|
||||
}
|
||||
else if(biped.modelType == ArmorModel.SCUBATANK)
|
||||
{
|
||||
|
||||
}
|
||||
else if(biped.modelType == ArmorModel.GASMASK)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
@ -125,10 +131,26 @@ public class ModelCustomArmor extends ModelBiped
|
|||
init(entity, par2, par3, par4, par5, par6, par7);
|
||||
super.render(entity, par2, par3, par4, par5, par6, par7);
|
||||
}
|
||||
|
||||
public static boolean useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped)
|
||||
{
|
||||
if(type.armorSlot == 0)
|
||||
{
|
||||
return partRender == biped.bipedHead;
|
||||
}
|
||||
else if(type.armorSlot == 1)
|
||||
{
|
||||
return partRender == biped.bipedBody;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static enum ArmorModel
|
||||
{
|
||||
JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png"));
|
||||
JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")),
|
||||
SCUBATANK(1, MekanismUtils.getResource(ResourceType.RENDER, "ScubaTank.png")),
|
||||
GASMASK(0, MekanismUtils.getResource(ResourceType.RENDER, "GasMask.png"));
|
||||
|
||||
public int armorSlot;
|
||||
public ResourceLocation resource;
|
||||
|
|
|
@ -3,19 +3,25 @@ package mekanism.client.render;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiChat;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityFlameFX;
|
||||
import net.minecraft.client.particle.EntitySmokeFX;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -25,6 +31,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class RenderTickHandler implements ITickHandler
|
||||
{
|
||||
public Random rand = new Random();
|
||||
public Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
|
||||
|
@ -33,7 +40,6 @@ public class RenderTickHandler implements ITickHandler
|
|||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
float partialTick = (Float)tickData[0];
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
if(mc.thePlayer != null && mc.theWorld != null)
|
||||
{
|
||||
|
@ -71,29 +77,47 @@ public class RenderTickHandler implements ITickHandler
|
|||
}
|
||||
}
|
||||
|
||||
if(player != null)
|
||||
if(player != null && !(mc.currentScreen instanceof GuiChat) && player.getCurrentItemOrArmor(3) != null)
|
||||
{
|
||||
if(player.getCurrentItemOrArmor(3) != null && player.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
ItemStack stack = player.getCurrentItemOrArmor(3);
|
||||
|
||||
ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
int x = scaledresolution.getScaledWidth();
|
||||
int y = scaledresolution.getScaledHeight();
|
||||
|
||||
if(stack.getItem() instanceof ItemJetpack)
|
||||
{
|
||||
ItemStack stack = player.getCurrentItemOrArmor(3);
|
||||
ItemJetpack jetpack = (ItemJetpack)stack.getItem();
|
||||
|
||||
ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
int x = scaledresolution.getScaledWidth();
|
||||
int y = scaledresolution.getScaledHeight();
|
||||
|
||||
font.drawStringWithShadow("Mode: " + jetpack.getMode(stack).getName(), 1, y - 20, 0x404040);
|
||||
font.drawStringWithShadow("Hydrogen: " + jetpack.getStored(stack), 1, y - 11, 0x404040);
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemScubaTank)
|
||||
{
|
||||
ItemScubaTank scubaTank = (ItemScubaTank)stack.getItem();
|
||||
String state = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" : EnumColor.DARK_RED + "Off");
|
||||
|
||||
font.drawStringWithShadow("Mode: " + state, 1, y - 20, 0x404040);
|
||||
font.drawStringWithShadow("Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040);
|
||||
}
|
||||
}
|
||||
|
||||
for(EntityPlayer p : Mekanism.jetpackOn)
|
||||
for(String s : Mekanism.jetpackOn)
|
||||
{
|
||||
if(p.getDistance(player.posX, player.posY, player.posZ) > 40)
|
||||
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);
|
||||
|
||||
if(p == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector3 playerPos = new Vector3(p);
|
||||
|
||||
if(p != mc.thePlayer)
|
||||
{
|
||||
playerPos.translate(new Vector3(0, 1.7, 0));
|
||||
}
|
||||
|
||||
float random = (rand.nextFloat()-0.5F)*0.1F;
|
||||
|
||||
Vector3 vLeft = new Vector3();
|
||||
|
@ -124,20 +148,40 @@ public class RenderTickHandler implements ITickHandler
|
|||
mLeft.translate(rLeft);
|
||||
mRight.translate(rRight);
|
||||
|
||||
Vector3 v = new Vector3(p).translate(vLeft);
|
||||
world.spawnParticle("flame", v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
|
||||
world.spawnParticle("smoke", v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
|
||||
Vector3 v = new Vector3(playerPos).translate(vLeft);
|
||||
spawnAndSetParticle("flame", world, v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
|
||||
spawnAndSetParticle("smoke", world, v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
|
||||
|
||||
v = new Vector3(p).translate(vRight);
|
||||
world.spawnParticle("flame", v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
|
||||
world.spawnParticle("smoke", v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
|
||||
v = new Vector3(playerPos).translate(vRight);
|
||||
spawnAndSetParticle("flame", world, v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
|
||||
spawnAndSetParticle("smoke", world, v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
|
||||
|
||||
v = new Vector3(p).translate(vCenter);
|
||||
world.spawnParticle("flame", v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z);
|
||||
world.spawnParticle("smoke", v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z);
|
||||
v = new Vector3(playerPos).translate(vCenter);
|
||||
spawnAndSetParticle("flame", world, v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z);
|
||||
spawnAndSetParticle("smoke", world, v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnAndSetParticle(String s, World world, double x, double y, double z, double velX, double velY, double velZ)
|
||||
{
|
||||
EntityFX fx = null;
|
||||
|
||||
if(s.equals("flame"))
|
||||
{
|
||||
fx = new EntityFlameFX(world, x, y, z, velX, velY, velZ);
|
||||
}
|
||||
else if(s.equals("smoke"))
|
||||
{
|
||||
fx = new EntitySmokeFX(world, x, y, z, velX, velY, velZ);
|
||||
}
|
||||
|
||||
fx.prevPosX = fx.posX = x;
|
||||
fx.prevPosY = fx.posY = y;
|
||||
fx.prevPosZ = fx.posZ = z;
|
||||
|
||||
mc.effectRenderer.addEffect(fx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
|
|
|
@ -86,7 +86,7 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
|
|||
{
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -1F, 0.05F);
|
||||
GL11.glTranslatef(0.0F, -1.06F, 0.05F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png"));
|
||||
rotaryCondensentrator.render(0.0625F);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
|||
toReturn.baseBlock = Block.stone;
|
||||
toReturn.setTexture(MekanismRenderer.getColorIcon(color));
|
||||
|
||||
DisplayInteger display = new DisplayInteger();
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
if(cachedOverlays.containsKey(side))
|
||||
{
|
||||
|
@ -118,9 +118,6 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
|||
cachedOverlays.put(side, map);
|
||||
}
|
||||
|
||||
display.display = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(display.display, 4864);
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case DOWN:
|
||||
|
@ -196,7 +193,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
GL11.glEndList();
|
||||
display.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class RenderDynamicTank extends TileEntitySpecialRenderer
|
||||
{
|
||||
private static Map<RenderData, HashMap<Fluid, int[]>> cachedCenterFluids = new HashMap<RenderData, HashMap<Fluid, int[]>>();
|
||||
private static Map<RenderData, HashMap<Fluid, DisplayInteger[]>> cachedCenterFluids = new HashMap<RenderData, HashMap<Fluid, DisplayInteger[]>>();
|
||||
private static Map<ValveRenderData, HashMap<Fluid, DisplayInteger>> cachedValveFluids = new HashMap<ValveRenderData, HashMap<Fluid, DisplayInteger>>();
|
||||
|
||||
@Override
|
||||
|
@ -57,15 +57,15 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
|
||||
|
||||
int[] displayList = getListAndRender(data, tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj);
|
||||
DisplayInteger[] displayList = getListAndRender(data, tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj);
|
||||
|
||||
if(tileEntity.structure.fluidStored.getFluid().isGaseous())
|
||||
{
|
||||
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.clientCapacity)+0.3F));
|
||||
GL11.glCallList(displayList[getStages(data.height)-1]);
|
||||
displayList[getStages(data.height)-1].render();
|
||||
}
|
||||
else {
|
||||
GL11.glCallList(displayList[(int)(((float)tileEntity.structure.fluidStored.amount/(float)tileEntity.clientCapacity)*((float)getStages(data.height)-1))]);
|
||||
displayList[(int)(((float)tileEntity.structure.fluidStored.amount/(float)tileEntity.clientCapacity)*((float)getStages(data.height)-1))].render();
|
||||
}
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
|
@ -82,8 +82,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
|
||||
|
||||
int display = getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj).display;
|
||||
GL11.glCallList(display);
|
||||
getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj).render();
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
|
||||
|
@ -110,7 +109,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
private int[] getListAndRender(RenderData data, Fluid fluid, World world)
|
||||
private DisplayInteger[] getListAndRender(RenderData data, Fluid fluid, World world)
|
||||
{
|
||||
if(cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid))
|
||||
{
|
||||
|
@ -122,14 +121,14 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
toReturn.setTexture(fluid.getIcon());
|
||||
|
||||
final int stages = getStages(data.height);
|
||||
int[] displays = new int[stages];
|
||||
DisplayInteger[] displays = new DisplayInteger[stages];
|
||||
|
||||
if(cachedCenterFluids.containsKey(data))
|
||||
{
|
||||
cachedCenterFluids.get(data).put(fluid, displays);
|
||||
}
|
||||
else {
|
||||
HashMap<Fluid, int[]> map = new HashMap<Fluid, int[]>();
|
||||
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
|
||||
map.put(fluid, displays);
|
||||
cachedCenterFluids.put(data, map);
|
||||
}
|
||||
|
@ -138,8 +137,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
displays[i] = DisplayInteger.createAndStart();
|
||||
|
||||
toReturn.minX = 0 + .01;
|
||||
toReturn.minY = 0 + .01;
|
||||
|
@ -169,7 +167,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.setTexture(fluid.getFlowingIcon());
|
||||
|
||||
DisplayInteger display = new DisplayInteger();
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
if(cachedValveFluids.containsKey(data))
|
||||
{
|
||||
|
@ -183,9 +181,6 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
MekanismRenderer.colorFluid(fluid);
|
||||
|
||||
display.display = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(display.display, 4864);
|
||||
|
||||
switch(data.side)
|
||||
{
|
||||
case DOWN:
|
||||
|
@ -261,7 +256,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
GL11.glEndList();
|
||||
display.endList();
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import mekanism.common.util.MekanismUtils.ResourceType;
|
|||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
|
@ -215,7 +214,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
|||
toReturn.baseBlock = Block.stone;
|
||||
toReturn.setTexture(icon);
|
||||
|
||||
DisplayInteger display = new DisplayInteger();
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
if(cachedOverlays.containsKey(side))
|
||||
{
|
||||
|
@ -227,9 +226,6 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
|||
cachedOverlays.put(side, map);
|
||||
}
|
||||
|
||||
display.display = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(display.display, 4864);
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case DOWN:
|
||||
|
@ -305,7 +301,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
GL11.glEndList();
|
||||
display.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger.endList();
|
||||
displays[i].endList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -300,7 +300,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger.endList();
|
||||
display.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
|
127
common/mekanism/client/render/tileentity/RenderTeleporter.java
Normal file
|
@ -0,0 +1,127 @@
|
|||
package mekanism.client.render.tileentity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.render.MekanismRenderer.Model3D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderTeleporter extends TileEntitySpecialRenderer
|
||||
{
|
||||
private HashMap<Integer, DisplayInteger> cachedOverlays = new HashMap<Integer, DisplayInteger>();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
renderAModelAt((TileEntityTeleporter)tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
if(tileEntity.shouldRender)
|
||||
{
|
||||
push();
|
||||
|
||||
GL11.glColor4f(EnumColor.PURPLE.getColor(0), EnumColor.PURPLE.getColor(1), EnumColor.PURPLE.getColor(2), 0.75F);
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
Object3D obj = Object3D.get(tileEntity).getFromSide(ForgeDirection.WEST);
|
||||
int type = 0;
|
||||
|
||||
if(obj.getBlockId(tileEntity.worldObj) == Mekanism.basicBlockID && obj.getMetadata(tileEntity.worldObj) == 7)
|
||||
{
|
||||
type = 1;
|
||||
}
|
||||
|
||||
int display = getOverlayDisplay(type).display;
|
||||
GL11.glCallList(display);
|
||||
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
||||
private void pop()
|
||||
{
|
||||
GL11.glPopAttrib();
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.blendOff();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void push()
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
MekanismRenderer.glowOn();
|
||||
MekanismRenderer.blendOn();
|
||||
}
|
||||
|
||||
private DisplayInteger getOverlayDisplay(Integer type)
|
||||
{
|
||||
if(cachedOverlays.containsKey(type))
|
||||
{
|
||||
return cachedOverlays.get(type);
|
||||
}
|
||||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Block.stone;
|
||||
toReturn.setTexture(GasRegistry.getGas("oxygen").getIcon());
|
||||
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
if(cachedOverlays.containsKey(type))
|
||||
{
|
||||
cachedOverlays.get(type);
|
||||
}
|
||||
else {
|
||||
cachedOverlays.put(type, display);
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
toReturn.minY = 1;
|
||||
toReturn.maxY = 3;
|
||||
|
||||
toReturn.minX = 0.46;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxX = 0.54;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
toReturn.minY = 1;
|
||||
toReturn.maxY = 3;
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minZ = 0.46;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxZ = 0.54;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
display.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
}
|
51
common/mekanism/client/sound/GasMaskSound.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import mekanism.client.ClientTickHandler;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GasMaskSound extends PlayerSound
|
||||
{
|
||||
public GasMaskSound(String id, EntityPlayer entity)
|
||||
{
|
||||
super(id, "GasMask.ogg", entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world)
|
||||
{
|
||||
if(!super.update(world))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(!hasGasMask(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(ClientTickHandler.isGasMaskOn(player) != isPlaying)
|
||||
{
|
||||
if(ClientTickHandler.isGasMaskOn(player))
|
||||
{
|
||||
play();
|
||||
}
|
||||
else {
|
||||
stopLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isPlaying)
|
||||
{
|
||||
ticksSincePlay++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasGasMask(EntityPlayer player)
|
||||
{
|
||||
return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask;
|
||||
}
|
||||
}
|
|
@ -1,54 +1,21 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import mekanism.client.ClientPlayerTickHandler;
|
||||
import mekanism.client.ClientTickHandler;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class JetpackSound extends Sound
|
||||
public class JetpackSound extends PlayerSound
|
||||
{
|
||||
/** The TileEntity this sound is associated with. */
|
||||
public EntityPlayer player;
|
||||
|
||||
public int ticksSincePlay = 0;
|
||||
|
||||
public JetpackSound(String id, String sound, EntityPlayer entity)
|
||||
public JetpackSound(String id, EntityPlayer entity)
|
||||
{
|
||||
super(id, sound, entity, new Vector3(entity));
|
||||
|
||||
player = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMultiplier()
|
||||
{
|
||||
return Math.min(1, ((float)ticksSincePlay/20F))*0.3F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getLocation()
|
||||
{
|
||||
return new Vector3(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play()
|
||||
{
|
||||
super.play();
|
||||
|
||||
ticksSincePlay = 0;
|
||||
super(id, "Jetpack.ogg", entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world)
|
||||
{
|
||||
if(player.isDead)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(!world.loadedEntityList.contains(player))
|
||||
if(!super.update(world))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -57,9 +24,9 @@ public class JetpackSound extends Sound
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
if(ClientPlayerTickHandler.isJetpackOn(player) != isPlaying)
|
||||
if(ClientTickHandler.isJetpackOn(player) != isPlaying)
|
||||
{
|
||||
if(ClientPlayerTickHandler.isJetpackOn(player))
|
||||
if(ClientTickHandler.isJetpackOn(player))
|
||||
{
|
||||
play();
|
||||
}
|
||||
|
|
59
common/mekanism/client/sound/PlayerSound.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public abstract class PlayerSound extends Sound
|
||||
{
|
||||
/** The TileEntity this sound is associated with. */
|
||||
public EntityPlayer player;
|
||||
|
||||
public int ticksSincePlay = 0;
|
||||
|
||||
public PlayerSound(String id, String sound, EntityPlayer entity)
|
||||
{
|
||||
super(id, sound, entity, new Vector3(entity));
|
||||
|
||||
player = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMultiplier()
|
||||
{
|
||||
return Math.min(1, ((float)ticksSincePlay/20F))*0.3F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world)
|
||||
{
|
||||
if(player.isDead)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(player.worldObj != world)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(!world.loadedEntityList.contains(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getLocation()
|
||||
{
|
||||
return new Vector3(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play()
|
||||
{
|
||||
super.play();
|
||||
|
||||
ticksSincePlay = 0;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ public abstract class Sound
|
|||
|
||||
private Object objRef;
|
||||
|
||||
protected Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/**
|
||||
* A sound that runs off of the PaulsCode sound system.
|
||||
* @param id - unique identifier
|
||||
|
@ -29,6 +31,11 @@ public abstract class Sound
|
|||
*/
|
||||
public Sound(String id, String sound, Object obj, Vector3 loc)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(obj) != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized(MekanismClient.audioHandler.sounds)
|
||||
{
|
||||
soundPath = sound;
|
||||
|
@ -45,7 +52,7 @@ public abstract class Sound
|
|||
if(SoundHandler.getSoundSystem() != null)
|
||||
{
|
||||
SoundHandler.getSoundSystem().newSource(false, id, url, sound, true, (float)loc.x, (float)loc.y, (float)loc.z, 0, 16F);
|
||||
updateVolume(Minecraft.getMinecraft().thePlayer);
|
||||
updateVolume();
|
||||
SoundHandler.getSoundSystem().activate(id);
|
||||
}
|
||||
|
||||
|
@ -67,7 +74,7 @@ public abstract class Sound
|
|||
|
||||
if(SoundHandler.getSoundSystem() != null)
|
||||
{
|
||||
updateVolume(Minecraft.getMinecraft().thePlayer);
|
||||
updateVolume();
|
||||
SoundHandler.getSoundSystem().play(identifier);
|
||||
}
|
||||
|
||||
|
@ -89,7 +96,7 @@ public abstract class Sound
|
|||
|
||||
if(SoundHandler.getSoundSystem() != null)
|
||||
{
|
||||
updateVolume(Minecraft.getMinecraft().thePlayer);
|
||||
updateVolume();
|
||||
SoundHandler.getSoundSystem().stop(identifier);
|
||||
}
|
||||
|
||||
|
@ -113,7 +120,7 @@ public abstract class Sound
|
|||
|
||||
if(SoundHandler.getSoundSystem() != null)
|
||||
{
|
||||
updateVolume(Minecraft.getMinecraft().thePlayer);
|
||||
updateVolume();
|
||||
SoundHandler.getSoundSystem().removeSource(identifier);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +136,7 @@ public abstract class Sound
|
|||
* Updates the volume based on how far away the player is from the machine.
|
||||
* @param entityplayer - player who is near the machine, always Minecraft.thePlayer
|
||||
*/
|
||||
public void updateVolume(EntityPlayer entityplayer)
|
||||
public void updateVolume()
|
||||
{
|
||||
synchronized(MekanismClient.audioHandler.sounds)
|
||||
{
|
||||
|
@ -138,8 +145,9 @@ public abstract class Sound
|
|||
float volume = 0;
|
||||
float masterVolume = MekanismClient.audioHandler.masterVolume;
|
||||
|
||||
double distance = entityplayer.getDistance(getLocation().x, getLocation().y, getLocation().z);
|
||||
double distance = mc.thePlayer.getDistance(getLocation().x, getLocation().y, getLocation().z);
|
||||
volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1);
|
||||
volume *= Math.max(0, Math.min(1, MekanismClient.baseSoundVolume));
|
||||
|
||||
if(SoundHandler.getSoundSystem() != null)
|
||||
{
|
||||
|
|
|
@ -193,7 +193,7 @@ public class SoundHandler
|
|||
{
|
||||
if(sound.isPlaying)
|
||||
{
|
||||
sound.updateVolume(FMLClientHandler.instance().getClient().thePlayer);
|
||||
sound.updateVolume();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,10 +248,6 @@ public class SoundHandler
|
|||
{
|
||||
new TileSound(getIdentifier(), ((IHasSound)obj).getSoundPath(), (TileEntity)obj);
|
||||
}
|
||||
else if(obj instanceof EntityPlayer)
|
||||
{
|
||||
new JetpackSound(getIdentifier(), "Jetpack.ogg", (EntityPlayer)obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
38
common/mekanism/common/ChemicalInput.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package mekanism.common;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.gas.Gas;
|
||||
|
||||
public class ChemicalInput
|
||||
{
|
||||
public Gas leftGas;
|
||||
public Gas rightGas;
|
||||
|
||||
public ChemicalInput(Gas left, Gas right)
|
||||
{
|
||||
leftGas = left;
|
||||
rightGas = right;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return leftGas != null && rightGas != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof ChemicalInput &&
|
||||
((ChemicalInput)obj).leftGas == leftGas &&
|
||||
((ChemicalInput)obj).rightGas == rightGas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + leftGas.getID();
|
||||
code = 31 * code + rightGas.getID();
|
||||
return code;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,10 @@ import java.util.EnumSet;
|
|||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.network.PacketStatusUpdate;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -123,6 +125,15 @@ public class CommonPlayerTickHandler implements ITickHandler
|
|||
|
||||
jetpack.useGas(player.getCurrentItemOrArmor(3));
|
||||
}
|
||||
|
||||
if(isGasMaskOn(player))
|
||||
{
|
||||
ItemScubaTank tank = (ItemScubaTank)player.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
tank.useGas(player.getCurrentItemOrArmor(3));
|
||||
player.setAir(300);
|
||||
player.clearActivePotions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,6 +163,30 @@ public class CommonPlayerTickHandler implements ITickHandler
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGasMaskOn(EntityPlayer player)
|
||||
{
|
||||
ItemStack tank = player.inventory.armorInventory[2];
|
||||
ItemStack mask = player.inventory.armorInventory[3];
|
||||
|
||||
if(tank != null && mask != null)
|
||||
{
|
||||
if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask)
|
||||
{
|
||||
ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem();
|
||||
|
||||
if(scubaTank.getGas(tank) != null)
|
||||
{
|
||||
if(scubaTank.getFlowing(tank))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
|
|
|
@ -1,20 +1,47 @@
|
|||
package mekanism.common;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
||||
import mekanism.common.network.PacketScubaTankData;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
|
||||
public class CommonPlayerTracker implements IPlayerTracker
|
||||
{
|
||||
@Override
|
||||
public void onPlayerLogin(EntityPlayer player) {}
|
||||
public void onPlayerLogin(EntityPlayer player)
|
||||
{
|
||||
if(!player.worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout(EntityPlayer player)
|
||||
{
|
||||
Mekanism.jetpackOn.remove(player);
|
||||
|
||||
if(!player.worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension(EntityPlayer player) {}
|
||||
public void onPlayerChangedDimension(EntityPlayer player)
|
||||
{
|
||||
Mekanism.jetpackOn.remove(player);
|
||||
|
||||
if(!player.worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(EntityPlayer player) {}
|
||||
|
|
|
@ -3,6 +3,9 @@ package mekanism.common;
|
|||
import java.io.File;
|
||||
|
||||
import mekanism.common.inventory.container.ContainerAdvancedElectricMachine;
|
||||
import mekanism.common.inventory.container.ContainerChemicalFormulator;
|
||||
import mekanism.common.inventory.container.ContainerChemicalInfuser;
|
||||
import mekanism.common.inventory.container.ContainerDictionary;
|
||||
import mekanism.common.inventory.container.ContainerDigitalMiner;
|
||||
import mekanism.common.inventory.container.ContainerDynamicTank;
|
||||
import mekanism.common.inventory.container.ContainerElectricMachine;
|
||||
|
@ -24,6 +27,8 @@ import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
|
|||
import mekanism.common.tileentity.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tileentity.TileEntityBin;
|
||||
import mekanism.common.tileentity.TileEntityChargepad;
|
||||
import mekanism.common.tileentity.TileEntityChemicalFormulator;
|
||||
import mekanism.common.tileentity.TileEntityChemicalInfuser;
|
||||
import mekanism.common.tileentity.TileEntityCombiner;
|
||||
import mekanism.common.tileentity.TileEntityContainerBlock;
|
||||
import mekanism.common.tileentity.TileEntityCrusher;
|
||||
|
@ -100,6 +105,9 @@ public class CommonProxy
|
|||
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner");
|
||||
GameRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT");
|
||||
GameRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator");
|
||||
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
|
||||
GameRegistry.registerTileEntity(TileEntityChemicalFormulator.class, "ChemicalFormulator");
|
||||
GameRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,6 +270,8 @@ public class CommonProxy
|
|||
|
||||
switch(ID)
|
||||
{
|
||||
case 0:
|
||||
return new ContainerDictionary(player.inventory);
|
||||
case 2:
|
||||
return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity);
|
||||
case 3:
|
||||
|
@ -296,6 +306,7 @@ public class CommonProxy
|
|||
return new ContainerDynamicTank(player.inventory, (TileEntityDynamicTank)tileEntity);
|
||||
case 21:
|
||||
EntityRobit robit = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit != null)
|
||||
{
|
||||
return new ContainerRobitMain(player.inventory, robit);
|
||||
|
@ -304,12 +315,14 @@ public class CommonProxy
|
|||
return new ContainerRobitCrafting(player.inventory, world);
|
||||
case 23:
|
||||
EntityRobit robit1 = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit1 != null)
|
||||
{
|
||||
return new ContainerRobitInventory(player.inventory, robit1);
|
||||
}
|
||||
case 24:
|
||||
EntityRobit robit2 = (EntityRobit)world.getEntityByID(x);
|
||||
|
||||
if(robit2 != null)
|
||||
{
|
||||
return new ContainerRobitSmelting(player.inventory, robit2);
|
||||
|
@ -322,6 +335,10 @@ public class CommonProxy
|
|||
return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity);
|
||||
case 28:
|
||||
return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity);
|
||||
case 29:
|
||||
return new ContainerChemicalFormulator(player.inventory, (TileEntityChemicalFormulator)tileEntity);
|
||||
case 30:
|
||||
return new ContainerChemicalInfuser(player.inventory, (TileEntityChemicalInfuser)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -85,6 +85,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
for(TileEntity acceptor : getAcceptors())
|
||||
{
|
||||
if(acceptorDirections.get(acceptor) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ForgeDirection side = acceptorDirections.get(acceptor).getOpposite();
|
||||
|
||||
if(!ignored.contains(acceptor))
|
||||
|
@ -264,11 +269,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
if(handler.canInterface(side.getOpposite()))
|
||||
{
|
||||
if(handler.receiveEnergy(side.getOpposite(), 1, true) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
}
|
||||
else if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0)
|
||||
if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
}
|
||||
|
|
|
@ -48,10 +48,12 @@ import mekanism.common.item.ItemBlockOre;
|
|||
import mekanism.common.item.ItemBlockTransmitter;
|
||||
import mekanism.common.item.ItemClump;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemDictionary;
|
||||
import mekanism.common.item.ItemDirtyDust;
|
||||
import mekanism.common.item.ItemDust;
|
||||
import mekanism.common.item.ItemElectricBow;
|
||||
import mekanism.common.item.ItemEnergized;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemIngot;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemMachineUpgrade;
|
||||
|
@ -60,9 +62,9 @@ import mekanism.common.item.ItemNetworkReader;
|
|||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemProxy;
|
||||
import mekanism.common.item.ItemRobit;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.multipart.ItemPartTransmitter;
|
||||
import mekanism.common.multipart.MultipartMekanism;
|
||||
import mekanism.common.network.PacketConfigurationUpdate;
|
||||
import mekanism.common.network.PacketConfiguratorState;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
|
@ -71,6 +73,8 @@ import mekanism.common.network.PacketDigitalMinerGui;
|
|||
import mekanism.common.network.PacketEditFilter;
|
||||
import mekanism.common.network.PacketElectricBowState;
|
||||
import mekanism.common.network.PacketElectricChest;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketKey;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui;
|
||||
import mekanism.common.network.PacketNewFilter;
|
||||
import mekanism.common.network.PacketPortableTeleport;
|
||||
|
@ -78,6 +82,7 @@ import mekanism.common.network.PacketPortalFX;
|
|||
import mekanism.common.network.PacketRedstoneControl;
|
||||
import mekanism.common.network.PacketRemoveUpgrade;
|
||||
import mekanism.common.network.PacketRobit;
|
||||
import mekanism.common.network.PacketScubaTankData;
|
||||
import mekanism.common.network.PacketSimpleGui;
|
||||
import mekanism.common.network.PacketStatusUpdate;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
|
@ -87,13 +92,11 @@ import mekanism.common.network.PacketWalkieTalkieState;
|
|||
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
|
||||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.common.voice.VoiceServerManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
|
@ -178,10 +181,11 @@ public class Mekanism
|
|||
|
||||
/** A list of the usernames of players who have donated to Mekanism. */
|
||||
public static List<String> donators = new ArrayList<String>();
|
||||
|
||||
|
||||
public static KeySync keyMap = new KeySync();
|
||||
|
||||
public static Set<EntityPlayer> jetpackOn = new HashSet<EntityPlayer>();
|
||||
|
||||
public static Set<String> jetpackOn = new HashSet<String>();
|
||||
public static Set<String> gasmaskOn = new HashSet<String>();
|
||||
|
||||
public static Set<Object3D> ic2Registered = new HashSet<Object3D>();
|
||||
|
||||
|
@ -215,7 +219,10 @@ public class Mekanism
|
|||
public static Item WalkieTalkie;
|
||||
public static Item ItemProxy;
|
||||
public static Item PartTransmitter;
|
||||
public static Item Jetpack;
|
||||
public static ItemJetpack Jetpack;
|
||||
public static ItemScubaTank ScubaTank;
|
||||
public static ItemGasMask GasMask;
|
||||
public static Item Dictionary;
|
||||
|
||||
//Blocks
|
||||
public static Block BasicBlock;
|
||||
|
@ -277,6 +284,8 @@ public class Mekanism
|
|||
public static double energizedSmelterUsage;
|
||||
public static double digitalMinerUsage;
|
||||
public static double rotaryCondensentratorUsage;
|
||||
public static double chemicalFormulatorUsage;
|
||||
public static double chemicalInfuserUsage;
|
||||
|
||||
/**
|
||||
* Adds all in-game crafting and smelting recipes.
|
||||
|
@ -471,6 +480,12 @@ public class Mekanism
|
|||
"GCG", "tET", "GIG", Character.valueOf('G'), Block.glass, Character.valueOf('C'), "circuitBasic", Character.valueOf('t'), MekanismUtils.getEmptyGasTank(), Character.valueOf('E'), EnergyTablet.getUnchargedItem(),
|
||||
Character.valueOf('T'), new ItemStack(BasicBlock, 1, 9), Character.valueOf('I'), new ItemStack(BasicBlock, 1, 8)
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Jetpack.getEmptyItem(), new Object[] {
|
||||
"SCS", "TGT", " T ", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), "ingotTin", Character.valueOf('G'), MekanismUtils.getEmptyGasTank()
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Dictionary), new Object[] {
|
||||
"C", "B", Character.valueOf('C'), "circuitBasic", Character.valueOf('B'), Item.book
|
||||
}));
|
||||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
|
@ -486,29 +501,31 @@ public class Mekanism
|
|||
}
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new BinRecipe());
|
||||
|
||||
//Transmitters
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 0), new Object[] {
|
||||
"SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), Item.redstone
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 1), new Object[] {
|
||||
"SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Item.bucketEmpty
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 2), new Object[] {
|
||||
"SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), Block.glass
|
||||
}));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 0), new ItemStack(Transmitter, 1, 1));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 1), new ItemStack(Transmitter, 1, 2));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 2), new ItemStack(Transmitter, 1, 0));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 3), new ItemStack(Transmitter, 1, 3));
|
||||
if(allowBackCrafting)
|
||||
{
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 1), new ItemStack(PartTransmitter, 1, 0));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 2), new ItemStack(PartTransmitter, 1, 1));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 0), new ItemStack(PartTransmitter, 1, 2));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 3), new ItemStack(PartTransmitter, 1, 3));
|
||||
}
|
||||
|
||||
//Transmitters
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 0), new Object[] {
|
||||
"SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), Item.redstone
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 1), new Object[] {
|
||||
"SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Item.bucketEmpty
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 2), new Object[] {
|
||||
"SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), Block.glass
|
||||
}));
|
||||
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 0), new ItemStack(Transmitter, 1, 1));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 1), new ItemStack(Transmitter, 1, 2));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 2), new ItemStack(Transmitter, 1, 0));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 3), new ItemStack(Transmitter, 1, 3));
|
||||
|
||||
if(allowBackCrafting)
|
||||
{
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 1), new ItemStack(PartTransmitter, 1, 0));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 2), new ItemStack(PartTransmitter, 1, 1));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 0), new ItemStack(PartTransmitter, 1, 2));
|
||||
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(Transmitter, 1, 3), new ItemStack(PartTransmitter, 1, 3));
|
||||
}
|
||||
|
||||
//Furnace Recipes
|
||||
FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F);
|
||||
FurnaceRecipes.smelting().addSmelting(oreBlockID, 1, new ItemStack(Ingot, 1, 5), 1.0F);
|
||||
|
@ -537,6 +554,7 @@ public class Mekanism
|
|||
//Combiner recipes
|
||||
RecipeHandler.addCombinerRecipe(new ItemStack(Item.redstone, 16), new ItemStack(Block.oreRedstone));
|
||||
RecipeHandler.addCombinerRecipe(new ItemStack(Item.dyePowder, 16, 4), new ItemStack(Block.oreLapis));
|
||||
RecipeHandler.addCombinerRecipe(new ItemStack(Item.flint), new ItemStack(Block.gravel));
|
||||
|
||||
//Osmium Compressor Recipes
|
||||
RecipeHandler.addOsmiumCompressorRecipe(new ItemStack(Item.glowstone), new ItemStack(Ingot, 1, 3));
|
||||
|
@ -551,9 +569,11 @@ public class Mekanism
|
|||
RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stone));
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2));
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 3), new ItemStack(Block.stoneBrick, 1, 0));
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Item.flint, 4), new ItemStack(Item.gunpowder));
|
||||
|
||||
//Purification Chamber Recipes
|
||||
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(Clump, 2, 6));
|
||||
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.cobblestone), new ItemStack(Block.gravel));
|
||||
|
||||
//Metallurgic Infuser Recipes
|
||||
RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedIron));
|
||||
|
@ -580,15 +600,16 @@ public class Mekanism
|
|||
{
|
||||
//Declarations
|
||||
configuration.load();
|
||||
ElectricBow = (ItemElectricBow) new ItemElectricBow(configuration.getItem("ElectricBow", 11200).getInt()).setUnlocalizedName("ElectricBow");
|
||||
//OPEN 11201-11203
|
||||
ElectricBow = (ItemElectricBow)new ItemElectricBow(configuration.getItem("ElectricBow", 11200).getInt()).setUnlocalizedName("ElectricBow");
|
||||
Dictionary = new ItemDictionary(configuration.getItem("Dictionary", 11201).getInt()).setUnlocalizedName("Dictionary");
|
||||
//OPEN 11202-11203
|
||||
Dust = new ItemDust(configuration.getItem("Dust", 11204).getInt()-256);
|
||||
Ingot = new ItemIngot(configuration.getItem("Ingot", 11205).getInt()-256);
|
||||
EnergyTablet = (ItemEnergized) new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet");
|
||||
EnergyTablet = (ItemEnergized)new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet");
|
||||
SpeedUpgrade = new ItemMachineUpgrade(configuration.getItem("SpeedUpgrade", 11207).getInt()).setUnlocalizedName("SpeedUpgrade");
|
||||
EnergyUpgrade = new ItemMachineUpgrade(configuration.getItem("EnergyUpgrade", 11208).getInt()).setUnlocalizedName("EnergyUpgrade");
|
||||
Robit = (ItemRobit) new ItemRobit(configuration.getItem("Robit", 11209).getInt()).setUnlocalizedName("Robit");
|
||||
AtomicDisassembler = (ItemAtomicDisassembler) new ItemAtomicDisassembler(configuration.getItem("AtomicDisassembler", 11210).getInt()).setUnlocalizedName("AtomicDisassembler");
|
||||
Robit = (ItemRobit)new ItemRobit(configuration.getItem("Robit", 11209).getInt()).setUnlocalizedName("Robit");
|
||||
AtomicDisassembler = (ItemAtomicDisassembler)new ItemAtomicDisassembler(configuration.getItem("AtomicDisassembler", 11210).getInt()).setUnlocalizedName("AtomicDisassembler");
|
||||
AtomicCore = new ItemMekanism(configuration.getItem("AtomicCore", 11211).getInt()).setUnlocalizedName("AtomicCore");
|
||||
EnrichedAlloy = new ItemMekanism(configuration.getItem("EnrichedAlloy", 11212).getInt()).setUnlocalizedName("EnrichedAlloy");
|
||||
ItemProxy = new ItemProxy(configuration.getItem("ItemProxy", 11213).getInt()).setUnlocalizedName("ItemProxy");
|
||||
|
@ -601,10 +622,11 @@ public class Mekanism
|
|||
DirtyDust = new ItemDirtyDust(configuration.getItem("DirtyDust", 11220).getInt()-256);
|
||||
Configurator = new ItemConfigurator(configuration.getItem("Configurator", 11221).getInt()).setUnlocalizedName("Configurator");
|
||||
NetworkReader = new ItemNetworkReader(configuration.getItem("NetworkReader", 11222).getInt()).setUnlocalizedName("NetworkReader");
|
||||
Jetpack = new ItemJetpack(configuration.getItem("Jetpack", 11223).getInt()).setUnlocalizedName("Jetpack");
|
||||
Jetpack = (ItemJetpack)new ItemJetpack(configuration.getItem("Jetpack", 11223).getInt()).setUnlocalizedName("Jetpack");
|
||||
WalkieTalkie = new ItemWalkieTalkie(configuration.getItem("WalkieTalkie", 11224).getInt()).setUnlocalizedName("WalkieTalkie");
|
||||
PartTransmitter = new ItemPartTransmitter(configuration.getItem("MultipartTransmitter", 11223).getInt()).setUnlocalizedName("MultipartTransmitter");
|
||||
configuration.save();
|
||||
//TODO 1.7, fix item shifts
|
||||
|
||||
//Registrations
|
||||
GameRegistry.registerItem(ElectricBow, "ElectricBow");
|
||||
|
@ -629,6 +651,7 @@ public class Mekanism
|
|||
GameRegistry.registerItem(NetworkReader, "NetworkReader");
|
||||
GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie");
|
||||
GameRegistry.registerItem(Jetpack, "Jetpack");
|
||||
GameRegistry.registerItem(Dictionary, "Dictionary");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -679,6 +702,7 @@ public class Mekanism
|
|||
OreDictionary.registerOre("dustCopper", new ItemStack(Dust, 1, 6));
|
||||
OreDictionary.registerOre("dustTin", new ItemStack(Dust, 1, 7));
|
||||
OreDictionary.registerOre("dustSilver", new ItemStack(Dust, 1, 8));
|
||||
OreDictionary.registerOre("dustLead", new ItemStack(Dust, 1, 9));
|
||||
|
||||
OreDictionary.registerOre("ingotRefinedObsidian", new ItemStack(Ingot, 1, 0));
|
||||
OreDictionary.registerOre("ingotOsmium", new ItemStack(Ingot, 1, 1));
|
||||
|
@ -704,6 +728,7 @@ public class Mekanism
|
|||
OreDictionary.registerOre("dustDirtyTin", new ItemStack(DirtyDust, 1, 4));
|
||||
OreDictionary.registerOre("dustDirtySilver", new ItemStack(DirtyDust, 1, 5));
|
||||
OreDictionary.registerOre("dustDirtyObsidian", new ItemStack(DirtyDust, 1, 6));
|
||||
OreDictionary.registerOre("dustDirtyLead", new ItemStack(DirtyDust, 1, 7));
|
||||
|
||||
//for RailCraft/IC2.
|
||||
OreDictionary.registerOre("dustObsidian", new ItemStack(DirtyDust, 1, 6));
|
||||
|
@ -715,10 +740,16 @@ public class Mekanism
|
|||
OreDictionary.registerOre("clumpTin", new ItemStack(Clump, 1, 4));
|
||||
OreDictionary.registerOre("clumpSilver", new ItemStack(Clump, 1, 5));
|
||||
OreDictionary.registerOre("clumpObsidian", new ItemStack(Clump, 1, 6));
|
||||
OreDictionary.registerOre("clumpLead", new ItemStack(Clump, 1, 7));
|
||||
|
||||
OreDictionary.registerOre("oreOsmium", new ItemStack(OreBlock, 1, 0));
|
||||
OreDictionary.registerOre("oreCopper", new ItemStack(OreBlock, 1, 1));
|
||||
OreDictionary.registerOre("oreTin", new ItemStack(OreBlock, 1, 2));
|
||||
|
||||
//MC stuff
|
||||
OreDictionary.registerOre("oreCoal", new ItemStack(Block.oreCoal));
|
||||
OreDictionary.registerOre("ingotIron", new ItemStack(Item.ingotIron));
|
||||
OreDictionary.registerOre("ingotGold", new ItemStack(Item.ingotGold));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -726,7 +757,7 @@ public class Mekanism
|
|||
* and adding machine recipes with other items' corresponding resources.
|
||||
*/
|
||||
public void addIntegratedItems()
|
||||
{
|
||||
{
|
||||
try {
|
||||
CraftingManagers.pulverizerManager.addRecipe(400, new ItemStack(OreBlock, 1, 0), new ItemStack(Dust, 2, 2), false);
|
||||
|
||||
|
@ -794,6 +825,11 @@ public class Mekanism
|
|||
RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(DirtyDust, 1, 6));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("clumpLead"))
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(DirtyDust, 1, 7));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("dustDirtyIron"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 1, 0));
|
||||
|
@ -824,6 +860,11 @@ public class Mekanism
|
|||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 1, 8));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("dustDirtyLead"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 1, 9));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("oreCopper"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 2, 6));
|
||||
|
@ -854,15 +895,22 @@ public class Mekanism
|
|||
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Clump, 3, 1));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("oreGold"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Dust, 2, 1));
|
||||
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Clump, 3, 1));
|
||||
}
|
||||
|
||||
try {
|
||||
for(ItemStack ore : OreDictionary.getOres("oreLead"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), MekanismUtils.size(OreDictionary.getOres("dustLead").get(0), 2));
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 2, 9));
|
||||
RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Clump, 3, 7));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("ingotLead"))
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), MekanismUtils.size(OreDictionary.getOres("dustLead").get(0), 1));
|
||||
RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Dust, 1, 9));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
@ -913,15 +961,11 @@ public class Mekanism
|
|||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 6, new ItemStack(Ingot, 1, 5), 0.0F);
|
||||
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 8, MekanismUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 0.0F);
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 7, new ItemStack(Ingot, 1, 6), 0.0F);
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 8, MekanismUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 1.0F);
|
||||
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 9, MekanismUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), 0.0F);
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
|
@ -968,6 +1012,11 @@ public class Mekanism
|
|||
RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Block.oreGold));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("dustLapisLazuli"))
|
||||
{
|
||||
RecipeHandler.addCrusherRecipe(new ItemStack(Item.dyePowder, 1, 4), MekanismUtils.size(ore, 1));
|
||||
}
|
||||
|
||||
for(ItemStack ore : OreDictionary.getOres("dustObsidian"))
|
||||
{
|
||||
RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 2), new ItemStack(Block.obsidian));
|
||||
|
@ -1095,7 +1144,6 @@ public class Mekanism
|
|||
//Tile entities
|
||||
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
|
||||
|
||||
//Load tile entities that have special renderers.
|
||||
proxy.registerSpecialTileEntities();
|
||||
|
@ -1123,6 +1171,9 @@ public class Mekanism
|
|||
teleporters.clear();
|
||||
dynamicInventories.clear();
|
||||
ic2Registered.clear();
|
||||
jetpackOn.clear();
|
||||
gasmaskOn.clear();
|
||||
|
||||
TransporterManager.flowingStacks.clear();
|
||||
}
|
||||
|
||||
|
@ -1156,8 +1207,6 @@ public class Mekanism
|
|||
InfuseRegistry.registerInfuseType(new InfuseType("TIN", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 4, 0));
|
||||
InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 8, 0));
|
||||
InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 16, 0));
|
||||
|
||||
new MultipartMekanism().init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1166,6 +1215,9 @@ public class Mekanism
|
|||
//Register the mod's ore handler
|
||||
GameRegistry.registerWorldGenerator(new OreHandler());
|
||||
|
||||
//Register player tracker
|
||||
GameRegistry.registerPlayerTracker(new CommonPlayerTracker());
|
||||
|
||||
//Register the mod's GUI handler
|
||||
NetworkRegistry.instance().registerGuiHandler(this, new CoreGuiHandler());
|
||||
|
||||
|
@ -1178,8 +1230,6 @@ public class Mekanism
|
|||
//Register to receive subscribed events
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
new MultipartMekanism();
|
||||
|
||||
//Set up VoiceServerManager
|
||||
if(voiceServerEnabled)
|
||||
{
|
||||
|
@ -1221,6 +1271,9 @@ public class Mekanism
|
|||
PacketHandler.registerPacket(PacketConfigurationUpdate.class);
|
||||
PacketHandler.registerPacket(PacketSimpleGui.class);
|
||||
PacketHandler.registerPacket(PacketDigitalMinerGui.class);
|
||||
PacketHandler.registerPacket(PacketJetpackData.class);
|
||||
PacketHandler.registerPacket(PacketKey.class);
|
||||
PacketHandler.registerPacket(PacketScubaTankData.class);
|
||||
|
||||
//Donators
|
||||
donators.add("mrgreaper");
|
||||
|
|
|
@ -3,6 +3,7 @@ package mekanism.common;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.infuse.InfusionInput;
|
||||
import mekanism.api.infuse.InfusionOutput;
|
||||
import mekanism.common.util.StackUtils;
|
||||
|
@ -80,18 +81,39 @@ public final class RecipeHandler
|
|||
Recipe.METALLURGIC_INFUSER.put(input, InfusionOutput.getInfusion(input, output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Chemical Infuser recipe.
|
||||
* @param input - input ChemicalInput
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
public static void addChemicalInfuserRecipe(ChemicalInput input, GasStack output)
|
||||
{
|
||||
Recipe.CHEMICAL_INFUSER.put(input, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Chemical Formulator recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
public static void addChemicalFormulatorRecipe(ItemStack input, GasStack output)
|
||||
{
|
||||
Recipe.CHEMICAL_FORMULATOR.put(input, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InfusionOutput of the InfusionInput in the parameters.
|
||||
* @param infusion - input Infusion
|
||||
* @param stackDecrease - whether or not to decrease the input slot's stack size AND the infuse amount
|
||||
* @param recipes - Map of recipes
|
||||
* @return InfusionOutput
|
||||
*/
|
||||
public static InfusionOutput getOutput(InfusionInput infusion, boolean stackDecrease, Map<InfusionInput, InfusionOutput> recipes)
|
||||
{
|
||||
public static InfusionOutput getMetallurgicInfuserOutput(InfusionInput infusion, boolean stackDecrease)
|
||||
{
|
||||
if(infusion != null && infusion.inputStack != null)
|
||||
{
|
||||
for(Map.Entry entry : recipes.entrySet())
|
||||
HashMap<InfusionInput, InfusionOutput> recipes = Recipe.METALLURGIC_INFUSER.get();
|
||||
|
||||
for(Map.Entry<InfusionInput, InfusionOutput> entry : recipes.entrySet())
|
||||
{
|
||||
InfusionInput input = (InfusionInput)entry.getKey();
|
||||
|
||||
|
@ -113,6 +135,53 @@ public final class RecipeHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GasStack of the ChemicalInput in the parameters.
|
||||
* @param input - input ChemicalInput
|
||||
* @return GasStack
|
||||
*/
|
||||
public static GasStack getChemicalInfuserOutput(ChemicalInput input)
|
||||
{
|
||||
if(input != null && input.isValid())
|
||||
{
|
||||
HashMap<ChemicalInput, GasStack> recipes = Recipe.CHEMICAL_INFUSER.get();
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InfusionOutput of the ItemStack in the parameters.
|
||||
* @param itemstack - input ItemStack
|
||||
* @param stackDecrease - whether or not to decrease the input slot's stack size
|
||||
* @return GasStack
|
||||
*/
|
||||
public static GasStack getChemicalFormulatorOutput(ItemStack itemstack, boolean stackDecrease)
|
||||
{
|
||||
if(itemstack != null)
|
||||
{
|
||||
HashMap<ItemStack, GasStack> recipes = Recipe.CHEMICAL_FORMULATOR.get();
|
||||
|
||||
for(Map.Entry<ItemStack, GasStack> entry : recipes.entrySet())
|
||||
{
|
||||
ItemStack stack = (ItemStack)entry.getKey();
|
||||
|
||||
if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize)
|
||||
{
|
||||
if(stackDecrease)
|
||||
{
|
||||
itemstack.stackSize -= stack.stackSize;
|
||||
}
|
||||
|
||||
return entry.getValue().copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output ItemStack of the ItemStack in the parameters.
|
||||
* @param itemstack - input ItemStack
|
||||
|
@ -150,7 +219,9 @@ public final class RecipeHandler
|
|||
COMBINER(new HashMap<ItemStack, ItemStack>()),
|
||||
CRUSHER(new HashMap<ItemStack, ItemStack>()),
|
||||
PURIFICATION_CHAMBER(new HashMap<ItemStack, ItemStack>()),
|
||||
METALLURGIC_INFUSER(new HashMap<InfusionInput, InfusionOutput>());
|
||||
METALLURGIC_INFUSER(new HashMap<InfusionInput, InfusionOutput>()),
|
||||
CHEMICAL_INFUSER(new HashMap<ChemicalInput, GasStack>()),
|
||||
CHEMICAL_FORMULATOR(new HashMap<ItemStack, GasStack>());
|
||||
|
||||
private HashMap recipes;
|
||||
|
||||
|
|
|
@ -156,6 +156,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
int height = Math.round(entityliving.rotationPitch);
|
||||
int change = 3;
|
||||
|
||||
if(tileEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1))
|
||||
{
|
||||
if(height >= 65)
|
||||
|
@ -242,23 +247,23 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
|
||||
if(side == 4)
|
||||
{
|
||||
world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("smoke", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if(side == 5)
|
||||
{
|
||||
world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("smoke", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if(side == 2)
|
||||
{
|
||||
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if(side == 3)
|
||||
{
|
||||
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -622,23 +627,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
if(metadata == MachineType.TELEPORTER.meta)
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
entityplayer.openGui(Mekanism.instance, 13, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntityTeleporter teleporter = (TileEntityTeleporter)tileEntity;
|
||||
|
||||
if(teleporter.canTeleport() == 1)
|
||||
{
|
||||
teleporter.teleport();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(metadata == MachineType.ELECTRIC_CHEST.meta)
|
||||
if(metadata == MachineType.ELECTRIC_CHEST.meta)
|
||||
{
|
||||
TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity;
|
||||
|
||||
|
@ -782,7 +771,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
{
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z));
|
||||
|
||||
|
||||
if(((IUpgradeManagement)itemStack.getItem()).supportsUpgrades(itemStack))
|
||||
{
|
||||
IUpgradeManagement upgrade = (IUpgradeManagement)itemStack.getItem();
|
||||
|
@ -1069,6 +1058,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
}
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return MekanismUtils.localize("tooltip." + name);
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return new ItemStack(typeId, 1, meta);
|
||||
|
|
115
common/mekanism/common/classloading/ClassEnumerator.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
package mekanism.common.classloading;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class ClassEnumerator
|
||||
{
|
||||
private static Class<?> loadClass(String className)
|
||||
{
|
||||
try {
|
||||
return Class.forName(className);
|
||||
} catch(ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unexpected ClassNotFoundException loading class '" + className + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private static void processDir(File directory, String pkgname, ArrayList<Class<?>> classes)
|
||||
{
|
||||
String[] files = directory.list();
|
||||
|
||||
for(int i = 0; i < files.length; i++)
|
||||
{
|
||||
String fileName = files[i];
|
||||
String className = null;
|
||||
|
||||
if(fileName.endsWith(".class"))
|
||||
{
|
||||
className = pkgname + '.' + fileName.substring(0, fileName.length() - 6);
|
||||
}
|
||||
|
||||
if(className != null)
|
||||
{
|
||||
classes.add(loadClass(className));
|
||||
}
|
||||
|
||||
File subdir = new File(directory, fileName);
|
||||
|
||||
if(subdir.isDirectory())
|
||||
{
|
||||
processDir(subdir, pkgname + '.' + fileName, classes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void processJar(URL resource, String pkgname, ArrayList<Class<?>> classes)
|
||||
{
|
||||
String relPath = pkgname.replace('.', '/');
|
||||
String resPath = resource.getPath();
|
||||
String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", "");
|
||||
|
||||
JarFile jarFile;
|
||||
|
||||
try {
|
||||
jarFile = new JarFile(jarPath);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException("Unexpected IOException reading JAR File '" + jarPath + "'", e);
|
||||
}
|
||||
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
|
||||
while(entries.hasMoreElements())
|
||||
{
|
||||
JarEntry entry = entries.nextElement();
|
||||
String entryName = entry.getName();
|
||||
String className = null;
|
||||
|
||||
if(entryName.endsWith(".class") && entryName.startsWith(relPath) && entryName.length() > (relPath.length() + "/".length()))
|
||||
{
|
||||
className = entryName.replace('/', '.').replace('\\', '.').replace(".class", "");
|
||||
}
|
||||
|
||||
if(className != null)
|
||||
{
|
||||
classes.add(loadClass(className));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Class<?>> getClassesForPackage(Package pkg)
|
||||
{
|
||||
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
|
||||
try {
|
||||
String pkgname = pkg.getName();
|
||||
String relPath = pkgname.replace('.', '/');
|
||||
|
||||
URL resource = ClassLoader.getSystemClassLoader().getResource(relPath);
|
||||
|
||||
if(resource == null)
|
||||
{
|
||||
throw new RuntimeException("Unexpected problem: No resource for " + relPath);
|
||||
}
|
||||
|
||||
resource.getPath();
|
||||
|
||||
if(resource.toString().startsWith("jar:"))
|
||||
{
|
||||
processJar(resource, pkgname, classes);
|
||||
}
|
||||
else {
|
||||
processDir(new File(resource.getPath()), pkgname, classes);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
System.err.println("[Mekanism] Error while loading classes in package " + pkg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.inventory.slot.SlotStorageTank;
|
||||
import mekanism.common.tileentity.TileEntityChemicalFormulator;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerChemicalFormulator extends Container
|
||||
{
|
||||
private TileEntityChemicalFormulator tileEntity;
|
||||
|
||||
public ContainerChemicalFormulator(InventoryPlayer inventory, TileEntityChemicalFormulator tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new Slot(tentity, 0, 26, 36));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 1, 155, 5));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 25));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.playersUsing.remove(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(RecipeHandler.getChemicalFormulatorOutput(slotStack, false) != null)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof IGasItem)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 2, 3, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 3 && slotID <= 29)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 29, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.inventory.slot.SlotStorageTank;
|
||||
import mekanism.common.item.ItemMachineUpgrade;
|
||||
import mekanism.common.tileentity.TileEntityChemicalInfuser;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerChemicalInfuser extends Container
|
||||
{
|
||||
private TileEntityChemicalInfuser tileEntity;
|
||||
|
||||
public ContainerChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 5, 56));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 155, 56));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 80, 65));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; slotX++)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; slotY++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.playersUsing.remove(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof IGasItem)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 3, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 4 && slotID <= 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerDictionary extends Container
|
||||
{
|
||||
public ContainerDictionary(InventoryPlayer inventory)
|
||||
{
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(slotID >= 0 && slotID <= 26)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 26)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 26, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -156,7 +156,7 @@ public class ContainerMetallurgicInfuser extends Container
|
|||
{
|
||||
if(tileEntity.type != null)
|
||||
{
|
||||
if(RecipeHandler.getOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, itemStack), false, Recipe.METALLURGIC_INFUSER.get()) != null)
|
||||
if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, itemStack), false) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -120,9 +120,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
|
||||
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more details.");
|
||||
list.add("Hold " + EnumColor.AQUA + EnumColor.INDIGO + "shift" + EnumColor.GREY + " for more details.");
|
||||
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " and " + EnumColor.AQUA + "M" + EnumColor.GREY + " for a description.");
|
||||
}
|
||||
else {
|
||||
else if(!Keyboard.isKeyDown(Keyboard.KEY_M))
|
||||
{
|
||||
if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY)
|
||||
{
|
||||
list.add(EnumColor.INDIGO + "Recipe Type: " + EnumColor.GREY + RecipeType.values()[getRecipeType(itemstack)].getName());
|
||||
|
@ -166,6 +168,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
list.addAll(MekanismUtils.getSplitText(type.getDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1022,14 +1027,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
|
||||
GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored"));
|
||||
|
||||
if(stored == null)
|
||||
{
|
||||
itemstack.setItemDamage(100);
|
||||
}
|
||||
else {
|
||||
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100))));
|
||||
}
|
||||
|
||||
return stored;
|
||||
}
|
||||
|
||||
|
@ -1055,14 +1052,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.setItemDamage(100);
|
||||
itemstack.stackTagCompound.removeTag("stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100))));
|
||||
itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ItemClump extends ItemMekanism
|
|||
public Icon[] icons = new Icon[256];
|
||||
public static String[] en_USNames = {"Iron", "Gold", "Osmium",
|
||||
"Copper", "Tin", "Silver",
|
||||
"Obsidian"};
|
||||
"Obsidian", "Lead"};
|
||||
|
||||
public ItemClump(int id)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class ItemClump extends ItemMekanism
|
|||
@Override
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
for(int i = 0; i <= 6; i++)
|
||||
for(int i = 0; i <= 7; i++)
|
||||
{
|
||||
icons[i] = register.registerIcon("mekanism:" + en_USNames[i] + "Clump");
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ItemClump extends ItemMekanism
|
|||
@Override
|
||||
public void getSubItems(int id, CreativeTabs tabs, List itemList)
|
||||
{
|
||||
for(int counter = 0; counter <= 6; ++counter)
|
||||
for(int counter = 0; counter <= 7; ++counter)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1, counter));
|
||||
}
|
||||
|
|
63
common/mekanism/common/item/ItemDictionary.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemDictionary extends ItemMekanism
|
||||
{
|
||||
public ItemDictionary(int id)
|
||||
{
|
||||
super(id);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(!player.isSneaking())
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
|
||||
if(block != null)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
ItemStack testStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z));
|
||||
String name = MekanismUtils.getOreDictName(testStack);
|
||||
|
||||
if(name != null && !name.isEmpty())
|
||||
{
|
||||
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Key found: " + EnumColor.DARK_GREEN + name);
|
||||
}
|
||||
else {
|
||||
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No key.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ public class ItemDirtyDust extends ItemMekanism
|
|||
public Icon[] icons = new Icon[256];
|
||||
public static String[] en_USNames = {"Iron", "Gold", "Osmium",
|
||||
"Copper", "Tin", "Silver",
|
||||
"Obsidian"};
|
||||
"Obsidian", "Lead"};
|
||||
|
||||
public ItemDirtyDust(int id)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class ItemDirtyDust extends ItemMekanism
|
|||
@Override
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
for(int i = 0; i <= 6; i++)
|
||||
for(int i = 0; i <= 7; i++)
|
||||
{
|
||||
icons[i] = register.registerIcon("mekanism:Dirty" + en_USNames[i] + "Dust");
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ItemDirtyDust extends ItemMekanism
|
|||
@Override
|
||||
public void getSubItems(int id, CreativeTabs tabs, List itemList)
|
||||
{
|
||||
for (int counter = 0; counter <= 6; ++counter)
|
||||
for (int counter = 0; counter <= 7; ++counter)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1, counter));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ public class ItemDust extends ItemMekanism
|
|||
public Icon[] icons = new Icon[256];
|
||||
public static String[] en_USNames = {"Iron", "Gold", "Osmium",
|
||||
"Obsidian", "Diamond", "Steel",
|
||||
"Copper", "Tin", "Silver"};
|
||||
"Copper", "Tin", "Silver",
|
||||
"Lead"};
|
||||
|
||||
public ItemDust(int id)
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ public class ItemDust extends ItemMekanism
|
|||
@Override
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
for(int i = 0; i <= 8; i++)
|
||||
for(int i = 0; i <= 9; i++)
|
||||
{
|
||||
icons[i] = register.registerIcon("mekanism:" + en_USNames[i] + "Dust");
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ public class ItemDust extends ItemMekanism
|
|||
@Override
|
||||
public void getSubItems(int id, CreativeTabs tabs, List itemList)
|
||||
{
|
||||
for(int counter = 0; counter <= 8; ++counter)
|
||||
for(int counter = 0; counter <= 9; ++counter)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1, counter));
|
||||
}
|
||||
|
|
68
common/mekanism/common/item/ItemGasMask.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.client.render.ModelCustomArmor.ArmorModel;
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.EnumHelper;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemGasMask extends ItemArmor
|
||||
{
|
||||
public ItemGasMask(int id)
|
||||
{
|
||||
super(id, EnumHelper.addArmorMaterial("GASMASK", 0, new int[] {0, 0, 0, 0}, 0), 0, 0);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
return armorType == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
return "mekanism:render/NullArmor.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
|
||||
{
|
||||
ModelCustomArmor model = ModelCustomArmor.INSTANCE;
|
||||
model.modelType = ArmorModel.GASMASK;
|
||||
return model;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntityAttacked(LivingAttackEvent event)
|
||||
{
|
||||
EntityLivingBase base = event.entityLiving;
|
||||
|
||||
if(base.getCurrentItemOrArmor(4) != null && base.getCurrentItemOrArmor(4).getItem() instanceof ItemGasMask)
|
||||
{
|
||||
ItemGasMask mask = (ItemGasMask)base.getCurrentItemOrArmor(4).getItem();
|
||||
|
||||
if(base.getCurrentItemOrArmor(3) != null && base.getCurrentItemOrArmor(3).getItem() instanceof ItemScubaTank)
|
||||
{
|
||||
ItemScubaTank tank = (ItemScubaTank)base.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
if(tank.getFlowing(base.getCurrentItemOrArmor(3)) && tank.getGas(base.getCurrentItemOrArmor(3)) != null)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -243,12 +243,9 @@ public class ItemJetpack extends ItemArmor implements IGasItem
|
|||
empty.setItemDamage(100);
|
||||
list.add(empty);
|
||||
|
||||
for(Gas type : GasRegistry.getRegisteredGasses())
|
||||
{
|
||||
ItemStack filled = new ItemStack(this);
|
||||
setGas(new GasStack(type, ((IGasItem)filled.getItem()).getMaxGas(filled)), filled);
|
||||
list.add(filled);
|
||||
}
|
||||
ItemStack filled = new ItemStack(this);
|
||||
setGas(new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem)filled.getItem()).getMaxGas(filled)), filled);
|
||||
list.add(filled);
|
||||
}
|
||||
|
||||
public static enum JetpackMode
|
||||
|
|
250
common/mekanism/common/item/ItemScubaTank.java
Normal file
|
@ -0,0 +1,250 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.client.render.ModelCustomArmor.ArmorModel;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.EnumHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemScubaTank extends ItemArmor implements IGasItem
|
||||
{
|
||||
public int MAX_GAS = 24000;
|
||||
public int TRANSFER_RATE = 16;
|
||||
|
||||
public ItemScubaTank(int id)
|
||||
{
|
||||
super(id, EnumHelper.addArmorMaterial("SCUBATANK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
setMaxDamage(100);
|
||||
setNoRepair();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
{
|
||||
GasStack gasStack = getGas(itemstack);
|
||||
|
||||
if(gasStack == null)
|
||||
{
|
||||
list.add("No gas stored.");
|
||||
}
|
||||
else {
|
||||
list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount);
|
||||
}
|
||||
|
||||
list.add(EnumColor.GREY + "Flowing: " + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowing(itemstack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
return armorType == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
return "mekanism:render/NullArmor.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
|
||||
{
|
||||
ModelCustomArmor model = ModelCustomArmor.INSTANCE;
|
||||
model.modelType = ArmorModel.SCUBATANK;
|
||||
return model;
|
||||
}
|
||||
|
||||
public void useGas(ItemStack stack)
|
||||
{
|
||||
setGas(new GasStack(getGas(stack).getGas(), getGas(stack).amount-1), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
return MAX_GAS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRate(ItemStack itemstack)
|
||||
{
|
||||
return TRANSFER_RATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(stack.getGas() != GasRegistry.getGas("oxygen"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount));
|
||||
setGas(new GasStack(stack.getGas(), getStored(itemstack)+toUse), itemstack);
|
||||
|
||||
return toUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack removeGas(ItemStack itemstack, int amount)
|
||||
{
|
||||
if(getGas(itemstack) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Gas type = getGas(itemstack).getGas();
|
||||
|
||||
int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount));
|
||||
setGas(new GasStack(type, getStored(itemstack)-gasToUse), itemstack);
|
||||
|
||||
return new GasStack(type, gasToUse);
|
||||
}
|
||||
|
||||
public int getStored(ItemStack itemstack)
|
||||
{
|
||||
return getGas(itemstack) != null ? getGas(itemstack).amount : 0;
|
||||
}
|
||||
|
||||
public void toggleFlowing(ItemStack stack)
|
||||
{
|
||||
setFlowing(stack, !getFlowing(stack));
|
||||
}
|
||||
|
||||
public boolean getFlowing(ItemStack stack)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stack.stackTagCompound.getBoolean("flowing");
|
||||
}
|
||||
|
||||
public void setFlowing(ItemStack stack, boolean flowing)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.stackTagCompound.setBoolean("flowing", flowing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ItemStack itemstack, Gas type)
|
||||
{
|
||||
return type == GasRegistry.getGas("oxygen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideGas(ItemStack itemstack, Gas type)
|
||||
{
|
||||
return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)data[0];
|
||||
|
||||
if(itemstack.stackTagCompound == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored"));
|
||||
|
||||
if(stored == null)
|
||||
{
|
||||
itemstack.setItemDamage(100);
|
||||
}
|
||||
else {
|
||||
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100))));
|
||||
}
|
||||
|
||||
return stored;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(GasStack stack, Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)data[0];
|
||||
|
||||
if(itemstack.stackTagCompound == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.setItemDamage(100);
|
||||
itemstack.stackTagCompound.removeTag("stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100))));
|
||||
itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getEmptyItem()
|
||||
{
|
||||
ItemStack empty = new ItemStack(this);
|
||||
setGas(null, empty);
|
||||
empty.setItemDamage(100);
|
||||
return empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int i, CreativeTabs tabs, List list)
|
||||
{
|
||||
ItemStack empty = new ItemStack(this);
|
||||
setGas(null, empty);
|
||||
empty.setItemDamage(100);
|
||||
list.add(empty);
|
||||
|
||||
ItemStack filled = new ItemStack(this);
|
||||
setGas(new GasStack(GasRegistry.getGas("oxygen"), ((IGasItem)filled.getItem()).getMaxGas(filled)), filled);
|
||||
list.add(filled);
|
||||
}
|
||||
}
|
|
@ -14,9 +14,9 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
|
||||
public class PacketJetpackData implements IMekanismPacket
|
||||
{
|
||||
public PacketType packetType;
|
||||
public JetpackPacket packetType;
|
||||
|
||||
public EntityPlayer updatePlayer;
|
||||
public String username;
|
||||
public boolean value;
|
||||
|
||||
@Override
|
||||
|
@ -28,11 +28,11 @@ public class PacketJetpackData implements IMekanismPacket
|
|||
@Override
|
||||
public IMekanismPacket setParams(Object... data)
|
||||
{
|
||||
packetType = (PacketType)data[0];
|
||||
packetType = (JetpackPacket)data[0];
|
||||
|
||||
if(packetType == PacketType.UPDATE)
|
||||
if(packetType == JetpackPacket.UPDATE)
|
||||
{
|
||||
updatePlayer = (EntityPlayer)data[1];
|
||||
username = (String)data[1];
|
||||
value = (Boolean)data[2];
|
||||
}
|
||||
|
||||
|
@ -42,32 +42,38 @@ public class PacketJetpackData implements IMekanismPacket
|
|||
@Override
|
||||
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
||||
{
|
||||
packetType = PacketType.values()[dataStream.readInt()];
|
||||
packetType = JetpackPacket.values()[dataStream.readInt()];
|
||||
|
||||
if(packetType == PacketType.UPDATE)
|
||||
if(packetType == JetpackPacket.FULL)
|
||||
{
|
||||
Mekanism.jetpackOn.clear();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
Mekanism.jetpackOn.add(dataStream.readUTF());
|
||||
}
|
||||
}
|
||||
else if(packetType == JetpackPacket.UPDATE)
|
||||
{
|
||||
String username = dataStream.readUTF();
|
||||
boolean value = dataStream.readBoolean();
|
||||
|
||||
EntityPlayer p = world.getPlayerEntityByName(username);
|
||||
|
||||
if(p != null)
|
||||
if(value)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
Mekanism.jetpackOn.add(p);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(p);
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(PacketType.UPDATE, p, value), world.provider.dimensionId);
|
||||
}
|
||||
Mekanism.jetpackOn.add(username);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(username);
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.UPDATE, username, value), world.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
else if(packetType == PacketType.MODE)
|
||||
else if(packetType == JetpackPacket.MODE)
|
||||
{
|
||||
ItemStack stack = player.getCurrentItemOrArmor(3);
|
||||
|
||||
|
@ -83,16 +89,26 @@ public class PacketJetpackData implements IMekanismPacket
|
|||
{
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
if(packetType == PacketType.UPDATE)
|
||||
if(packetType == JetpackPacket.UPDATE)
|
||||
{
|
||||
dataStream.writeUTF(updatePlayer.username);
|
||||
dataStream.writeUTF(username);
|
||||
dataStream.writeBoolean(value);
|
||||
}
|
||||
else if(packetType == JetpackPacket.FULL)
|
||||
{
|
||||
dataStream.writeInt(Mekanism.jetpackOn.size());
|
||||
|
||||
for(String username : Mekanism.jetpackOn)
|
||||
{
|
||||
dataStream.writeUTF(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static enum PacketType
|
||||
public static enum JetpackPacket
|
||||
{
|
||||
UPDATE,
|
||||
FULL,
|
||||
MODE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.common.PacketHandler;
|
|||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -15,6 +16,8 @@ import net.minecraft.world.World;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class PacketPortableTeleport implements IMekanismPacket
|
||||
{
|
||||
@Override
|
||||
|
@ -49,6 +52,11 @@ public class PacketPortableTeleport implements IMekanismPacket
|
|||
((EntityPlayerMP)player).travelToDimension(coords.dimensionId);
|
||||
}
|
||||
|
||||
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId);
|
||||
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
|
||||
|
||||
teleporter.didTeleport.add(player);
|
||||
teleporter.teleDelay = 5;
|
||||
((EntityPlayerMP)player).playerNetServerHandler.setPlayerLocation(coords.xCoord+0.5, coords.yCoord+1, coords.zCoord+0.5, player.rotationYaw, player.rotationPitch);
|
||||
|
||||
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
|
114
common/mekanism/common/network/PacketScubaTankData.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
package mekanism.common.network;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class PacketScubaTankData implements IMekanismPacket
|
||||
{
|
||||
public ScubaTankPacket packetType;
|
||||
|
||||
public String username;
|
||||
public boolean value;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "ScubaTankData";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMekanismPacket setParams(Object... data)
|
||||
{
|
||||
packetType = (ScubaTankPacket)data[0];
|
||||
|
||||
if(packetType == ScubaTankPacket.UPDATE)
|
||||
{
|
||||
username = (String)data[1];
|
||||
value = (Boolean)data[2];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
||||
{
|
||||
packetType = ScubaTankPacket.values()[dataStream.readInt()];
|
||||
|
||||
if(packetType == ScubaTankPacket.FULL)
|
||||
{
|
||||
Mekanism.gasmaskOn.clear();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
Mekanism.gasmaskOn.add(dataStream.readUTF());
|
||||
}
|
||||
}
|
||||
else if(packetType == ScubaTankPacket.UPDATE)
|
||||
{
|
||||
String username = dataStream.readUTF();
|
||||
boolean value = dataStream.readBoolean();
|
||||
|
||||
if(value)
|
||||
{
|
||||
Mekanism.gasmaskOn.add(username);
|
||||
}
|
||||
else {
|
||||
Mekanism.gasmaskOn.remove(username);
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.UPDATE, username, value), world.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
else if(packetType == ScubaTankPacket.MODE)
|
||||
{
|
||||
ItemStack stack = player.getCurrentItemOrArmor(3);
|
||||
|
||||
if(stack != null && stack.getItem() instanceof ItemScubaTank)
|
||||
{
|
||||
((ItemScubaTank)stack.getItem()).toggleFlowing(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream dataStream) throws Exception
|
||||
{
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
if(packetType == ScubaTankPacket.UPDATE)
|
||||
{
|
||||
dataStream.writeUTF(username);
|
||||
dataStream.writeBoolean(value);
|
||||
}
|
||||
else if(packetType == ScubaTankPacket.FULL)
|
||||
{
|
||||
dataStream.writeInt(Mekanism.gasmaskOn.size());
|
||||
|
||||
for(String username : Mekanism.gasmaskOn)
|
||||
{
|
||||
dataStream.writeUTF(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ScubaTankPacket
|
||||
{
|
||||
UPDATE,
|
||||
FULL,
|
||||
MODE;
|
||||
}
|
||||
}
|
|
@ -168,7 +168,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
return getFuelTicks(itemstack) > 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,372 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasAcceptor;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.IGasStorage;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityChemicalFormulator extends TileEntityElectricBlock implements IActiveState, IGasStorage, ITubeConnection, IRedstoneControl
|
||||
{
|
||||
public GasStack gasTank;
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 16;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public int operatingTicks = 0;
|
||||
|
||||
public int TICKS_REQUIRED = 100;
|
||||
|
||||
public final double ENERGY_USAGE = Mekanism.rotaryCondensentratorUsage;
|
||||
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityChemicalFormulator()
|
||||
{
|
||||
super("ChemicalFormulator", 0 /*TODO*/);
|
||||
inventory = new ItemStack[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(getGas() != null)
|
||||
{
|
||||
if(inventory[2] != null)
|
||||
{
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.addGas(inventory[2], getGas())));
|
||||
}
|
||||
}
|
||||
|
||||
if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this))
|
||||
{
|
||||
setActive(true);
|
||||
setEnergy(getEnergy() - ENERGY_USAGE);
|
||||
|
||||
if(operatingTicks < TICKS_REQUIRED)
|
||||
{
|
||||
operatingTicks++;
|
||||
}
|
||||
else {
|
||||
GasStack stack = RecipeHandler.getChemicalFormulatorOutput(inventory[0], true);
|
||||
|
||||
setGas(new GasStack(stack.getGas(), getStoredGas()+stack.amount));
|
||||
operatingTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(prevEnergy >= getEnergy())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
|
||||
if(getGas() != null)
|
||||
{
|
||||
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput));
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing))));
|
||||
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IGasAcceptor)
|
||||
{
|
||||
if(((IGasAcceptor)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), getGas().getGas()))
|
||||
{
|
||||
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput)));
|
||||
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
|
||||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
return RecipeHandler.getChemicalFormulatorOutput(itemstack, false) != null;
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
|
||||
{
|
||||
if(slotID == 2)
|
||||
{
|
||||
return inventory[2] != null && inventory[2].getItem() instanceof IGasItem && ((IGasItem)inventory[2].getItem()).canProvideGas(inventory[2], null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
if(side == MekanismUtils.getLeft(facing).ordinal())
|
||||
{
|
||||
return new int[] {0};
|
||||
}
|
||||
else if(side == 0 || side == 1)
|
||||
{
|
||||
return new int[] {1};
|
||||
}
|
||||
else if(side == MekanismUtils.getRight(facing).ordinal())
|
||||
{
|
||||
return new int[] {2};
|
||||
}
|
||||
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
public int getStoredGas()
|
||||
{
|
||||
return gasTank != null ? gasTank.amount : 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress(int i)
|
||||
{
|
||||
return operatingTicks*i / TICKS_REQUIRED;
|
||||
}
|
||||
|
||||
public boolean canOperate()
|
||||
{
|
||||
if(inventory[0] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GasStack stack = RecipeHandler.getChemicalFormulatorOutput(inventory[0], false);
|
||||
|
||||
if(stack == null || (getGas() != null && (getGas().getGas() != stack.getGas() || getMaxGas()-getGas().amount < stack.amount)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
operatingTicks = dataStream.readInt();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
gasTank = new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt());
|
||||
}
|
||||
else {
|
||||
gasTank = null;
|
||||
}
|
||||
|
||||
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(operatingTicks);
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(gasTank.getGas().getID());
|
||||
data.add(gasTank.amount);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
|
||||
gasTank = GasStack.readFromNBT(nbtTags.getCompoundTag("gasTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int i)
|
||||
{
|
||||
return i != 0 && i != 1;
|
||||
}
|
||||
|
||||
public int getScaledGasLevel(int i)
|
||||
{
|
||||
return gasTank != null ? gasTank.amount*i / MAX_GAS : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return side == MekanismUtils.getRight(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(Object... data)
|
||||
{
|
||||
return gasTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(GasStack stack, Object... data)
|
||||
{
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
gasTank = null;
|
||||
}
|
||||
else {
|
||||
gasTank = new GasStack(stack.getGas(), Math.max(Math.min(stack.amount, getMaxGas()), 0));
|
||||
}
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
return MAX_GAS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
}
|
473
common/mekanism/common/tileentity/TileEntityChemicalInfuser.java
Normal file
|
@ -0,0 +1,473 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasAcceptor;
|
||||
import mekanism.common.IRedstoneControl.RedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityChemicalInfuser extends TileEntityElectricBlock //implements IActiveState, IGasStorage, IGasAcceptor, ITubeConnection, IRedstoneControl
|
||||
{
|
||||
public GasStack leftStack;
|
||||
public GasStack rightStack;
|
||||
|
||||
public GasStack centerStack;
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 16;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double ENERGY_USAGE = Mekanism.chemicalInfuserUsage;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityChemicalInfuser()
|
||||
{
|
||||
super("ChemicalInfuser", 0 /*TODO*/);
|
||||
inventory = new ItemStack[4];
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if(mode == 0)
|
||||
{
|
||||
if(inventory[1] != null && (getGas() == null || getGas().amount < getMaxGas()))
|
||||
{
|
||||
if(getGas() == null)
|
||||
{
|
||||
setGas(GasTransmission.removeGas(inventory[1], null, getMaxGas()));
|
||||
}
|
||||
else {
|
||||
GasStack removed = GasTransmission.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount);
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount + (removed != null ? removed.amount : 0)));
|
||||
}
|
||||
}
|
||||
|
||||
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidGas(gasTank) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < 10000 && gasEquals(gasTank, fluidTank.getFluid()))))
|
||||
{
|
||||
setActive(true);
|
||||
fluidTank.fill(new FluidStack(getGas().getGas().getFluid(), 1), true);
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount-1));
|
||||
setEnergy(getEnergy() - ENERGY_USAGE);
|
||||
}
|
||||
else {
|
||||
if(prevEnergy >= getEnergy())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mode == 1)
|
||||
{
|
||||
if(getGas() != null)
|
||||
{
|
||||
if(inventory[0] != null)
|
||||
{
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.addGas(inventory[0], getGas())));
|
||||
}
|
||||
}
|
||||
|
||||
if(getGas() != null)
|
||||
{
|
||||
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput));
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing))));
|
||||
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IGasAcceptor)
|
||||
{
|
||||
if(((IGasAcceptor)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), getGas().getGas()))
|
||||
{
|
||||
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput)));
|
||||
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(FluidContainerRegistry.isFilledContainer(inventory[2]))
|
||||
{
|
||||
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[2]);
|
||||
|
||||
if((fluidTank.getFluid() == null && itemFluid.amount <= 10000) || fluidTank.getFluid().amount+itemFluid.amount <= 10000)
|
||||
{
|
||||
if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack containerItem = inventory[2].getItem().getContainerItemStack(inventory[2]);
|
||||
|
||||
boolean filled = false;
|
||||
|
||||
if(containerItem != null)
|
||||
{
|
||||
if(inventory[3] == null || (inventory[3].isItemEqual(containerItem) && inventory[3].stackSize+1 <= containerItem.getMaxStackSize()))
|
||||
{
|
||||
inventory[2] = null;
|
||||
|
||||
if(inventory[3] == null)
|
||||
{
|
||||
inventory[3] = containerItem;
|
||||
}
|
||||
else {
|
||||
inventory[3].stackSize++;
|
||||
}
|
||||
|
||||
filled = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
inventory[2].stackSize--;
|
||||
|
||||
if(inventory[2].stackSize == 0)
|
||||
{
|
||||
inventory[2] = null;
|
||||
}
|
||||
|
||||
filled = true;
|
||||
}
|
||||
|
||||
if(filled)
|
||||
{
|
||||
fluidTank.fill(itemFluid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank == null || (gasTank.amount < MAX_GAS && gasEquals(gasTank, fluidTank.getFluid()))))
|
||||
{
|
||||
setActive(true);
|
||||
setGas(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), getGas() != null ? getGas().amount+1 : 1));
|
||||
fluidTank.drain(1, true);
|
||||
setEnergy(getEnergy() - ENERGY_USAGE);
|
||||
}
|
||||
else {
|
||||
if(prevEnergy >= getEnergy())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidGas(GasStack g)
|
||||
{
|
||||
if(g == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return g.getGas().hasFluid();
|
||||
}
|
||||
|
||||
public boolean gasEquals(GasStack gas, FluidStack fluid)
|
||||
{
|
||||
if(fluid == null || gas == null || !gas.getGas().hasFluid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return gas.getGas().getFluid() == fluid.getFluid();
|
||||
}
|
||||
|
||||
public boolean isValidFluid(FluidStack f)
|
||||
{
|
||||
if(f == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return GasRegistry.getGas(f.getFluid()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
int type = dataStream.readInt();
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
mode = mode == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
mode = dataStream.readInt();
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt()));
|
||||
}
|
||||
else {
|
||||
fluidTank.setFluid(null);
|
||||
}
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
gasTank = new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt());
|
||||
}
|
||||
else {
|
||||
gasTank = null;
|
||||
}
|
||||
|
||||
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(mode);
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(fluidTank.getFluid().fluidID);
|
||||
data.add(fluidTank.getFluid().amount);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(gasTank.getGas().getID());
|
||||
data.add(gasTank.amount);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
mode = nbtTags.getInteger("mode");
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
gasTank = GasStack.readFromNBT(nbtTags.getCompoundTag("gasTank"));
|
||||
|
||||
if(nbtTags.hasKey("fluidTank"))
|
||||
{
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("mode", mode);
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int i)
|
||||
{
|
||||
return i != 0 && i != 1;
|
||||
}
|
||||
|
||||
public int getScaledFluidLevel(int i)
|
||||
{
|
||||
return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0;
|
||||
}
|
||||
|
||||
public int getScaledGasLevel(int i)
|
||||
{
|
||||
return gasTank != null ? gasTank.amount*i / MAX_GAS : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return side == MekanismUtils.getLeft(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(GasStack stack)
|
||||
{
|
||||
if(gasTank == null || (gasTank != null && gasTank.getGas() == stack.getGas()))
|
||||
{
|
||||
int stored = getGas() != null ? getGas().amount : 0;
|
||||
int toUse = Math.min(getMaxGas()-stored, stack.amount);
|
||||
|
||||
setGas(new GasStack(stack.getGas(), stored + toUse));
|
||||
|
||||
return toUse;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return mode == 0 && (getGas() == null || getGas().getGas() == type) && side == MekanismUtils.getLeft(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(Object... data)
|
||||
{
|
||||
return gasTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(GasStack stack, Object... data)
|
||||
{
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
gasTank = null;
|
||||
}
|
||||
else {
|
||||
gasTank = new GasStack(stack.getGas(), Math.max(Math.min(stack.amount, getMaxGas()), 0));
|
||||
}
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
return MAX_GAS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}*/
|
||||
}
|
|
@ -868,7 +868,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
|||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -449,7 +449,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
return RecipeType.values()[recipeType].getFuelTicks(itemstack) > 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -226,7 +226,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
if(type != null)
|
||||
{
|
||||
if(RecipeHandler.getOutput(InfusionInput.getInfusion(type, infuseStored, itemstack), false, Recipe.METALLURGIC_INFUSER.get()) != null)
|
||||
if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, itemstack), false) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void operate()
|
||||
|
@ -257,7 +257,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
return;
|
||||
}
|
||||
|
||||
InfusionOutput output = RecipeHandler.getOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), true, Recipe.METALLURGIC_INFUSER.get());
|
||||
InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), true);
|
||||
|
||||
infuseStored -= output.getInfuseRequired();
|
||||
|
||||
|
@ -284,7 +284,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
return false;
|
||||
}
|
||||
|
||||
InfusionOutput output = RecipeHandler.getOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), false, Recipe.METALLURGIC_INFUSER.get());
|
||||
InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), false);
|
||||
|
||||
if(output == null)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
|
@ -11,18 +13,23 @@ import mekanism.common.PacketHandler.Transmission;
|
|||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketPortalFX;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dan200.computer.api.IComputerAccess;
|
||||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
@ -32,6 +39,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
/** This teleporter's frequency. */
|
||||
public Teleporter.Code code;
|
||||
|
||||
public AxisAlignedBB teleportBounds = null;
|
||||
|
||||
public Set<Entity> didTeleport = new HashSet<Entity>();
|
||||
|
||||
public int teleDelay = 0;
|
||||
|
||||
public boolean shouldRender;
|
||||
|
||||
public boolean prevShouldRender;
|
||||
|
||||
/** This teleporter's current status. */
|
||||
public String status = (EnumColor.DARK_RED + "Not ready.");
|
||||
|
||||
|
@ -47,8 +64,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
if(teleportBounds == null)
|
||||
{
|
||||
resetBounds();
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(Mekanism.teleporters.containsKey(code))
|
||||
{
|
||||
if(!Mekanism.teleporters.get(code).contains(Object3D.get(this)) && hasFrame())
|
||||
|
@ -88,11 +110,47 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
status = EnumColor.DARK_GREEN + "Idle.";
|
||||
break;
|
||||
}
|
||||
|
||||
if(canTeleport() == 1 && teleDelay == 0)
|
||||
{
|
||||
teleport();
|
||||
}
|
||||
|
||||
if(teleDelay == 0 && didTeleport.size() > 0)
|
||||
{
|
||||
cleanTeleportCache();
|
||||
}
|
||||
|
||||
byte b = canTeleport();
|
||||
shouldRender = b == 1 || b > 4;
|
||||
|
||||
if(shouldRender != prevShouldRender)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 40D);
|
||||
}
|
||||
|
||||
prevShouldRender = shouldRender;
|
||||
|
||||
teleDelay = Math.max(0, teleDelay-1);
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(0, this);
|
||||
}
|
||||
|
||||
public void cleanTeleportCache()
|
||||
{
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds);
|
||||
Set<Entity> teleportCopy = (Set<Entity>)((HashSet<Entity>)didTeleport).clone();
|
||||
|
||||
for(Entity entity : teleportCopy)
|
||||
{
|
||||
if(!list.contains(entity))
|
||||
{
|
||||
didTeleport.remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
|
@ -110,6 +168,11 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
return true;
|
||||
}
|
||||
|
||||
public void resetBounds()
|
||||
{
|
||||
teleportBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1: yes
|
||||
* 2: no frame
|
||||
|
@ -138,7 +201,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
if(Mekanism.teleporters.get(code).size() == 2)
|
||||
{
|
||||
List<EntityPlayer> entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1));
|
||||
List<Entity> entitiesInPortal = getToTeleport();
|
||||
|
||||
Object3D closestCoords = null;
|
||||
|
||||
|
@ -153,7 +216,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
int electricityNeeded = 0;
|
||||
|
||||
for(EntityPlayer entity : entitiesInPortal)
|
||||
for(Entity entity : entitiesInPortal)
|
||||
{
|
||||
electricityNeeded += calculateEnergyCost(entity, closestCoords);
|
||||
}
|
||||
|
@ -178,7 +241,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
if(worldObj.isRemote) return;
|
||||
|
||||
List<EntityPlayer> entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1));
|
||||
List<Entity> entitiesInPortal = getToTeleport();
|
||||
|
||||
Object3D closestCoords = null;
|
||||
|
||||
|
@ -191,26 +254,86 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
}
|
||||
}
|
||||
|
||||
for(EntityPlayer entity : entitiesInPortal)
|
||||
{
|
||||
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
||||
for(Entity entity : entitiesInPortal)
|
||||
{
|
||||
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(closestCoords.dimensionId);
|
||||
TileEntityTeleporter teleporter = (TileEntityTeleporter)closestCoords.getTileEntity(teleWorld);
|
||||
|
||||
worldObj.playSoundAtEntity((EntityPlayerMP)entity, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
if(entity.worldObj.provider.dimensionId != closestCoords.dimensionId)
|
||||
if(teleporter != null)
|
||||
{
|
||||
entity.travelToDimension(closestCoords.dimensionId);
|
||||
}
|
||||
|
||||
((EntityPlayerMP)entity).playerNetServerHandler.setPlayerLocation(closestCoords.xCoord+0.5, closestCoords.yCoord+1, closestCoords.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||
|
||||
for(Object3D coords : Mekanism.teleporters.get(code))
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D);
|
||||
teleporter.didTeleport.add(entity);
|
||||
teleporter.teleDelay = 5;
|
||||
|
||||
if(entity instanceof EntityPlayerMP)
|
||||
{
|
||||
if(entity.worldObj.provider.dimensionId != closestCoords.dimensionId)
|
||||
{
|
||||
entity.travelToDimension(closestCoords.dimensionId);
|
||||
}
|
||||
|
||||
((EntityPlayerMP)entity).playerNetServerHandler.setPlayerLocation(closestCoords.xCoord+0.5, closestCoords.yCoord+1, closestCoords.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||
}
|
||||
else {
|
||||
teleportEntityTo(entity, closestCoords, teleporter);
|
||||
}
|
||||
|
||||
for(Object3D coords : Mekanism.teleporters.get(code))
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D);
|
||||
}
|
||||
|
||||
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
||||
|
||||
worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportEntityTo(Entity entity, Object3D coord, TileEntityTeleporter teleporter)
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
WorldServer world = server.worldServerForDimension(coord.dimensionId);
|
||||
|
||||
if(entity.worldObj.provider.dimensionId != coord.dimensionId)
|
||||
{
|
||||
entity.worldObj.removeEntity(entity);
|
||||
entity.isDead = false;
|
||||
|
||||
world.spawnEntityInWorld(entity);
|
||||
entity.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||
world.updateEntityWithOptionalForce(entity, false);
|
||||
entity.setWorld(world);
|
||||
world.resetUpdateEntityTick();
|
||||
|
||||
Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), world);
|
||||
|
||||
if(e != null)
|
||||
{
|
||||
e.copyDataFrom(entity, true);
|
||||
world.spawnEntityInWorld(e);
|
||||
teleporter.didTeleport.add(e);
|
||||
}
|
||||
|
||||
entity.isDead = true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Entity> getToTeleport()
|
||||
{
|
||||
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds);
|
||||
List<Entity> ret = new ArrayList<Entity>();
|
||||
|
||||
for(Entity entity : entities)
|
||||
{
|
||||
if(!didTeleport.contains(entity))
|
||||
{
|
||||
ret.add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
@ -333,6 +456,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
code.digitTwo = dataStream.readInt();
|
||||
code.digitThree = dataStream.readInt();
|
||||
code.digitFour = dataStream.readInt();
|
||||
shouldRender = dataStream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -345,6 +469,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
data.add(code.digitTwo);
|
||||
data.add(code.digitThree);
|
||||
data.add(code.digitFour);
|
||||
data.add(shouldRender);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -420,10 +545,17 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess computer) {}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess computer) {}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
|||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
if(getTransmitterNetwork().getEnergyNeeded(new ArrayList()) == 0)
|
||||
if(getTransmitterNetwork().getEnergyNeeded(getBuildCraftIgnored()) == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public final class ChargeUtils
|
|||
}
|
||||
else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem)
|
||||
{
|
||||
double sent = ElectricItem.manager.charge(storer.inventory[slotID], (int)(storer.getEnergy()*Mekanism.TO_IC2), 3, true, false)*Mekanism.FROM_IC2;
|
||||
double sent = ElectricItem.manager.charge(storer.inventory[slotID], (int)(storer.getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2;
|
||||
storer.setEnergy(storer.getEnergy() - sent);
|
||||
}
|
||||
else if(storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
|
||||
|
|
|
@ -50,6 +50,8 @@ public final class InventoryUtils
|
|||
|
||||
public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side, boolean force)
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
if(force && inventory instanceof TileEntityLogisticalSorter)
|
||||
{
|
||||
return ((TileEntityLogisticalSorter)inventory).sendHome(itemStack.copy());
|
||||
|
@ -59,8 +61,6 @@ public final class InventoryUtils
|
|||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
for(int i = 0; i <= inventory.getSizeInventory() - 1; i++)
|
||||
{
|
||||
if(!force)
|
||||
|
@ -167,6 +167,8 @@ public final class InventoryUtils
|
|||
|
||||
public static ItemStack takeTopItemFromInventory(IInventory inventory, int side)
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
for(int i = inventory.getSizeInventory() - 1; i >= 0; i--)
|
||||
|
@ -213,12 +215,12 @@ public final class InventoryUtils
|
|||
|
||||
public static InvStack takeDefinedItem(IInventory inventory, int side, ItemStack type, int min, int max)
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
InvStack ret = new InvStack(inventory);
|
||||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
{
|
||||
for(int i = inventory.getSizeInventory() - 1; i >= 0; i--)
|
||||
{
|
||||
if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).isItemEqual(type))
|
||||
|
@ -296,10 +298,10 @@ public final class InventoryUtils
|
|||
|
||||
public static InvStack takeTopStack(IInventory inventory, int side)
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
{
|
||||
for(int i = inventory.getSizeInventory() - 1; i >= 0; i--)
|
||||
{
|
||||
if(inventory.getStackInSlot(i) != null)
|
||||
|
@ -359,12 +361,10 @@ public final class InventoryUtils
|
|||
}
|
||||
}
|
||||
|
||||
IInventory inventory = (IInventory)tileEntity;
|
||||
IInventory inventory = checkChestInv((IInventory)tileEntity);
|
||||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
inventory = InventoryUtils.checkChestInv(inventory);
|
||||
|
||||
{
|
||||
for(int i = 0; i <= inventory.getSizeInventory() - 1; i++)
|
||||
{
|
||||
if(!force)
|
||||
|
|
|
@ -8,17 +8,19 @@ import java.lang.reflect.Method;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.DynamicTankCache;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.IFactory;
|
||||
import mekanism.common.IFactory.RecipeType;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.IModule;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.IRedstoneControl.RedstoneControl;
|
||||
|
@ -1126,6 +1128,16 @@ public final class MekanismUtils
|
|||
return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]";
|
||||
}
|
||||
|
||||
public static List<String> getSplitText(String s)
|
||||
{
|
||||
ArrayList ret = new ArrayList();
|
||||
|
||||
String[] split = s.split("!n");
|
||||
ret.addAll(Arrays.asList(split));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static enum ResourceType
|
||||
{
|
||||
GUI("gui"),
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class StackUtils
|
|||
return false;
|
||||
}
|
||||
|
||||
return stack1.itemID != stack2.itemID;
|
||||
return stack1.itemID != stack2.itemID || stack1.getItemDamage() != stack2.getItemDamage();
|
||||
}
|
||||
|
||||
public static boolean equalsWildcard(ItemStack wild, ItemStack check)
|
||||
|
|
|
@ -56,7 +56,7 @@ public class VoiceConnection
|
|||
EntityPlayerMP playerMP = (EntityPlayerMP)obj;
|
||||
String playerIP = playerMP.getPlayerIP();
|
||||
|
||||
if(playerIP.equals("127.0.0.1") && !Mekanism.voiceManager.foundLocal)
|
||||
if(!server.isDedicatedServer() && playerIP.equals("127.0.0.1") && !Mekanism.voiceManager.foundLocal)
|
||||
{
|
||||
Mekanism.voiceManager.foundLocal = true;
|
||||
username = playerMP.username;
|
||||
|
|
|
@ -25,11 +25,10 @@ public class VoiceServerManager
|
|||
System.out.println("[Mekanism] VoiceServer: Starting up server...");
|
||||
|
||||
try {
|
||||
running = true;
|
||||
serverSocket = new ServerSocket(Mekanism.VOICE_PORT);
|
||||
(listenThread = new ListenThread()).start();
|
||||
} catch(Exception e) {}
|
||||
|
||||
running = true;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
|
|
|
@ -137,7 +137,7 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(model3D);
|
||||
DisplayInteger.endList();
|
||||
displays[i].endList();
|
||||
}
|
||||
|
||||
energyDisplays.put(side, displays);
|
||||
|
|
|
@ -84,7 +84,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
|
|||
}
|
||||
else {
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)));
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + (getVoltage(itemstack)*Mekanism.FROM_UE) + "v");
|
||||
|
||||
if(hasTank(itemstack))
|
||||
{
|
||||
|
|
|
@ -151,10 +151,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(2);
|
||||
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), data), Object3D.get(this), 40D);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getParticlePacket(new ArrayList())), Object3D.get(this), 40D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -320,30 +317,35 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
{
|
||||
dumpType = GasRegistry.getGas(dataStream.readInt());
|
||||
}
|
||||
else if(type == 2)
|
||||
{
|
||||
spawnParticle();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
int type = dataStream.readInt();
|
||||
|
||||
if(amount != 0)
|
||||
if(type == 0)
|
||||
{
|
||||
waterTank.setFluid(new FluidStack(FluidRegistry.WATER, amount));
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
if(amount != 0)
|
||||
{
|
||||
waterTank.setFluid(new FluidStack(FluidRegistry.WATER, amount));
|
||||
}
|
||||
else {
|
||||
waterTank.setFluid(null);
|
||||
}
|
||||
|
||||
oxygenStored = dataStream.readInt();
|
||||
hydrogenStored = dataStream.readInt();
|
||||
outputType = GasRegistry.getGas(dataStream.readInt());
|
||||
dumpType = GasRegistry.getGas(dataStream.readInt());
|
||||
}
|
||||
else {
|
||||
waterTank.setFluid(null);
|
||||
else if(type == 1)
|
||||
{
|
||||
spawnParticle();
|
||||
}
|
||||
|
||||
oxygenStored = dataStream.readInt();
|
||||
hydrogenStored = dataStream.readInt();
|
||||
outputType = GasRegistry.getGas(dataStream.readInt());
|
||||
dumpType = GasRegistry.getGas(dataStream.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -351,6 +353,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(0);
|
||||
if(waterTank.getFluid() != null)
|
||||
{
|
||||
data.add(waterTank.getFluid().amount);
|
||||
|
@ -367,6 +370,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
return data;
|
||||
}
|
||||
|
||||
public ArrayList getParticlePacket(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
data.add(1);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.induction.client.model.ModelEMContractor;
|
|||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
|||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
switch (((TileEntityEMContractor) t).getFacing())
|
||||
switch(ForgeDirection.getOrientation(((TileEntityEMContractor)t).getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
|
@ -50,21 +51,19 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
|||
break;
|
||||
}
|
||||
|
||||
if (((TileEntityEMContractor) t).suck)
|
||||
if(((TileEntityEMContractor) t).suck)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractor.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractorOn.png"));
|
||||
}
|
||||
|
||||
if (((TileEntityEMContractor) t).canFunction() && !Mekanism.proxy.isPaused())
|
||||
if(((TileEntityEMContractor)t).canFunction() && !Mekanism.proxy.isPaused())
|
||||
{
|
||||
MODEL_SPIN.render(0.0625f);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
model.render(0.0625f);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,16 +20,18 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
|||
*/
|
||||
public class InductionCommonProxy implements IGuiHandler
|
||||
{
|
||||
public void registerRenderers()
|
||||
public void registerRenderers() {}
|
||||
|
||||
public void loadConfiguration()
|
||||
{
|
||||
Mekanism.configuration.load();
|
||||
MekanismInduction.SOUND_FXS = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", MekanismInduction.SOUND_FXS).getBoolean(MekanismInduction.SOUND_FXS);
|
||||
MekanismInduction.MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MekanismInduction.MAX_CONTRACTOR_DISTANCE).getInt(MekanismInduction.MAX_CONTRACTOR_DISTANCE);
|
||||
MekanismInduction.SOUND_FXS = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TeslaSoundFXs", MekanismInduction.SOUND_FXS).getBoolean(MekanismInduction.SOUND_FXS);
|
||||
MekanismInduction.MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxEMContractor Path", MekanismInduction.MAX_CONTRACTOR_DISTANCE).getInt(MekanismInduction.MAX_CONTRACTOR_DISTANCE);
|
||||
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
TileEntityEMContractor.MAX_REACH = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
|
||||
TileEntityEMContractor.MAX_SPEED = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", TileEntityEMContractor.MAX_SPEED).getDouble(TileEntityEMContractor.MAX_SPEED);
|
||||
TileEntityEMContractor.PUSH_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", TileEntityEMContractor.PUSH_DELAY).getInt(TileEntityEMContractor.PUSH_DELAY);
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorItemAcceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
TileEntityEMContractor.MAX_REACH = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorMaxItemReach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
|
||||
TileEntityEMContractor.MAX_SPEED = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorMaxItemSpeed", TileEntityEMContractor.MAX_SPEED).getDouble(TileEntityEMContractor.MAX_SPEED);
|
||||
TileEntityEMContractor.PUSH_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorItemPushDelay", TileEntityEMContractor.PUSH_DELAY).getInt(TileEntityEMContractor.PUSH_DELAY);
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ public class MekanismInduction implements IModule
|
|||
GameRegistry.registerTileEntity(TileEntityBattery.class, "Battery");
|
||||
|
||||
MekanismInduction.proxy.registerRenderers();
|
||||
MekanismInduction.proxy.loadConfiguration();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -9,10 +9,10 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* Uses the well known A* Pathfinding algorithm.
|
||||
|
@ -22,111 +22,108 @@ import universalelectricity.core.vector.Vector3;
|
|||
*/
|
||||
public class PathfinderEMContractor
|
||||
{
|
||||
public final Set<Vector3> openSet, closedSet;
|
||||
public final Set<Object3D> openSet, closedSet;
|
||||
|
||||
public final HashMap<Vector3, Vector3> navMap;
|
||||
public final HashMap<Object3D, Object3D> navMap;
|
||||
|
||||
public final HashMap<Vector3, Double> gScore, fScore;
|
||||
public final HashMap<Object3D, Double> gScore, fScore;
|
||||
|
||||
public final Vector3 target;
|
||||
public final Object3D target;
|
||||
|
||||
public List<Vector3> results;
|
||||
public List<Object3D> results;
|
||||
|
||||
private World world;
|
||||
|
||||
public PathfinderEMContractor(World world, Vector3 target)
|
||||
public PathfinderEMContractor(World w, Object3D t)
|
||||
{
|
||||
this.world = world;
|
||||
this.target = target;
|
||||
world = w;
|
||||
target = t;
|
||||
|
||||
/**
|
||||
* Instantiate Variables
|
||||
*/
|
||||
this.openSet = new HashSet<Vector3>();
|
||||
this.closedSet = new HashSet<Vector3>();
|
||||
this.navMap = new HashMap<Vector3, Vector3>();
|
||||
this.gScore = new HashMap<Vector3, Double>();
|
||||
this.fScore = new HashMap<Vector3, Double>();
|
||||
this.results = new ArrayList<Vector3>();
|
||||
openSet = new HashSet<Object3D>();
|
||||
closedSet = new HashSet<Object3D>();
|
||||
navMap = new HashMap<Object3D, Object3D>();
|
||||
gScore = new HashMap<Object3D, Double>();
|
||||
fScore = new HashMap<Object3D, Double>();
|
||||
results = new ArrayList<Object3D>();
|
||||
}
|
||||
|
||||
public boolean find(final Vector3 start)
|
||||
public boolean find(final Object3D start)
|
||||
{
|
||||
this.openSet.add(start);
|
||||
this.gScore.put(start, 0d);
|
||||
this.fScore.put(start, this.gScore.get(start) + getEstimate(start, this.target));
|
||||
openSet.add(start);
|
||||
gScore.put(start, 0d);
|
||||
fScore.put(start, gScore.get(start) + getEstimate(start, target));
|
||||
|
||||
int blockCount = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Vector3 neighbor = this.target.clone().translate(new Vector3(direction.offsetX, direction.offsetY, direction.offsetZ));
|
||||
Object3D neighbor = target.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||
|
||||
if (!TileEntityEMContractor.canBePath(this.world, neighbor))
|
||||
if(!TileEntityEMContractor.canBePath(world, neighbor))
|
||||
{
|
||||
blockCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (blockCount >= 6)
|
||||
if(blockCount >= 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double maxSearchDistance = start.distance(this.target) * 2;
|
||||
double maxSearchDistance = start.distanceTo(target) * 2;
|
||||
|
||||
while (!this.openSet.isEmpty())
|
||||
while(!openSet.isEmpty())
|
||||
{
|
||||
Vector3 currentNode = null;
|
||||
Object3D currentNode = null;
|
||||
double lowestFScore = 0;
|
||||
|
||||
for (Vector3 node : this.openSet)
|
||||
for(Object3D node : openSet)
|
||||
{
|
||||
if (currentNode == null || this.fScore.get(node) < lowestFScore)
|
||||
if(currentNode == null || fScore.get(node) < lowestFScore)
|
||||
{
|
||||
currentNode = node;
|
||||
lowestFScore = this.fScore.get(node);
|
||||
lowestFScore = fScore.get(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentNode == null && start.distance(currentNode) > maxSearchDistance)
|
||||
if(currentNode == null && start.distanceTo(currentNode) > maxSearchDistance)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (currentNode.equals(this.target))
|
||||
if(currentNode.equals(target))
|
||||
{
|
||||
this.results = this.reconstructPath(this.navMap, this.target);
|
||||
results = reconstructPath(navMap, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.openSet.remove(currentNode);
|
||||
this.closedSet.add(currentNode);
|
||||
openSet.remove(currentNode);
|
||||
closedSet.add(currentNode);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Vector3 neighbor = currentNode.clone().modifyPositionFromSide(direction);
|
||||
Object3D neighbor = currentNode.getFromSide(direction);
|
||||
|
||||
if (TileEntityEMContractor.canBePath(this.world, neighbor))
|
||||
if(TileEntityEMContractor.canBePath(world, neighbor))
|
||||
{
|
||||
double tentativeG = this.gScore.get(currentNode) + currentNode.distance(neighbor);
|
||||
double tentativeG = gScore.get(currentNode) + currentNode.distanceTo(neighbor);
|
||||
|
||||
if (this.closedSet.contains(neighbor))
|
||||
if(closedSet.contains(neighbor))
|
||||
{
|
||||
if (tentativeG >= this.gScore.get(neighbor))
|
||||
if(tentativeG >= gScore.get(neighbor))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.openSet.contains(neighbor) || tentativeG < this.gScore.get(neighbor))
|
||||
if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor))
|
||||
{
|
||||
this.navMap.put(neighbor, currentNode);
|
||||
this.gScore.put(neighbor, tentativeG);
|
||||
this.fScore.put(neighbor, this.gScore.get(neighbor) + this.getEstimate(neighbor, this.target));
|
||||
this.openSet.add(neighbor);
|
||||
navMap.put(neighbor, currentNode);
|
||||
gScore.put(neighbor, tentativeG);
|
||||
fScore.put(neighbor, gScore.get(neighbor) + getEstimate(neighbor, target));
|
||||
openSet.add(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,21 +132,21 @@ public class PathfinderEMContractor
|
|||
return false;
|
||||
}
|
||||
|
||||
private List<Vector3> reconstructPath(HashMap<Vector3, Vector3> naviMap, Vector3 currentNode)
|
||||
private List<Object3D> reconstructPath(HashMap<Object3D, Object3D> naviMap, Object3D currentNode)
|
||||
{
|
||||
List<Vector3> path = new ArrayList<Vector3>();
|
||||
List<Object3D> path = new ArrayList<Object3D>();
|
||||
path.add(currentNode);
|
||||
|
||||
if (naviMap.containsKey(currentNode))
|
||||
if(naviMap.containsKey(currentNode))
|
||||
{
|
||||
path.addAll(this.reconstructPath(naviMap, naviMap.get(currentNode)));
|
||||
path.addAll(reconstructPath(naviMap, naviMap.get(currentNode)));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private double getEstimate(Vector3 start, Vector3 target2)
|
||||
private double getEstimate(Object3D start, Object3D target2)
|
||||
{
|
||||
return start.distance(target2);
|
||||
return start.distanceTo(target2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package mekanism.induction.common;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import mekanism.api.Object3D;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
|
@ -13,27 +13,27 @@ public class ThreadEMPathfinding extends Thread
|
|||
{
|
||||
private boolean isCompleted = false;
|
||||
private PathfinderEMContractor pathfinder;
|
||||
private Vector3 start;
|
||||
private Object3D start;
|
||||
|
||||
public ThreadEMPathfinding(PathfinderEMContractor pathfinder, Vector3 start)
|
||||
public ThreadEMPathfinding(PathfinderEMContractor p, Object3D s)
|
||||
{
|
||||
this.pathfinder = pathfinder;
|
||||
this.start = start;
|
||||
this.setPriority(Thread.MIN_PRIORITY);
|
||||
pathfinder = p;
|
||||
start = s;
|
||||
setPriority(Thread.MIN_PRIORITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
this.pathfinder.find(this.start);
|
||||
this.isCompleted = true;
|
||||
pathfinder.find(start);
|
||||
isCompleted = true;
|
||||
}
|
||||
|
||||
public PathfinderEMContractor getPath()
|
||||
{
|
||||
if (this.isCompleted)
|
||||
if(isCompleted)
|
||||
{
|
||||
return this.pathfinder;
|
||||
return pathfinder;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -110,7 +110,7 @@ public class BlockEMContractor extends Block implements ITileEntityProvider
|
|||
|
||||
if(tileEntity instanceof IInventory)
|
||||
{
|
||||
tileContractor.setFacing(side.getOpposite());
|
||||
tileContractor.setFacing((short)side.getOpposite().ordinal());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,20 +21,20 @@ public class ItemBlockContractor extends ItemBlock
|
|||
{
|
||||
boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
|
||||
|
||||
if (place)
|
||||
if(place)
|
||||
{
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z);
|
||||
tileContractor.setFacing(ForgeDirection.getOrientation(side));
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
tileContractor.setFacing((short)ForgeDirection.getOrientation(side).ordinal());
|
||||
|
||||
if (!tileContractor.isLatched())
|
||||
if(!tileContractor.isLatched())
|
||||
{
|
||||
for (ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x + side1.offsetX, y + side1.offsetY, z + side1.offsetZ);
|
||||
|
||||
if (tileEntity instanceof IInventory)
|
||||
if(tileEntity instanceof IInventory)
|
||||
{
|
||||
tileContractor.setFacing(side1.getOpposite());
|
||||
tileContractor.setFacing((short)side1.getOpposite().ordinal());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.tileentity.TileEntityBasicBlock;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.PathfinderEMContractor;
|
||||
|
@ -30,16 +29,10 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class TileEntityEMContractor extends TileEntityAdvanced implements ITileNetwork
|
||||
public class TileEntityEMContractor extends TileEntityBasicBlock
|
||||
{
|
||||
public static int MAX_REACH = 40;
|
||||
public static int PUSH_DELAY = 5;
|
||||
|
@ -50,17 +43,12 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
private AxisAlignedBB operationBounds;
|
||||
private AxisAlignedBB suckBounds;
|
||||
|
||||
public ForgeDirection facing = ForgeDirection.UP;
|
||||
|
||||
/**
|
||||
* true = suck, false = push
|
||||
*/
|
||||
public boolean suck = true;
|
||||
|
||||
/**
|
||||
* Pathfinding
|
||||
*/
|
||||
private ThreadEMPathfinding thread;
|
||||
private PathfinderEMContractor pathfinder;
|
||||
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
|
||||
|
@ -69,19 +57,15 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
/** Color of beam */
|
||||
private int dyeID = TileEntityTesla.DEFAULT_COLOR;
|
||||
private Vector3 tempLinkVector;
|
||||
private Object3D tempLinkVector;
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
public void onUpdate()
|
||||
{
|
||||
super.initiate();
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if(ticker == 1)
|
||||
{
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
pushDelay = Math.max(0, pushDelay - 1);
|
||||
|
||||
|
@ -102,7 +86,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
if(!suck && pushDelay == 0)
|
||||
{
|
||||
ItemStack retrieved = InventoryUtils.takeTopItemFromInventory(inventory, getFacing().getOpposite().ordinal());
|
||||
ItemStack retrieved = InventoryUtils.takeTopItemFromInventory(inventory, ForgeDirection.OPPOSITES[getFacing()]);
|
||||
|
||||
if(retrieved != null)
|
||||
{
|
||||
|
@ -124,7 +108,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
{
|
||||
for(EntityItem item : (List<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, suckBounds))
|
||||
{
|
||||
ItemStack remains = InventoryUtils.putStackInInventory(inventory, item.getEntityItem(), getFacing().getOpposite().ordinal(), false);
|
||||
ItemStack remains = InventoryUtils.putStackInInventory(inventory, item.getEntityItem(), ForgeDirection.OPPOSITES[getFacing()], false);
|
||||
|
||||
if(remains == null)
|
||||
{
|
||||
|
@ -150,7 +134,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
}
|
||||
|
||||
final int renderFrequency = MekanismInduction.proxy.isFancy() ? 1 + worldObj.rand.nextInt(2) : 10 + worldObj.rand.nextInt(2);
|
||||
final boolean renderBeam = ticks % renderFrequency == 0 && hasLink() && linked.suck != suck;
|
||||
final boolean renderBeam = ticker % renderFrequency == 0 && hasLink() && linked.suck != suck;
|
||||
|
||||
if(hasLink())
|
||||
{
|
||||
|
@ -166,23 +150,23 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
{
|
||||
for(int i = 0; i < pathfinder.results.size(); i++)
|
||||
{
|
||||
Vector3 result = pathfinder.results.get(i).clone();
|
||||
Object3D result = pathfinder.results.get(i);
|
||||
|
||||
if(TileEntityEMContractor.canBePath(worldObj, result))
|
||||
{
|
||||
if(i - 1 >= 0)
|
||||
{
|
||||
Vector3 prevResult = pathfinder.results.get(i - 1).clone();
|
||||
Object3D prevResult = pathfinder.results.get(i - 1);
|
||||
|
||||
Vector3 difference = prevResult.clone().difference(result);
|
||||
final ForgeDirection direction = difference.toForgeDirection();
|
||||
Object3D difference = prevResult.difference(result);
|
||||
final ForgeDirection direction = toForge(difference);
|
||||
|
||||
if(renderBeam)
|
||||
{
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, toVec(prevResult).translate(0.5), toVec(result).translate(0.5), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.x, result.y, result.z, result.x + 1, result.y + 1, result.z + 1);
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.xCoord, result.yCoord, result.zCoord, result.xCoord + 1, result.yCoord + 1, result.zCoord + 1);
|
||||
List<EntityItem> entities = worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
|
||||
|
||||
for(EntityItem entityItem : entities)
|
||||
|
@ -210,8 +194,8 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
pathfinder = null;
|
||||
|
||||
Vector3 searchVec = new Vector3(this).modifyPositionFromSide(getFacing());
|
||||
AxisAlignedBB searchBounds = AxisAlignedBB.getAABBPool().getAABB(searchVec.x, searchVec.y, searchVec.z, searchVec.x + 1, searchVec.y + 1, searchVec.z + 1);
|
||||
Object3D searchVec = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(getFacing()));
|
||||
AxisAlignedBB searchBounds = AxisAlignedBB.getAABBPool().getAABB(searchVec.xCoord, searchVec.yCoord, searchVec.zCoord, searchVec.xCoord + 1, searchVec.yCoord + 1, searchVec.zCoord + 1);
|
||||
|
||||
if(searchBounds != null)
|
||||
{
|
||||
|
@ -222,7 +206,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
moveEntity(entityItem, getFacing(), new Vector3(this));
|
||||
moveEntity(entityItem, ForgeDirection.getOrientation(getFacing()), Object3D.get(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +215,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
{
|
||||
for(EntityItem entityItem : (List<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, operationBounds))
|
||||
{
|
||||
moveEntity(entityItem, getFacing(), new Vector3(this));
|
||||
moveEntity(entityItem, ForgeDirection.getOrientation(getFacing()), Object3D.get(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,10 +227,28 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
lastCalcTime--;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canBePath(World world, Vector3 position)
|
||||
|
||||
private static Vector3 toVec(Object3D obj)
|
||||
{
|
||||
Block block = Block.blocksList[position.getBlockID(world)];
|
||||
return new Vector3(obj.xCoord, obj.yCoord, obj.zCoord);
|
||||
}
|
||||
|
||||
private static ForgeDirection toForge(Object3D obj)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(side.offsetX == obj.xCoord && side.offsetY == obj.yCoord && side.offsetZ == obj.zCoord)
|
||||
{
|
||||
return side;
|
||||
}
|
||||
}
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static boolean canBePath(World world, Object3D position)
|
||||
{
|
||||
Block block = Block.blocksList[position.getBlockId(world)];
|
||||
return block == null || (block instanceof BlockSnow || block instanceof BlockVine || block instanceof BlockLadder || ((block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockID != Block.lavaMoving.blockID && block.blockID != Block.lavaStill.blockID));
|
||||
}
|
||||
|
||||
|
@ -255,12 +257,12 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
return linked != null && !linked.isInvalid() && linked.linked == this;
|
||||
}
|
||||
|
||||
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Vector3 lockVector)
|
||||
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Object3D lockVector)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case DOWN:
|
||||
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, entityItem.posY, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
@ -275,8 +277,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
break;
|
||||
case UP:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, entityItem.posY, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
@ -291,8 +292,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
break;
|
||||
case NORTH:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, lockVector.yCoord + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
@ -307,8 +307,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
break;
|
||||
case SOUTH:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, lockVector.yCoord + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
@ -323,8 +322,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
break;
|
||||
case WEST:
|
||||
|
||||
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
|
||||
entityItem.setPosition(entityItem.posX, lockVector.yCoord + 0.5, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
@ -339,7 +337,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
break;
|
||||
case EAST:
|
||||
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
|
||||
entityItem.setPosition(entityItem.posX, lockVector.yCoord + 0.5, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
@ -367,7 +365,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
{
|
||||
EntityItem item = null;
|
||||
|
||||
switch (getFacing())
|
||||
switch(ForgeDirection.getOrientation(getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.2, zCoord + 0.5, toSend);
|
||||
|
@ -398,20 +396,9 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Object3D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBounds()
|
||||
{
|
||||
switch (getFacing())
|
||||
switch(ForgeDirection.getOrientation(getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord - MAX_REACH, 1), zCoord, xCoord + 1, yCoord, zCoord + 1);
|
||||
|
@ -449,7 +436,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
public TileEntity getLatched()
|
||||
{
|
||||
ForgeDirection side = getFacing().getOpposite();
|
||||
ForgeDirection side = ForgeDirection.getOrientation(getFacing()).getOpposite();
|
||||
|
||||
TileEntity tile = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
|
||||
|
||||
|
@ -463,25 +450,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
|
||||
public void incrementFacing()
|
||||
{
|
||||
int newOrdinal = getFacing().ordinal() < 5 ? getFacing().ordinal() + 1 : 0;
|
||||
setFacing(ForgeDirection.getOrientation(newOrdinal));
|
||||
}
|
||||
|
||||
public ForgeDirection getFacing()
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
|
||||
public void setFacing(ForgeDirection side)
|
||||
{
|
||||
facing = side;
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
}
|
||||
|
||||
updateBounds();
|
||||
setFacing((short)(facing == 5 ? 0 : facing+1));
|
||||
}
|
||||
|
||||
public boolean canFunction()
|
||||
|
@ -490,45 +459,44 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
facing = ForgeDirection.getOrientation(nbt.getInteger("facing"));
|
||||
suck = nbt.getBoolean("suck");
|
||||
dyeID = nbt.getInteger("dyeID");
|
||||
suck = nbtTags.getBoolean("suck");
|
||||
dyeID = nbtTags.getInteger("dyeID");
|
||||
|
||||
if(nbt.hasKey("link"))
|
||||
if(nbtTags.hasKey("link"))
|
||||
{
|
||||
tempLinkVector = new Vector3(nbt.getCompoundTag("link"));
|
||||
tempLinkVector = Object3D.read(nbtTags.getCompoundTag("link"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbt.setInteger("facing", facing.ordinal());
|
||||
nbt.setBoolean("suck", suck);
|
||||
nbt.setInteger("dyeID", dyeID);
|
||||
nbtTags.setBoolean("suck", suck);
|
||||
nbtTags.setInteger("dyeID", dyeID);
|
||||
|
||||
if(linked != null)
|
||||
{
|
||||
nbt.setCompoundTag("link", new Vector3(linked).writeToNBT(new NBTTagCompound()));
|
||||
nbtTags.setCompoundTag("link", Object3D.get(linked).write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput input)
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
facing = ForgeDirection.getOrientation(input.readInt());
|
||||
suck = input.readBoolean();
|
||||
dyeID = input.readInt();
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
suck = dataStream.readBoolean();
|
||||
dyeID = dataStream.readInt();
|
||||
|
||||
if(input.readBoolean())
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
tempLinkVector = new Vector3(input.readInt(), input.readInt(), input.readInt());
|
||||
tempLinkVector = new Object3D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
}
|
||||
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
|
@ -538,7 +506,8 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(facing.ordinal());
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(suck);
|
||||
data.add(dyeID);
|
||||
|
||||
|
@ -583,10 +552,10 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
|||
{
|
||||
pathfinder = null;
|
||||
|
||||
Vector3 start = new Vector3(this).modifyPositionFromSide(getFacing());
|
||||
Vector3 target = new Vector3(linked).modifyPositionFromSide(linked.getFacing());
|
||||
Object3D start = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(getFacing()));
|
||||
Object3D target = Object3D.get(linked).getFromSide(ForgeDirection.getOrientation(linked.getFacing()));
|
||||
|
||||
if(start.distance(target) < MekanismInduction.MAX_CONTRACTOR_DISTANCE)
|
||||
if(start.distanceTo(target) < MekanismInduction.MAX_CONTRACTOR_DISTANCE)
|
||||
{
|
||||
if(TileEntityEMContractor.canBePath(worldObj, start) && TileEntityEMContractor.canBePath(worldObj, target))
|
||||
{
|
||||
|
|
BIN
resources/assets/mekanism/gui/GuiChemicalFormulator.png
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
resources/assets/mekanism/gui/GuiChemicalInfuser.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
resources/assets/mekanism/gui/GuiDictionary.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
|
@ -22,6 +22,9 @@ item.TeleportationCore.name=Teleportationskern
|
|||
item.Configurator.name=Konfigurator
|
||||
item.NetworkReader.name=Netzwerklesegerät
|
||||
item.WalkieTalkie.name=Walkie-Talkie
|
||||
item.Jetpack.name=Jetpack
|
||||
item.ScubaTank.name=Taucherflasche
|
||||
item.GasMask.name=Gasmaske
|
||||
|
||||
//Gas Tank
|
||||
tile.GasTank.GasTank.name=Gastank
|
||||
|
@ -242,6 +245,28 @@ tooltip.configurator.noLink=Kein Link
|
|||
tooltip.configurator.linkMsg=Verbunden mit
|
||||
tooltip.configurator.dim=Dimension
|
||||
|
||||
tooltip.jetpack.regular=Regulär
|
||||
tooltip.jetpack.hover=Schweben
|
||||
tooltip.jetpack.disabled=Deaktiviert
|
||||
|
||||
tooltip.EnrichmentChamber=Eine einfache Maschine, genutzt, um Erze zu !nzwei ihrer entsprechenden Stäube anzureichern !nsowie viele andere Operationen auszuführen.
|
||||
tooltip.OsmiumCompressor=Eine ziemlich fortschrittliche Maschine, genutzt, !num Osmium in verschiedene Stäube zu pressen, !num ihre entsprechenden Barren zu kreieren.
|
||||
tooltip.Combiner=Eine Maschine, genutzt, um Stäube mit Pflasterstein !nzu kombinieren, um entsprechende Erze zu formen.
|
||||
tooltip.Crusher=Eine Maschine, genutzt, um Barren in ihre entsprechenden !nStäube zu zerstoßen sowie viele andere Operationen auszuführen.
|
||||
tooltip.DigitalMiner=Ein äußerst fortschrittlicher, Filter-basierter !nAuto-Minierer, der alles abbauen kann, was du willst, !ninnerhalb eines Radius von 32 Blöcken (max).
|
||||
tooltip.BasicFactory=Die niedrigste Stufe in der Reihe der Fabriken, !nwelche genutzt werden kann, um mehrere !nMaschinenoperationen auf einmal auszuführen.
|
||||
tooltip.AdvancedFactory=Die mittlere Stufe in der Reihe der Fabriken, !nwelche genutzt werden kann, um mehrere !nMaschinenoperationen auf einmal auszuführen.
|
||||
tooltip.EliteFactory=Die höchste Stufe in der Reihe der Fabriken, !nwelche genutzt werden kann, um mehrere !nMaschinenoperationen auf einmal auszuführen.
|
||||
tooltip.MetallurgicInfuser=Eine Maschine, genutzt, um verschiedene Materialien !n(generell) in Metalle einzuflößen, um Legierungen !nund andere Komponenten zu kreieren.
|
||||
tooltip.PurificationChamber=Eine fortgeschrittene Maschine, fähig, Erze zu !ndrei Klumpen zu verarbeiten, was im Anfangsstadium !n300% an Erzverarbeitung bietet.
|
||||
tooltip.EnergizedSmelter=Eine einfache Maschine, die einen Mekanism-basierten !nOfen bietet, der mit Energie läuft.
|
||||
tooltip.Teleporter=Eine Maschine, fähig, Spieler zu verschiedenen Orten, !ndefiniert durch andere Teleporter, zu teleportieren.
|
||||
tooltip.ElectricPump=Eine fortgeschrittene Pumpe, fähig, !nganze Lavaseen auszupumpen.
|
||||
tooltip.ElectricChest=Eine Tragbare, 54-Slot-Truhe, die Energie nutzt, !num sich selbst zu sperren, per Passwortschutz.
|
||||
tooltip.Chargepad=Ein universelles Ladepad, dass jegliches energetisiertes !nItem jeglicher Mods aufladen kann.
|
||||
tooltip.LogisticalSorter=Eine Filter-basierte, fortgeschrittene Sortiermaschine, die !nautomatisch spezifische Items aus einem Inventar oder !nLogistischen Transporter heraus und in eines hinein treiben kann.
|
||||
tooltip.RotaryCondensentrator=Eine Maschine, die fähig ist, Gase in ihre !nflüssige Form zu konvertieren und umgekehrt.
|
||||
|
||||
//Redstone control
|
||||
control.disabled=Deaktiviert
|
||||
control.high=High
|
||||
|
@ -289,6 +314,12 @@ tile.Generator.BioGenerator.name=Bio-Generator
|
|||
tile.Generator.AdvancedSolarGenerator.name=Fortgeschrittener Solargenerator
|
||||
tile.Generator.WindTurbine.name=Windturbine
|
||||
|
||||
//Gui text
|
||||
gui.heatGenerator.fuel=Brennstoff
|
||||
gui.solarGenerator.sun=Sonne
|
||||
gui.bioGenerator.bioFuel=Biobrennstoff
|
||||
gui.electrolyticSeparator.dump=Entsorge
|
||||
|
||||
//*****//
|
||||
//TOOLS//
|
||||
//*****//
|
||||
|
@ -385,9 +416,3 @@ tile.Battery.name=Modulare Batterie
|
|||
//General text
|
||||
text.contractor.success=Kontraktor erfolgreich verbunden
|
||||
text.tesla.success=Teslaspule erfolgreich verbunden
|
||||
|
||||
//Gui text
|
||||
gui.heatGenerator.fuel=Brennstoff
|
||||
gui.solarGenerator.sun=Sonne
|
||||
gui.bioGenerator.bioFuel=Biobrennstoff
|
||||
gui.electrolyticSeparator.dump=Entsorge
|
||||
|
|
|
@ -23,6 +23,9 @@ item.Configurator.name=Configurator
|
|||
item.NetworkReader.name=Network Reader
|
||||
item.WalkieTalkie.name=Walkie-Talkie
|
||||
item.Jetpack.name=Jetpack
|
||||
item.ScubaTank.name=Scuba Tank
|
||||
item.GasMask.name=Gas Mask
|
||||
item.Dictionary.name=Dictionary
|
||||
|
||||
//Gas Tank
|
||||
tile.GasTank.GasTank.name=Gas Tank
|
||||
|
@ -63,6 +66,8 @@ tile.MachineBlock.DigitalMiner.name=Digital Miner
|
|||
|
||||
//Machine Block 2 (second ID iteration)
|
||||
tile.MachineBlock2.RotaryCondensentrator.name=Rotary Condensentrator
|
||||
tile.MachineBlock2.ChemicalFormulator.name=Chemical Formulator
|
||||
tile.MachineBlock2.ChemicalInfuser.name=Chemical Infuser
|
||||
|
||||
//Ore Block
|
||||
tile.OreBlock.OsmiumOre.name=Osmium Ore
|
||||
|
@ -93,6 +98,7 @@ item.steelDust.name=Steel Dust
|
|||
item.copperDust.name=Copper Dust
|
||||
item.tinDust.name=Tin Dust
|
||||
item.silverDust.name=Silver Dust
|
||||
item.leadDust.name=Lead Dust
|
||||
|
||||
//Clumps
|
||||
item.ironClump.name=Iron Clump
|
||||
|
@ -102,6 +108,7 @@ item.copperClump.name=Copper Clump
|
|||
item.tinClump.name=Tin Clump
|
||||
item.silverClump.name=Silver Clump
|
||||
item.obsidianClump.name=Obsidian Clump
|
||||
item.leadClump.name=Lead Clump
|
||||
|
||||
//Dirty Dust
|
||||
item.dirtyIronDust.name=Dirty Iron Dust
|
||||
|
@ -111,6 +118,7 @@ item.dirtyCopperDust.name=Dirty Copper Dust
|
|||
item.dirtyTinDust.name=Dirty Tin Dust
|
||||
item.dirtySilverDust.name=Dirty Silver Dust
|
||||
item.dirtyObsidianDust.name=Dirty Obsidian Dust
|
||||
item.dirtyLeadDust.name=Dirty Lead Dust
|
||||
|
||||
//Ingots
|
||||
item.obsidianIngot.name=Obsidian Ingot
|
||||
|
@ -124,10 +132,14 @@ item.tinIngot.name=Tin Ingot
|
|||
//Gasses
|
||||
gas.hydrogen=Hydrogen
|
||||
gas.oxygen=Oxygen
|
||||
gas.sulfuricGas=Sulfuric Gas
|
||||
gas.sulfuricAcid=Sulfuric Acid
|
||||
|
||||
//Fluids
|
||||
fluid.hydrogen=Liquid Hydrogen
|
||||
fluid.oxygen=Liquid Oxygen
|
||||
fluid.sulfuricGas=Sulfuric Gas
|
||||
fluid.sulfuricAcid=Sulfuric Acid
|
||||
|
||||
//Gui text
|
||||
gui.removeSpeedUpgrade=Remove speed upgrade
|
||||
|
@ -161,6 +173,9 @@ gui.input=Input
|
|||
gui.slots=Slots
|
||||
gui.state=State
|
||||
|
||||
gui.dictionary.noKey=No key.
|
||||
gui.dictionary.key=Key
|
||||
|
||||
gui.configuration=Configuration
|
||||
gui.configuration.strictInput=Strict Input
|
||||
|
||||
|
@ -247,6 +262,24 @@ tooltip.jetpack.regular=Regular
|
|||
tooltip.jetpack.hover=Hover
|
||||
tooltip.jetpack.disabled=Disabled
|
||||
|
||||
tooltip.EnrichmentChamber=A simple machine used to enrich ores into !ntwo of their dust counterparts, as well as !nperform many other operations.
|
||||
tooltip.OsmiumCompressor=A fairly advanced machine used to compress !nosmium into various dusts in order to create !ntheir ingot counterparts.
|
||||
tooltip.Combiner=A machine used to combine dusts and cobblestone to !nform their ore counterparts.
|
||||
tooltip.Crusher=A machine used to crush ingots into their dust counterparts, !nas well as perform many other operations.
|
||||
tooltip.DigitalMiner=A highly-advanced, filter-based, auto-miner that can !nmine whatever block you tell it to within !na 32 block (max) radius.
|
||||
tooltip.BasicFactory=The lowest tier of the line of Factories, which can !nbe used to process multiple machine operations !nat once.
|
||||
tooltip.AdvancedFactory=The middle tier of the line of Factories, which can !nbe used to process multiple machine !noperations at once.
|
||||
tooltip.EliteFactory=The highest tier of the line of Factories, which can !nbe used to process multiple machine !noperations at once.
|
||||
tooltip.MetallurgicInfuser=A machine used to infuse various materials !ninto (generally) metals to create metal alloys !nand other compounds.
|
||||
tooltip.PurificationChamber=An advanced machine capable of processing !nores into three clumps, serving as the initial !nstage of 300% ore processing.
|
||||
tooltip.EnergizedSmelter=A simple machine that serves as a Mekanism-based !nfurnace that runs off of energy.
|
||||
tooltip.Teleporter=A machine capable of teleporting players to various !nlocations defined by another teleporter.
|
||||
tooltip.ElectricPump=An advanced pump capable of pumping out an entire !nlava lake.
|
||||
tooltip.ElectricChest=A portable, 54-slot chest that uses energy to lock !nitself from others by means of password protection.
|
||||
tooltip.Chargepad=A universal chargepad that can charge any energized item !nfrom any mod.
|
||||
tooltip.LogisticalSorter=A filter-based, advanced sorting machine that !ncan auto-eject specified items out of and into !nadjacent inventories and Logistical Transporters.
|
||||
tooltip.RotaryCondensentrator=A machine capable of converting gasses into !ntheir fluid form and vice versa.
|
||||
|
||||
//Redstone control
|
||||
control.disabled=Disabled
|
||||
control.high=High
|
||||
|
|
BIN
resources/assets/mekanism/sound/etc/GasMask.ogg
Normal file
BIN
resources/assets/mekanism/textures/blocks/LiquidSulfuricAcid.png
Normal file
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 2
|
||||
}
|
||||
}
|
BIN
resources/assets/mekanism/textures/blocks/LiquidSulfuricGas.png
Normal file
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 2
|
||||
}
|
||||
}
|
BIN
resources/assets/mekanism/textures/items/Dictionary.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
resources/assets/mekanism/textures/items/DirtyLeadDust.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
resources/assets/mekanism/textures/items/LeadClump.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
resources/assets/mekanism/textures/items/LeadDust.png
Normal file
After Width: | Height: | Size: 1.4 KiB |