diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-02-12 20:43:03 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-02-12 20:43:03 +0300 |
| commit | 5cb4c6e24033cf337812390d99a6817d24d21eab (patch) | |
| tree | 695789855920199efd4702a7bb3e4bacfe58b9f0 /ihl/crop_harvestors | |
| parent | 8f22398517206aed21a7fd840f463332429fae35 (diff) | |
Removed explosion radius limitations. Explosion calculation optimized (reduced memory usage). One more detonator and explosive pack recipe. GT6 recipes for both chemical reactors and cryogenic distiller. Max stack size of muffle furnace is limited to 32. A lot of old features are removed.
Diffstat (limited to 'ihl/crop_harvestors')
| -rw-r--r-- | ihl/crop_harvestors/BlowerBlock.java | 169 | ||||
| -rw-r--r-- | ihl/crop_harvestors/BlowerContainer.java | 89 | ||||
| -rw-r--r-- | ihl/crop_harvestors/BlowerGui.java | 58 | ||||
| -rw-r--r-- | ihl/crop_harvestors/BlowerTileEntity.java | 1065 |
4 files changed, 0 insertions, 1381 deletions
diff --git a/ihl/crop_harvestors/BlowerBlock.java b/ihl/crop_harvestors/BlowerBlock.java deleted file mode 100644 index 3ec49b7..0000000 --- a/ihl/crop_harvestors/BlowerBlock.java +++ /dev/null @@ -1,169 +0,0 @@ -package ihl.crop_harvestors;
-
-import java.util.Random;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.item.IC2Items;
-import ihl.IHLCreativeTab;
-import ihl.IHLModInfo;
-import ihl.utils.IHLUtils;
-import net.minecraft.block.Block;
-import net.minecraft.block.ITileEntityProvider;
-import net.minecraft.block.material.Material;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.IIcon;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
-public class BlowerBlock extends Block implements ITileEntityProvider{
-
- IIcon textureLeft, textureRight, textureBack;
-
- public BlowerBlock(Material material)
- {
- super(material);
- this.setCreativeTab(IHLCreativeTab.tab);
- }
-
- @Override
- public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
- {
- return IC2Items.getItem("machine").getItem();
- }
-
- @Override
- public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
- {
- TileEntity te = world.getTileEntity(x,y,z);
- if(te instanceof BlowerTileEntity)
- {
- BlowerTileEntity bte = (BlowerTileEntity)te;
- bte.updateChecksum=-1;
- }
- }
-
- @Override
- public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
- {
- }
-
- @Override
- public TileEntity createNewTileEntity(World world, int var2) {
- return new BlowerTileEntity();
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister par1IconRegister)
- {
- this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerFront");
- this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerBack");
- this.textureLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerLeft");
- this.textureRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerRight");
- }
-
- @Override
- public boolean hasTileEntity(int metadata)
- {
- return true;
- }
-
- @Override
- public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
- TileEntity te = world.getTileEntity(x,y,z);
- if(te instanceof BlowerTileEntity)
- {
- BlowerTileEntity bte = (BlowerTileEntity)te;
- if (bte == null || entityPlayer.isSneaking()) {
- return false;
- }
- else
- {
- return bte.getGui(entityPlayer);
- }
- }
- return false;
- }
-
- /**
- * Called when the block is placed in the world.
- */
- @Override
- public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
- {
- TileEntity t = world.getTileEntity(x, y, z);
- if(t!=null && t instanceof BlowerTileEntity)
- {
- ((BlowerTileEntity)t).setFacing(IHLUtils.getFacingFromPlayerView(player, false));
- }
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
- {
- int facing=3;
- int mask[] = {
- 0,1,2,3,4,5,
- 1,0,3,2,4,5,
- 3,2,0,1,4,5,
- 2,3,1,0,4,5,
- 2,3,5,4,0,1,
- 2,3,4,5,1,0
- };
- TileEntity te = world.getTileEntity(x, y, z);
- if(te!=null)
- {
- BlowerTileEntity tebh = (BlowerTileEntity) te;
- facing=tebh.getFacing();
- }
-
- switch (mask[facing*6+side])
- {
- case 0:
- return this.blockIcon;
- case 1:
- return this.textureBack;
- case 2:
- return this.textureBack;
- case 3:
- return this.textureBack;
- case 4:
- return this.textureLeft;
- case 5:
- return this.textureRight;
- default:
- return this.textureLeft;
- }
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int meta)
- {
- switch (side)
- {
- case 0:
- return this.blockIcon;
- case 1:
- return this.textureBack;
- case 2:
- return this.textureLeft;
- case 3:
- return this.textureRight;
- case 4:
- return this.textureBack;
- case 5:
- return this.textureBack;
- default:
- return this.textureLeft;
- }
- }
-
-}
diff --git a/ihl/crop_harvestors/BlowerContainer.java b/ihl/crop_harvestors/BlowerContainer.java deleted file mode 100644 index 2a64488..0000000 --- a/ihl/crop_harvestors/BlowerContainer.java +++ /dev/null @@ -1,89 +0,0 @@ -package ihl.crop_harvestors;
-
-import ic2.core.ContainerBase;
-import ic2.core.slot.SlotInvSlot;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ICrafting;
-import net.minecraft.inventory.Slot;
-
-public class BlowerContainer extends ContainerBase<BlowerTileEntity> {
-
- protected BlowerTileEntity tileEntity;
- public int lastStorage = -1;
- public int lastAirSpeed = -1;
- private final static int height=166;
-
- public BlowerContainer(EntityPlayer entityPlayer, BlowerTileEntity tileEntity1){
- super(tileEntity1);
- this.tileEntity = tileEntity1;
- int col;
-
- for (col = 0; col < 3; ++col)
- {
- for (int col1 = 0; col1 < 9; ++col1)
- {
- this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18));
- }
- }
-
- for (col = 0; col < 9; ++col)
- {
- this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24));
- }
-
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 26, 26));
- for(int row=0;row<=3;row++)
- {
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18));
- }
- }
-
- @Override
- public void detectAndSendChanges()
- {
- super.detectAndSendChanges();
- for (int i = 0; i < this.crafters.size(); ++i)
- {
- ICrafting icrafting = (ICrafting)this.crafters.get(i);
-
- if (this.tileEntity.getStored() != this.lastStorage)
- {
- icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE);
- icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE));
-
- }
-
- if (this.tileEntity.airSpeedBase != this.lastAirSpeed)
- {
- icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.airSpeedBase);
- }
- }
-
- this.lastStorage = this.tileEntity.getStored();
- this.lastAirSpeed = this.tileEntity.airSpeedBase;
- }
-
- @Override
- public void updateProgressBar(int index, int value)
- {
- super.updateProgressBar(index, value);
-
- switch (index)
- {
- case 0:
- this.tileEntity.setStored(value<<15);
- break;
- case 1:
- this.tileEntity.setStored(this.tileEntity.getStored()+value);
- break;
- case 2:
- this.tileEntity.airSpeedBase=value;
- break;
- }
- }
-
- @Override
- public boolean canInteractWith(EntityPlayer var1) {
- return tileEntity.isUseableByPlayer(var1);
- }
-}
diff --git a/ihl/crop_harvestors/BlowerGui.java b/ihl/crop_harvestors/BlowerGui.java deleted file mode 100644 index bedee1f..0000000 --- a/ihl/crop_harvestors/BlowerGui.java +++ /dev/null @@ -1,58 +0,0 @@ -package ihl.crop_harvestors;
-
-import cpw.mods.fml.relauncher.Side;
-
-import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.StatCollector;
-
-import org.lwjgl.opengl.GL11;
-
-@SideOnly(Side.CLIENT)
-public class BlowerGui extends GuiContainer {
- private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIBlower.png");
- private BlowerContainer container;
-
- public BlowerGui (BlowerContainer container1) {
- //the container is instanciated and passed to the superclass for handling
- super(container1);
- this.container=container1;
- }
-
- @Override
- protected void drawGuiContainerForegroundLayer(int param1, int param2) {
- //the parameters for drawString are: string, x, y, color
- String title = StatCollector.translateToLocal("tile.blowerBlock.name");
- fontRendererObj.drawStringWithShadow(title, 8, 8, 16767839);
- String airspeed = StatCollector.translateToLocal("ihl.gui.blower");
- String units = StatCollector.translateToLocal("ihl.gui.blowerUnits");
- fontRendererObj.drawString(airspeed, 8, 60, 852037);
- float e = container.tileEntity.getActive()?container.tileEntity.airSpeedBase/10F:0F;
- String eStr = String.valueOf(e);
- int w = this.fontRendererObj.getStringWidth(eStr);
- fontRendererObj.drawString(eStr, 60-w, 71, 16767839);
- fontRendererObj.drawString(units, 62, 71, 852037);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.renderEngine.bindTexture(background);
- //charge
- if (this.container.tileEntity.getStored() > 0)
- {
- int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13);
- this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel);
- }
-
-
- }
-
- @Override
- protected void drawGuiContainerBackgroundLayer(float par1, int par2,
- int par3) {
- //draw your Gui here, only thing you need to change is the path
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.renderEngine.bindTexture(background);
- int x = (width - xSize) / 2;
- int y = (height - ySize) / 2;
- this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
- }
-}
\ No newline at end of file diff --git a/ihl/crop_harvestors/BlowerTileEntity.java b/ihl/crop_harvestors/BlowerTileEntity.java deleted file mode 100644 index e26632b..0000000 --- a/ihl/crop_harvestors/BlowerTileEntity.java +++ /dev/null @@ -1,1065 +0,0 @@ -package ihl.crop_harvestors;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-import net.minecraft.block.Block;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.util.ForgeDirection;
-import ic2.api.energy.event.EnergyTileLoadEvent;
-import ic2.api.energy.event.EnergyTileUnloadEvent;
-import ic2.api.energy.tile.IEnergySink;
-import ic2.api.item.IC2Items;
-import ic2.core.ContainerBase;
-import ic2.core.IC2;
-import ic2.core.IHasGui;
-import ic2.core.audio.AudioSource;
-import ic2.core.audio.PositionSpec;
-import ic2.core.block.TileEntityInventory;
-import ic2.core.block.invslot.InvSlot;
-import ic2.core.block.invslot.InvSlotUpgrade;
-import ic2.core.block.invslot.InvSlot.Access;
-import ic2.core.upgrade.IUpgradableBlock;
-import ic2.core.upgrade.UpgradableProperty;
-import ihl.IHLMod;
-import ihl.utils.IHLInvSlotDischarge;
-
-public class BlowerTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, IUpgradableBlock
-{
- private int startUpCounter=0;
- private int tier=1;
- private int defaultTier=1;
- public int maxStorage=100;
- private int defaultMaxStorage=100;
- private double energy=0D;
- private double defaultEnergyConsume=5D;
- private double energyConsume=5D;
- private int defaultAirSpeedBase=100;
- public int airSpeedBase=100;
- private int sCAFCount=0;
- public boolean addedToEnergyNet = false;
- private ArrayList<AirSpeedZone> aszlist = new ArrayList<AirSpeedZone>();
- public final InvSlotUpgrade upgradeSlot;
- public final IHLInvSlotDischarge dischargeSlot;
- public int updateChecksum=-1;
- private final float lambda=0.00001F;
- public int operationRange=-1;
- public int lastOperationRange=0;
-
- private AudioSource startAS;
- private AudioSource loopAS;
- private AudioSource stopAS;
-
- public BlowerTileEntity()
- {
- this.defaultTier=IHLMod.config.blowerTier;
- this.defaultMaxStorage=IHLMod.config.blowerMaxEnergyStorage;
- this.defaultEnergyConsume=IHLMod.config.blowerEnergyConsumePerTick;
- this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 2, 4);
- this.dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM);
- }
-
- @Override
- public List<String> getNetworkedFields()
- {
- List<String> fields = super.getNetworkedFields();
- fields.add("tier");
- fields.add("airSpeedBase");
- fields.add("maxStorage");
- return fields;
- }
-
- @Override
- public void readFromNBT(NBTTagCompound nbttagcompound)
- {
- super.readFromNBT(nbttagcompound);
- try
- {
- this.energy = nbttagcompound.getDouble("energy");
- }
- catch (Exception var3)
- {
- this.energy = nbttagcompound.getInteger("energy");
-
- if (this.maxStorage > Integer.MAX_VALUE)
- {
- this.energy *= 10.0D;
- }
- }
- }
-
- @Override
- public void writeToNBT(NBTTagCompound nbttagcompound)
- {
- super.writeToNBT(nbttagcompound);
- nbttagcompound.setDouble("energy", this.energy);
- }
-
- @Override
- public void onLoaded()
- {
- super.onLoaded();
- if (IC2.platform.isSimulating())
- {
- MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
- this.addedToEnergyNet = true;
- }
- if (IC2.platform.isRendering() && (this.startAS==null||this.loopAS==null||this.stopAS==null))
- {
- this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 1F);
- this.loopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getLoopSoundFile(),true,false, 1F);
- this.stopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStopSoundFile(),false,false, 1F);
- }
- }
-
- @Override
- public void onUnloaded()
- {
- if (IC2.platform.isRendering() && this.loopAS != null)
- {
- this.startAS.stop();
- this.loopAS.stop();
- this.stopAS.stop();
- this.startAS = null;
- this.loopAS = null;
- this.stopAS = null;
- IC2.audioManager.removeSources(this);
- }
-
- if (IC2.platform.isSimulating() && this.addedToEnergyNet)
- {
- MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
- this.addedToEnergyNet = false;
- }
- super.onUnloaded();
- }
-
- @Override
- public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
- return this.getFacing()!=(short)side;
- }
-
- @Override
- public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
- if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get()));
- if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
- if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
- if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
- if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
- return new ItemStack(IHLMod.blowerBlock,1);
- }
-
- @Override
- public void setFacing(short facing1)
- {
- super.setFacing(facing1);
- this.updateChecksum=-1;
- }
-
- public boolean enableUpdateEntity()
- {
- return true;
- }
-
- public String getStartSoundFile()
- {
- return "Machines/IHL Industrial Fan/start.ogg";
- }
-
- public String getLoopSoundFile()
- {
- return "Machines/IHL Industrial Fan/loop.ogg";
- }
-
- public String getStopSoundFile()
- {
- return "Machines/IHL Industrial Fan/stop.ogg";
- }
-
- @Override
- public void updateEntityClient()
- {
- this.updateBoth();
- if(IC2.platform.isRendering() && this.loopAS!=null)
- {
- if(this.getActive())
- {
- if(this.startUpCounter>12)
- {
- this.startUpCounter=0;
- }
- if(this.startUpCounter==0)
- {
- this.stopAS.stop();
- this.startAS.play();
- }
- if(this.startUpCounter<10)
- {
- this.startUpCounter++;
- }
- else if(this.startUpCounter==10)
- {
- this.startAS.stop();
- this.loopAS.play();
- this.startUpCounter++;
- }
- }
- else if(this.startUpCounter>0)
- {
- this.startAS.stop();
- this.loopAS.stop();
- this.stopAS.play();
- if(this.startUpCounter<170)
- {
- this.startUpCounter++;
- }
- else
- {
- this.startUpCounter=0;
- this.stopAS.stop();
- }
- }
- }
- else if(IC2.platform.isRendering() && !this.getActive() && this.loopAS!=null)
- {
- this.loopAS.stop();
- }
- }
-
- public void updateBoth()
- {
- if(this.dischargeSlot.tier!=this.tier)
- {
- this.dischargeSlot.tier=this.tier;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public void updateEntityServer()
- {
-
- if (IC2.platform.isSimulating())
- {
- this.setOverclockRates();
- }
- this.updateBoth();
- if(this.getDemandedEnergy() > 1.0D)
- {
- double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false);
- this.energy += amount;
- }
- if(this.energy>this.maxStorage)
- {
- this.energy=this.maxStorage;
- }
- if(IC2.platform.isSimulating()&&!this.getActive()&&this.energy>=this.energyConsume*2D)
- {
- this.setActive(true);
- }
- else if(IC2.platform.isSimulating()&&this.getActive()&&this.energy<this.energyConsume)
- {
- this.setActive(false);
- }
- if(!this.aszlist.isEmpty() && this.getActive())
- {
- if(this.energy>=this.energyConsume)this.energy-=this.energyConsume;
- Iterator<AirSpeedZone> it = this.aszlist.iterator();
- a:while(it.hasNext())
- {
- AirSpeedZone asz = it.next();
- List<Entity> entityList = worldObj.getEntitiesWithinAABB(Entity.class, asz.getAABB());
- if(!entityList.isEmpty())
- {
- if(this.sCAFCount<=0)
- {
- this.aszlist.clear();
- this.calculateAirSpeed();
- this.sCAFCount=40;
- break a;
- }
- Iterator<Entity> ei = entityList.iterator();
- while(ei.hasNext())
- {
- Entity ent = ei.next();
- if(asz.isEntityMoveable(ent))
- {
- if(ent instanceof EntityPlayer)
- {
- if(worldObj.isRemote)
- {
- ent.addVelocity(mX()*0.1D, mY()*0.05D, mZ()*0.1D);
- }
- }
- else
- {
- ent.addVelocity(mX()*0.1D, mY()*0.05D, mZ()*0.1D);
- }
- }
- }
- }
- }
-
- }
- if(this.sCAFCount>0)
- {
- this.sCAFCount--;
- }
- else
- {
- this.calculateAirSpeed();
- if(this.operationRange==this.lastOperationRange)
- {
- this.sCAFCount=600;
- }
- else
- {
- this.sCAFCount=20;
- this.lastOperationRange=this.operationRange;
- }
- }
-
-
- }
-
- private void calculateAirSpeed()
- {
- int x=xCoord;
- int y=yCoord;
- int z=zCoord;
- int airSpeed=airSpeedBase;
- int x0,y0,z0;
- x0=x;
- y0=y;
- z0=z;
- int flowExtL=0;
- int flowExtR=0;
- int flowExtT=0;
- int flowExtB=0;
- int flowCanBeExtL=0;
- int flowCanBeExtR=0;
- int flowCanBeExtT=0;
- int flowCanBeExtB=0;
-
- int checkFlowL=0;
- int checkFlowR=0;
- int checkFlowT=0;
- int checkFlowB=0;
-
- checkFlowL = Math.max(
- this.neighborBlowerOperationRange(this.xCoord+mXL()+mX(), this.yCoord+mYL()+mY(),this.zCoord+mZL()+mZ()),
- this.neighborBlowerOperationRange(this.xCoord+mXL()-mX(), this.yCoord+mYL()-mY(), this.zCoord+mZL()-mZ())
- );
- checkFlowR = Math.max(
- this.neighborBlowerOperationRange(this.xCoord-mXL()+mX(), this.yCoord-mYL()+mY(),this.zCoord-mZL()+mZ()),
- this.neighborBlowerOperationRange(this.xCoord-mXL()-mX(), this.yCoord-mYL()-mY(), this.zCoord-mZL()-mZ())
- );
- checkFlowT = Math.max(Math.max(
- this.neighborBlowerOperationRange(this.xCoord+mXT()+mX(), this.yCoord+mYT()+mY(),this.zCoord+mZT()+mZ()),
- this.neighborBlowerOperationRange(this.xCoord+mXT()-mX(), this.yCoord+mYT()-mY(), this.zCoord+mZT()-mZ())
- ),
- this.neighborBlowerOperationRange(this.xCoord+mXT(), this.yCoord+mYT(),this.zCoord+mZT()));
- checkFlowB = Math.max(Math.max(
- this.neighborBlowerOperationRange(this.xCoord-mXT()+mX(), this.yCoord-mYT()+mY(),this.zCoord-mZT()+mZ()),
- this.neighborBlowerOperationRange(this.xCoord-mXT()-mX(), this.yCoord-mYT()-mY(), this.zCoord-mZT()-mZ())
- ),
- this.neighborBlowerOperationRange(this.xCoord-mXT(), this.yCoord-mYT(),this.zCoord-mZT()));
- int asg = this.getAirSpeedGrade(airSpeed);
- a:for(int step=0;step<256;step++)
- {
- x+=mX();
- y+=mY();
- z+=mZ();
- airSpeed-=Math.round(lambda*(airSpeed*airSpeed))+1;
- asg = this.getAirSpeedGrade(airSpeed);
- if(asg==0)
- {
- break;
- }
- int i1,i2,il,ir,it,ib;
- i1=0;i2=0;il=0;ir=0;it=0;ib=0;
- for(int tb=-flowExtB;tb<=flowExtT;tb++)
- {
- i1++;
- if(this.isAirPassable(x+mXL()*(flowExtL+1)+mXT()*tb,y+mYL()*(flowExtL+1)+mYT()*tb,z+mZL()*(flowExtL+1)+mZT()*tb))
- {
- il++;
- }
- if(this.isAirPassable(x-mXL()*(flowExtR+1)+mXT()*tb,y-mYL()*(flowExtR+1)+mYT()*tb,z-mZL()*(flowExtR+1)+mZT()*tb))
- {
- ir++;
- }
- }
- if(i1==il && step>=checkFlowL)
- {
- flowCanBeExtL++;
- }
- if(i1==ir && step>=checkFlowR)
- {
- flowCanBeExtR++;
- }
- for(int lr=-flowExtL;lr<=flowExtR;lr++)
- {
- i2++;
- if(this.isAirPassable(x+mXT()*(flowExtT+1)+mXL()*lr,y+mYT()*(flowExtT+1)+mYL()*lr,z+mZT()*(flowExtT+1)+mZL()*lr))
- {
- it++;
- }
- if(this.isAirPassable(x-mXT()*(flowExtB+1)+mXL()*lr,y-mYT()*(flowExtB+1)+mYL()*lr,z-mZT()*(flowExtB+1)+mZL()*lr))
- {
- ib++;
- }
- }
- if(i2==it && step>=checkFlowT)
- {
- flowCanBeExtT++;
- }
- if(i2==ib && step>=checkFlowB)
- {
- flowCanBeExtB++;
- }
- airSpeed-=Math.round(lambda*(airSpeed*airSpeed)*(il+ir+it+ib))+il+ir+it+ib;
- asg = this.getAirSpeedGrade(airSpeed);
- if(asg==0)
- {
- this.operationRange=step;
- break;
- }
- if(flowCanBeExtB>=4)
- {
- flowCanBeExtB=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtB++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtT>=4)
- {
- flowCanBeExtT=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtT++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtR>=4)
- {
- flowCanBeExtR=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtR++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtL>=3)
- {
- flowCanBeExtL=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtL++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtR>=3)
- {
- flowCanBeExtR=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtR++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtT>=3)
- {
- flowCanBeExtT=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtT++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- else if(flowCanBeExtB>=3)
- {
- flowCanBeExtB=0;
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- flowExtB++;
- int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1);
- airSpeed=airSpeed*s0/s1;
- }
- for(int tb=-flowExtB;tb<=flowExtT;tb++)
- {
- for(int lr=-flowExtR;lr<=flowExtL;lr++)
- {
- if(!this.isAirPassable(x+mXL()*lr+mXT()*tb+mX(),y+mYL()*lr+mYT()*tb+mY(),z+mZL()*lr+mZT()*tb+mZ()))
- {
- if(lr==0 && tb==0)
- {
- //System.out.println("Flow breakened by wall check at step="+step);
- this.operationRange=step;
- break a;
- }
- else
- {
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x-mX()+mXL()*flowExtL+mXT()*flowExtT,
- y-mY()+mYL()*flowExtL+mYT()*flowExtT,
- z-mZ()+mZL()*flowExtL+mZT()*flowExtT));
- x0=x;
- y0=y;
- z0=z;
- if(lr>0)
- {
- flowExtL=lr-1;
- }
- else if(lr<0)
- {
- flowExtR=-1-lr;
- }
- if(tb>0)
- {
- flowExtT=tb-1;
- }
- else if(tb<0)
- {
- flowExtB=-1-tb;
- }
- }
- }
- }
- }
- //System.out.println("Airspeed at step="+step+"equals="+airSpeed);
- }
- if(asg>0)
- {
- this.aszlist.add(new AirSpeedZone(asg,
- x0-mXL()*flowExtR-mXT()*flowExtB,
- y0-mYL()*flowExtR-mYT()*flowExtB,
- z0-mZL()*flowExtR-mZT()*flowExtB,
- x+mXL()*flowExtL+mXT()*flowExtT,
- y+mYL()*flowExtL+mYT()*flowExtT,
- z+mZL()*flowExtL+mZT()*flowExtT));
- }
- }
-
-
- @Override
- public boolean acceptsEnergyFrom(TileEntity emitter,
- ForgeDirection direction) {
- switch(direction)
- {
- case UP:
- return mY()!=1;
- case DOWN:
- return mY()!=-1;
- case NORTH:
- return mZ()!=-1 && mZL()==0;
- case EAST:
- return mX()!=1 && mXL()==0;
- case SOUTH:
- return mZ()!=1 && mZL()==0;
- case WEST:
- return mX()!=-1 && mXL()==0;
- default:
- return false;
- }
- }
-
- private boolean isAirPassable(int x,int y,int z)
- {
- Block block = worldObj.getBlock(x,y,z);
- if(block!=null && !block.isNormalCube(worldObj,x,y,z))
- {
- if(
- !block.isCollidable() ||
- block.isAir(worldObj,x, y, z) ||
- block.getBlockBoundsMinX()>0.15D ||
- block.getBlockBoundsMaxX()<0.85D ||
- block.getBlockBoundsMinY()>0.15D ||
- block.getBlockBoundsMaxY()<0.85D ||
- block.getBlockBoundsMinZ()>0.15D ||
- block.getBlockBoundsMaxZ()<0.85D
- )
- {
- return true;
- }
- else
- {
- AxisAlignedBB cb = block.getCollisionBoundingBoxFromPool(worldObj, x, y, z);
- if(cb!=null)
- {
- if(
- cb.maxX<=1D &&
- cb.maxX>=0D &&
- cb.minX<=1D &&
- cb.minX>=0D &&
- cb.maxY<=1D &&
- cb.maxY>=0D &&
- cb.minY<=1D &&
- cb.minY>=0D &&
- cb.maxZ<=1D &&
- cb.maxZ>=0D &&
- cb.minZ<=1D &&
- cb.minZ>=0D
- )
- {
- if(
- cb.maxX<0.85D||
- cb.minX>0.15D||
- cb.maxY<0.85D||
- cb.minY>0.15D||
- cb.maxZ<0.85D||
- cb.minZ>0.15D
- )
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- private int getAirSpeedGrade(int airSpeed)
- {
- if(airSpeed<30)
- {
- return 0;
- }
- else if(airSpeed<100)
- {
- return 1;
- }
- else if(airSpeed<200)
- {
- return 2;
- }
- else if(airSpeed<300)
- {
- return 3;
- }
- else if(airSpeed<400)
- {
- return 4;
- }
- else if(airSpeed<500)
- {
- return 5;
- }
- else if(airSpeed<600)
- {
- return 6;
- }
- else
- {
- return 7;
- }
- }
-
- private class AirSpeedZone
- {
- private int airSpeedGrade, x0, y0, z0, x1, y1, z1;
- public AirSpeedZone(int airSpeedGrade1, int vx0, int vy0, int vz0, int vx1,int vy1,int vz1)
- {
- this.airSpeedGrade=airSpeedGrade1;
- this.x0=vx0;
- this.y0=vy0;
- this.z0=vz0;
- this.x1=vx1;
- this.y1=vy1;
- this.z1=vz1;
- }
-
- public AxisAlignedBB getAABB()
- {
- return AxisAlignedBB.getBoundingBox(Math.min(x0,x1), Math.min(y0,y1), Math.min(z0,z1), Math.max(x0,x1)+1D, Math.max(y0,y1)+1D, Math.max(z0,z1)+1D);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if(obj instanceof AirSpeedZone)
- {
- AirSpeedZone asz = (AirSpeedZone)obj;
- return (
- this.x0==asz.x0 &&
- this.y0==asz.y0 &&
- this.z0==asz.z0 &&
- this.x1==asz.x1 &&
- this.y1==asz.y1 &&
- this.z1==asz.z1);
- }
- return false;
- }
-
- public boolean isEntityMoveable(Entity entity)
- {
- if(this.airSpeedGrade>=7)
- {
- return true;
- }
- else
- {
- return (entity.width+1F)*(entity.height+1F)<=this.airSpeedGrade*2;
- }
- }
- }
-
- private int mX()
- {
- switch(this.getFacing())
- {
- case 4:
- return -1;
- case 5:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mY()
- {
- switch(this.getFacing())
- {
- case 0:
- return -1;
- case 1:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mZ()
- {
- switch(this.getFacing())
- {
- case 2:
- return -1;
- case 3:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mXL()
- {
- switch(this.getFacing())
- {
- case 0:
- return -1;
- case 1:
- return 1;
- case 2:
- return -1;
- case 3:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mYL()
- {
- return 0;
- }
-
- private int mZL()
- {
- switch(this.getFacing())
- {
- case 4:
- return 1;
- case 5:
- return -1;
- default:
- return 0;
- }
- }
-
- private int mXT()
- {
- return 0;
- }
-
- private int mYT()
- {
- switch(this.getFacing())
- {
- case 2:
- return 1;
- case 3:
- return 1;
- case 4:
- return 1;
- case 5:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mZT()
- {
- switch(this.getFacing())
- {
- case 0:
- return 1;
- case 1:
- return -1;
- default:
- return 0;
- }
- }
-
-
-@Override
- public String getInventoryName() {
- return "blower";
- }
-
- public int getStored() {
- return Math.round((float)this.energy);
- }
-
- public void setStored(int value) {
- this.energy=value;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public GuiScreen getGui(EntityPlayer arg0, boolean arg1) {
- return new BlowerGui(new BlowerContainer(arg0, this));
- }
-
- public boolean getGui(EntityPlayer player)
- {
- return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
- }
- @Override
- public ContainerBase<?> getGuiContainer(EntityPlayer arg0) {
- return new BlowerContainer(arg0, this);
- }
- @Override
- public void onGuiClosed(EntityPlayer arg0) {}
-
- public void setOverclockRates()
- {
- int speedUp=0;
- int tierUp=0;
- int capacityUp=0;
- int checksum=0;
- for(int i=0;i<this.upgradeSlot.size();i++)
- {
- if(this.upgradeSlot.get(i)!=null)
- {
- if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("overclockerUpgrade").getItemDamage())
- {
- speedUp+=this.upgradeSlot.get(i).stackSize;
- }
- if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
- {
- tierUp+=this.upgradeSlot.get(i).stackSize;
- }
- if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
- {
- capacityUp+=this.upgradeSlot.get(i).stackSize;
- }
- }
- }
- checksum=speedUp*4096+tierUp*64+capacityUp;
- if(this.updateChecksum!=checksum)
- {
-
- if(
- this.isAirPassable(this.xCoord+mXL(),this.yCoord+mYL(),this.zCoord+mZL())&&
- this.isAirPassable(this.xCoord-mXL(),this.yCoord-mYL(),this.zCoord-mZL()))
- {
- this.airSpeedBase=Math.min(3284,(int) (this.defaultAirSpeedBase*Math.pow(1.7D, speedUp)));
- }
- else if(
- !this.isAirPassable(this.xCoord+mXL(),this.yCoord+mYL(),this.zCoord+mZL())&&
- !this.isAirPassable(this.xCoord-mXL(),this.yCoord-mYL(),this.zCoord-mZL()))
- {
- this.airSpeedBase=0;
- }
- else
- {
- this.airSpeedBase=Math.min(3282,(int) (this.defaultAirSpeedBase*Math.pow(1.7D, speedUp)*0.5D));
- }
- this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
- IC2.network.get().updateTileEntityField(this, "maxStorage");
- this.energyConsume=(int) Math.min(this.defaultEnergyConsume*Math.pow(1.6D, speedUp),this.maxStorage);
- IC2.network.get().updateTileEntityField(this, "airSpeedBase");
- this.tier=this.defaultTier+tierUp;
- IC2.network.get().updateTileEntityField(this, "tier");
- this.updateChecksum=checksum;
- }
- }
-
- //1.7.10 API
- @Override
- public double getDemandedEnergy()
- {
- return this.maxStorage - this.energy;
- }
-
- @Override
- public int getSinkTier()
- {
- return this.tier;
- }
-
- @Override
- public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
- {
- if (this.energy >= this.maxStorage)
- {
- return amount;
- }
- else
- {
- this.energy += amount;
- return 0.0D;
- }
- }
-
- @Override
- public double getEnergy() {
- return this.energy;
- }
-
- @Override
- public boolean useEnergy(double amount)
- {
- if (this.energy >= amount)
- {
- this.energy -= amount;
- return true;
- }
- else
- {
- return false;
- }
- }
-
- public int neighborBlowerOperationRange(int x,int y,int z)
- {
- if(this.worldObj.getTileEntity(x, y, z)!=null && this.worldObj.getTileEntity(x, y, z) instanceof BlowerTileEntity)
- {
- BlowerTileEntity bte = (BlowerTileEntity) this.worldObj.getTileEntity(x, y, z);
- if(bte.getFacing()==this.getFacing())
- {
- return bte.operationRange;
- }
- }
- return -1;
- }
-
- public ItemStack getOutput(int arg0)
- {
- return null;
- }
-
- public int getOutputSize() {
- return 0;
- }
-
- public void setOutput(int arg0, ItemStack arg1) {
- }
-
- @Override
- public Set<UpgradableProperty> getUpgradableProperties()
- {
- Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
- properties.add(UpgradableProperty.Processing);
- properties.add(UpgradableProperty.EnergyStorage);
- properties.add(UpgradableProperty.Transformer);
- return properties;
- }
-}
\ No newline at end of file |
