Dev branch initial commit
parent
77ef188fac
commit
53e91d1566
|
@ -1,4 +1,4 @@
|
|||
package com.droog71.prospect.fe;
|
||||
package com.droog71.prospect.forge_energy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -26,17 +26,20 @@ public class ProspectEnergyStorage implements IEnergyStorage
|
|||
public int maxReceive;
|
||||
public boolean overloaded;
|
||||
|
||||
// Load the amount of energy stored.
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
energy = compound.getInteger("energy");
|
||||
}
|
||||
|
||||
// Save the amount of energy stored.
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
compound.setInteger("energy",energy);
|
||||
return compound;
|
||||
}
|
||||
|
||||
// Add energy to the buffer.
|
||||
public int generateEnergy(int amount)
|
||||
{
|
||||
int energyAdded = Math.min(capacity - energy, amount);
|
||||
|
@ -44,6 +47,7 @@ public class ProspectEnergyStorage implements IEnergyStorage
|
|||
return energyAdded;
|
||||
}
|
||||
|
||||
// Remove energy from the buffer.
|
||||
public int useEnergy(int energyToUse)
|
||||
{
|
||||
int energyUsed = Math.min(energy, energyToUse);
|
||||
|
@ -71,7 +75,7 @@ public class ProspectEnergyStorage implements IEnergyStorage
|
|||
}
|
||||
}
|
||||
|
||||
//Give energy to an adjacent block.
|
||||
// A list of all adjacent blocks capable of receiving energy.
|
||||
public List<IEnergyStorage> receivers(World world, BlockPos pos)
|
||||
{
|
||||
List<IEnergyStorage> receiversFound = new ArrayList<IEnergyStorage>();
|
||||
|
@ -103,6 +107,7 @@ public class ProspectEnergyStorage implements IEnergyStorage
|
|||
return receiversFound;
|
||||
}
|
||||
|
||||
// Give energy to receivers
|
||||
public void giveEnergy(ProspectEnergyStorage source, IEnergyStorage sink, int rating)
|
||||
{
|
||||
if (sink != null)
|
||||
|
@ -141,33 +146,37 @@ public class ProspectEnergyStorage implements IEnergyStorage
|
|||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the amount of energy in the buffer.
|
||||
@Override
|
||||
public int getEnergyStored()
|
||||
{
|
||||
return energy;
|
||||
}
|
||||
|
||||
// Get the maximum capacity of the buffer.
|
||||
@Override
|
||||
public int getMaxEnergyStored()
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive()
|
||||
{
|
||||
return maxReceive > 0;
|
||||
}
|
||||
|
||||
// Not used.
|
||||
@Override
|
||||
public boolean canExtract()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not used.
|
||||
@Override
|
||||
public boolean canReceive()
|
||||
public int extractEnergy(int maxExtract, boolean simulate)
|
||||
{
|
||||
return maxReceive > 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -62,22 +62,22 @@ public class ExtruderGUI extends GuiContainer
|
|||
|
||||
if (ExtruderTileEntity.isEnergized(this.tileExtruder))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
int k = this.getPowerScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int l = this.getExtrustionProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
private int getExtrustionProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileExtruder.getField(2);
|
||||
int j = this.tileExtruder.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
private int getPowerScaled(int pixels)
|
||||
{
|
||||
int i = this.tileExtruder.getField(1);
|
||||
|
||||
|
|
|
@ -12,18 +12,18 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PrinterGUI extends GuiContainer
|
||||
public class FabricatorGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation PRINTER_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/printer.png");
|
||||
private static final ResourceLocation FABRICATOR_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/fabricator.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tilePrinter;
|
||||
private final IInventory tileFabricator;
|
||||
|
||||
public PrinterGUI(InventoryPlayer playerInv, IInventory printerInv)
|
||||
public FabricatorGUI(InventoryPlayer playerInv, IInventory fabricatorInv)
|
||||
{
|
||||
super(new FabricatorContainer(playerInv, printerInv));
|
||||
super(new FabricatorContainer(playerInv, fabricatorInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tilePrinter = printerInv;
|
||||
this.tileFabricator = fabricatorInv;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public class PrinterGUI extends GuiContainer
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tilePrinter.getName();
|
||||
String s = this.tileFabricator.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
@ -55,37 +55,37 @@ public class PrinterGUI extends GuiContainer
|
|||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(PRINTER_GUI_TEXTURES);
|
||||
this.mc.getTextureManager().bindTexture(FABRICATOR_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (FabricatorTileEntity.isEnergized(this.tilePrinter))
|
||||
if (FabricatorTileEntity.isEnergized(this.tileFabricator))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
int k = this.getPowerScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int l = this.getFabricationProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
private int getFabricationProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePrinter.getField(2);
|
||||
int j = this.tilePrinter.getField(3);
|
||||
int i = this.tileFabricator.getField(2);
|
||||
int j = this.tileFabricator.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
private int getPowerScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePrinter.getField(1);
|
||||
int i = this.tileFabricator.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tilePrinter.getField(0) * pixels / i;
|
||||
return this.tileFabricator.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -62,22 +62,22 @@ public class LaunchPadGUI extends GuiContainer
|
|||
|
||||
if (LaunchPadTileEntity.isEnergized(this.tileLaunchPad))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
int k = this.getPowerScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int l = this.getLaunchProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
private int getLaunchProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileLaunchPad.getField(2);
|
||||
int j = this.tileLaunchPad.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
private int getPowerScaled(int pixels)
|
||||
{
|
||||
int i = this.tileLaunchPad.getField(1);
|
||||
|
||||
|
|
|
@ -62,22 +62,22 @@ public class PressGUI extends GuiContainer
|
|||
|
||||
if (PressTileEntity.isEnergized(this.tilePress))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
int k = this.getPowerScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int l = this.getPressProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
private int getPressProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePress.getField(2);
|
||||
int j = this.tilePress.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
private int getPowerScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePress.getField(1);
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@ public class ProspectGuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (ID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (ID == 1)
|
||||
{
|
||||
return new FabricatorContainer(player.inventory, (FabricatorTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
|
@ -52,13 +48,9 @@ public class ProspectGuiHandler implements IGuiHandler
|
|||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (ID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (ID == 1)
|
||||
{
|
||||
return new PrinterGUI(player.inventory, (FabricatorTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
return new FabricatorGUI(player.inventory, (FabricatorTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 2)
|
||||
{
|
||||
|
|
|
@ -62,22 +62,22 @@ public class ReplicatorGUI extends GuiContainer
|
|||
|
||||
if (ReplicatorTileEntity.isEnergized(this.tileReplicator))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
int k = this.getPowerScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int l = this.getReplicationProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
private int getReplicationProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileReplicator.getField(2);
|
||||
int j = this.tileReplicator.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
private int getPowerScaled(int pixels)
|
||||
{
|
||||
int i = this.tileReplicator.getField(4);
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ public class ProspectItems
|
|||
public static Item suit;
|
||||
public static Item pants;
|
||||
public static Item boots;
|
||||
|
||||
public static Item filter;
|
||||
public static Item suit_material;
|
||||
public static Item gem;
|
||||
|
@ -103,11 +102,13 @@ public class ProspectItems
|
|||
|
||||
public static void init()
|
||||
{
|
||||
// Armor
|
||||
helmet = new ProspectArmor("helmet",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.HEAD);
|
||||
suit = new ProspectArmor("suit",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.CHEST);
|
||||
pants = new ProspectArmor("pants",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 1, EntityEquipmentSlot.LEGS);
|
||||
boots = new ProspectArmor("boots",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.FEET);
|
||||
|
||||
// Items
|
||||
filter = new SporeFilter("filter").setMaxDamage(100000).setCreativeTab(Prospect.tabProspect).setMaxStackSize(1);
|
||||
gem = new ProspectItem("gem").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
credit = new ProspectItem("credit").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
|
@ -141,7 +142,8 @@ public class ProspectItems
|
|||
lead_plate = new ProspectItem("lead_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
aluminum_plate = new ProspectItem("aluminum_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
silicon = new ProspectItem("silicon").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
|
||||
|
||||
// Schematics
|
||||
boots_schematic = new Schematic("boots_schematic",0).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
pants_schematic = new Schematic("pants_schematic",1).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
suit_schematic = new Schematic("suit_schematic",2).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
|
@ -190,12 +192,14 @@ public class ProspectItems
|
|||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
{
|
||||
// Armor
|
||||
event.getRegistry().registerAll(helmet);
|
||||
event.getRegistry().registerAll(suit);
|
||||
event.getRegistry().registerAll(pants);
|
||||
event.getRegistry().registerAll(boots);
|
||||
|
||||
// Items
|
||||
event.getRegistry().registerAll(filter);
|
||||
event.getRegistry().registerAll(gem);
|
||||
event.getRegistry().registerAll(credit);
|
||||
|
@ -230,6 +234,7 @@ public class ProspectItems
|
|||
event.getRegistry().registerAll(aluminum_plate);
|
||||
event.getRegistry().registerAll(silicon);
|
||||
|
||||
// Schematics
|
||||
event.getRegistry().registerAll(purifier_schematic);
|
||||
event.getRegistry().registerAll(launch_pad_schematic);
|
||||
event.getRegistry().registerAll(fabricator_schematic);
|
||||
|
@ -271,7 +276,6 @@ public class ProspectItems
|
|||
event.getRegistry().registerAll(iv_coil_schematic);
|
||||
event.getRegistry().registerAll(circuit_schematic);
|
||||
event.getRegistry().registerAll(prepared_circuit_schematic);
|
||||
|
||||
event.getRegistry().registerAll(chest_schematic);
|
||||
event.getRegistry().registerAll(hopper_schematic);
|
||||
event.getRegistry().registerAll(piston_schematic);
|
||||
|
@ -280,12 +284,14 @@ public class ProspectItems
|
|||
@SubscribeEvent
|
||||
public static void registerRenders(ModelRegistryEvent event)
|
||||
{
|
||||
// Armor
|
||||
registerRender(filter);
|
||||
registerRender(helmet);
|
||||
registerRender(suit);
|
||||
registerRender(pants);
|
||||
registerRender(boots);
|
||||
|
||||
// Items
|
||||
registerRender(gem);
|
||||
registerRender(credit);
|
||||
registerRender(suit_material);
|
||||
|
@ -319,6 +325,7 @@ public class ProspectItems
|
|||
registerRender(aluminum_plate);
|
||||
registerRender(silicon);
|
||||
|
||||
// Schematics
|
||||
registerRender(helmet_schematic);
|
||||
registerRender(suit_schematic);
|
||||
registerRender(pants_schematic);
|
||||
|
@ -360,7 +367,6 @@ public class ProspectItems
|
|||
registerRender(iv_coil_schematic);
|
||||
registerRender(circuit_schematic);
|
||||
registerRender(prepared_circuit_schematic);
|
||||
|
||||
registerRender(chest_schematic);
|
||||
registerRender(hopper_schematic);
|
||||
registerRender(piston_schematic);
|
||||
|
|
|
@ -8,8 +8,8 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Prospect.MODID)
|
||||
public class ProspectPotions {
|
||||
|
||||
public class ProspectPotions
|
||||
{
|
||||
public static final Potion spore = new PotionSpore();
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.droog71.prospect.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.droog71.prospect.tile_entity.ReplicatorTileEntity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ReplicatorItems
|
||||
{
|
||||
public boolean replicatorItem(ReplicatorTileEntity replicator, ItemStack stack)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item == Items.ENDER_PEARL || item == Items.GHAST_TEAR || item == Items.BLAZE_POWDER || item == Items.NETHER_WART)
|
||||
{
|
||||
replicator.itemTier = 5;
|
||||
return true;
|
||||
}
|
||||
if (item == Items.DIAMOND || item == Items.EMERALD)
|
||||
{
|
||||
replicator.itemTier = 4;
|
||||
return true;
|
||||
}
|
||||
if (item == Items.IRON_INGOT || item == Items.GOLD_INGOT || item == Items.REDSTONE)
|
||||
{
|
||||
replicator.itemTier = 3;
|
||||
return true;
|
||||
}
|
||||
if (item == Items.GLOWSTONE_DUST || item == Items.CLAY_BALL || item == Items.QUARTZ || item == Items.COAL || item == Items.STRING)
|
||||
{
|
||||
replicator.itemTier = 2;
|
||||
return true;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(Blocks.PLANKS) || item == Item.getItemFromBlock(Blocks.COBBLESTONE) || item == Item.getItemFromBlock(Blocks.WOOL))
|
||||
{
|
||||
replicator.itemTier = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
List<NonNullList<ItemStack>> oreDictList = new ArrayList<NonNullList<ItemStack>>();
|
||||
String[] listNames = { "ingotCopper", "ingotTin", "ingotSilver", "ingotLead", "ingotAluminum", "silicon" };
|
||||
for (String name : listNames)
|
||||
{
|
||||
oreDictList.add(OreDictionary.getOres(name));
|
||||
}
|
||||
|
||||
for (NonNullList<ItemStack> list : oreDictList)
|
||||
{
|
||||
for (ItemStack s : list)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
replicator.itemTier = 3;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class SporeFilter extends ProspectItem
|
|||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if(itemSlot < 9) //Spore filters must be placed in the hotbar when in use. Extra filters stored in the player's inventory will not take damage.
|
||||
if(itemSlot < 9) //Spore filters must be placed in the hotbar when in use.
|
||||
{
|
||||
if (stack.getItemDamage() >= stack.getMaxDamage())
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.droog71.prospect.potion;
|
||||
|
||||
import net.machinemuse.powersuits.item.armor.ItemElectricArmor;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -8,25 +7,18 @@ import net.minecraft.potion.PotionEffect;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import techguns.TGArmors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.droog71.prospect.armor.ProspectArmor;
|
||||
import com.droog71.prospect.blocks.energy.Purifier;
|
||||
import com.droog71.prospect.config.ConfigHandler;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
|
||||
import ic2.core.platform.registry.Ic2Items;
|
||||
|
||||
|
||||
public class PotionSpore extends PotionProspect
|
||||
{
|
||||
private SporeArmorList sporeArmorList;
|
||||
private int hurtTimer;
|
||||
private int message;
|
||||
|
||||
|
@ -52,115 +44,14 @@ public class PotionSpore extends PotionProspect
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isArmorProtective(ItemStack stack) //Checks if the player's armor will protect them from toxic spores.
|
||||
{
|
||||
if (stack.getItem() instanceof ProspectArmor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (stack == Ic2Items.hazmatHelmet || stack == Ic2Items.hazmatChest || stack == Ic2Items.hazmatLeggings || stack == Ic2Items.hazmatBoots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("techguns"))
|
||||
{
|
||||
if (stack.getItem() == TGArmors.hazmat_Helmet || stack.getItem() == TGArmors.hazmat_Chestplate || stack.getItem() == TGArmors.hazmat_Leggings || stack.getItem() == TGArmors.hazmat_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t3_miner_Helmet || stack.getItem() == TGArmors.t3_miner_Chestplate || stack.getItem() == TGArmors.t3_miner_Leggings || stack.getItem() == TGArmors.t3_miner_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.steam_Helmet || stack.getItem() == TGArmors.steam_Chestplate || stack.getItem() == TGArmors.steam_Leggings || stack.getItem() == TGArmors.steam_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t3_power_Helmet || stack.getItem() == TGArmors.t3_power_Chestplate || stack.getItem() == TGArmors.t3_power_Leggings || stack.getItem() == TGArmors.t3_power_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t4_power_Helmet || stack.getItem() == TGArmors.t4_power_Chestplate || stack.getItem() == TGArmors.t4_power_Leggings || stack.getItem() == TGArmors.t4_power_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("powersuits"))
|
||||
{
|
||||
if (stack.getItem() instanceof ItemElectricArmor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void performEffect(@Nonnull EntityLivingBase living, int amplified)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) living;
|
||||
if (player != null && ConfigHandler.toxicSporesEnabled())
|
||||
{
|
||||
boolean isPoisoned = false;
|
||||
boolean nearPurifier = false;
|
||||
BlockPos pos = player.getPosition();
|
||||
BlockPos corner_1 = pos.add(-20, -20, -20);
|
||||
BlockPos corner_2 = pos.add(20, 20, 20);
|
||||
Iterable<BlockPos> allBlocks = BlockPos.getAllInBox(corner_1, corner_2);
|
||||
Iterator<BlockPos> iter = allBlocks.iterator();
|
||||
while(iter.hasNext()) //Check if the player is near an energized purifier block which will protect them from toxic spores.
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockPos found = iter.next();
|
||||
if (player.world.getBlockState(found).getBlock() == ProspectBlocks.purifier)
|
||||
{
|
||||
Purifier purifier = (Purifier) player.world.getBlockState(found).getBlock();
|
||||
if (purifier.powered == true)
|
||||
{
|
||||
nearPurifier = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(NoSuchElementException e)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
}
|
||||
if (!nearPurifier)
|
||||
{
|
||||
boolean filterInstalled = false;
|
||||
int i = 0;
|
||||
while (i < 9) //Check if the player has a spore filter in their hotbar.
|
||||
{
|
||||
if (player.inventory.getStackInSlot(i).getItem() == ProspectItems.filter)
|
||||
{
|
||||
filterInstalled = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!filterInstalled)
|
||||
{
|
||||
isPoisoned = true; //The player is not near a purifier and has no spore filter in their hotbar and is therefore vulnerable to toxic spores.
|
||||
}
|
||||
ArrayList<ItemStack> armorList = new ArrayList<ItemStack>();
|
||||
for (int slot=36; slot<40; slot++)
|
||||
{
|
||||
armorList.add(player.inventory.getStackInSlot(slot));
|
||||
}
|
||||
for (ItemStack armorItem : armorList)
|
||||
{
|
||||
if (!(isArmorProtective(armorItem)))
|
||||
{
|
||||
isPoisoned = true; //The player is not near a purifier and is not wearing protective armor and is therefore vulnerable to toxic spores.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isPoisoned)
|
||||
{
|
||||
if (!nearPurifier(player) && !filterInstalled(player) || !wearingProtectiveArmor(player))
|
||||
{
|
||||
hurtTimer++;
|
||||
if (hurtTimer >= 200)
|
||||
|
@ -169,29 +60,10 @@ public class PotionSpore extends PotionProspect
|
|||
}
|
||||
if (hurtTimer >= 240)
|
||||
{
|
||||
if (message == 0)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Received poisonous spore damage!"));
|
||||
}
|
||||
if (message == 1)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("You need protective armor and a spore filter in your hotbar!"));
|
||||
}
|
||||
if (message == 2)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Build a purifier to create a protected area!"));
|
||||
}
|
||||
if (message < 2)
|
||||
{
|
||||
message++;
|
||||
}
|
||||
else
|
||||
{
|
||||
message = 0;
|
||||
}
|
||||
sendMessage(player);
|
||||
hurtTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = 0;
|
||||
|
@ -199,4 +71,83 @@ public class PotionSpore extends PotionProspect
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the player is near an energized purifier block.
|
||||
private boolean nearPurifier(EntityPlayer player) throws NoSuchElementException
|
||||
{
|
||||
BlockPos pos = player.getPosition();
|
||||
BlockPos corner_1 = pos.add(-20, -20, -20);
|
||||
BlockPos corner_2 = pos.add(20, 20, 20);
|
||||
Iterable<BlockPos> allBlocks = BlockPos.getAllInBox(corner_1, corner_2);
|
||||
Iterator<BlockPos> iter = allBlocks.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
BlockPos found = iter.next();
|
||||
if (player.world.getBlockState(found).getBlock() == ProspectBlocks.purifier)
|
||||
{
|
||||
Purifier purifier = (Purifier) player.world.getBlockState(found).getBlock();
|
||||
if (purifier.powered == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the player has a spore filter in their hotbar.
|
||||
private boolean filterInstalled(EntityPlayer player)
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
if (player.inventory.getStackInSlot(i).getItem() == ProspectItems.filter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the player's armor is protecting them from toxic spores.
|
||||
private boolean wearingProtectiveArmor(EntityPlayer player)
|
||||
{
|
||||
ArrayList<ItemStack> playerArmorList = new ArrayList<ItemStack>();
|
||||
for (int slot=36; slot<40; slot++)
|
||||
{
|
||||
playerArmorList.add(player.inventory.getStackInSlot(slot));
|
||||
}
|
||||
for (ItemStack armorItem : playerArmorList)
|
||||
{
|
||||
if (!sporeArmorList.protectiveArmorList().contains(armorItem.getItem()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendMessage(EntityPlayer player)
|
||||
{
|
||||
if (message == 0)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Received poisonous spore damage!"));
|
||||
}
|
||||
if (message == 1)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("You need protective armor and a spore filter in your hotbar!"));
|
||||
}
|
||||
if (message == 2)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Build a purifier to create a protected area!"));
|
||||
}
|
||||
if (message < 2)
|
||||
{
|
||||
message++;
|
||||
}
|
||||
else
|
||||
{
|
||||
message = 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.droog71.prospect.potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import ic2.core.platform.registry.Ic2Items;
|
||||
import net.machinemuse.powersuits.common.MPSItems;
|
||||
import techguns.TGArmors;
|
||||
|
||||
public class SporeArmorList
|
||||
{
|
||||
public List<Item> protectiveArmorList()
|
||||
{
|
||||
List<Item> list = new ArrayList<Item>();
|
||||
|
||||
list.add(ProspectItems.helmet);
|
||||
list.add(ProspectItems.suit);
|
||||
list.add(ProspectItems.pants);
|
||||
list.add(ProspectItems.boots);
|
||||
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
list.add(Ic2Items.hazmatHelmet.getItem());
|
||||
list.add(Ic2Items.hazmatChest.getItem());
|
||||
list.add(Ic2Items.hazmatLeggings.getItem());
|
||||
list.add(Ic2Items.hazmatBoots.getItem());
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("techguns"))
|
||||
{
|
||||
list.add(TGArmors.hazmat_Helmet);
|
||||
list.add(TGArmors.hazmat_Chestplate);
|
||||
list.add(TGArmors.hazmat_Leggings);
|
||||
list.add(TGArmors.hazmat_Boots);
|
||||
list.add(TGArmors.steam_Helmet);
|
||||
list.add(TGArmors.steam_Chestplate);
|
||||
list.add(TGArmors.steam_Leggings);
|
||||
list.add(TGArmors.steam_Boots);
|
||||
list.add(TGArmors.t3_miner_Helmet);
|
||||
list.add(TGArmors.t3_miner_Chestplate);
|
||||
list.add(TGArmors.t3_miner_Leggings);
|
||||
list.add(TGArmors.t3_miner_Boots);
|
||||
list.add(TGArmors.t3_power_Helmet);
|
||||
list.add(TGArmors.t3_power_Chestplate);
|
||||
list.add(TGArmors.t3_power_Leggings);
|
||||
list.add(TGArmors.t3_power_Boots);
|
||||
list.add(TGArmors.t4_power_Helmet);
|
||||
list.add(TGArmors.t4_power_Chestplate);
|
||||
list.add(TGArmors.t4_power_Leggings);
|
||||
list.add(TGArmors.t4_power_Boots);
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("powersuits"))
|
||||
{
|
||||
list.add(MPSItems.powerArmorHead);
|
||||
list.add(MPSItems.powerArmorTorso);
|
||||
list.add(MPSItems.powerArmorLegs);
|
||||
list.add(MPSItems.powerArmorFeet);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.ExtruderContainer;
|
||||
|
@ -282,7 +282,7 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
extrudeTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && extrudeTime > 0)
|
||||
else if (extrudeTime > 0)
|
||||
{
|
||||
extrudeTime = MathHelper.clamp(extrudeTime - 2, 0, totalextrudeTime);
|
||||
}
|
||||
|
@ -291,16 +291,14 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++extrudeTime;
|
||||
|
||||
{
|
||||
++extrudeTime;
|
||||
if (extrudeTime == totalextrudeTime)
|
||||
{
|
||||
extrudeTime = 0;
|
||||
totalextrudeTime = getextrudeTime(extruderItemStacks.get(0));
|
||||
extrudeItem();
|
||||
flag1 = true;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
|
@ -309,12 +307,9 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
world.playSound(null, pos, ProspectSounds.extruderSoundEvent, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Get values from the energy storage or ic2 energy sink
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
|
@ -341,6 +336,7 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
}
|
||||
}
|
||||
|
||||
// Remove energy from the buffer
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
|
@ -369,11 +365,13 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
return false;
|
||||
}
|
||||
|
||||
public int getextrudeTime(ItemStack stack) //Could be used for varying extrude time for different ingots.
|
||||
// How long it takes to extrude the ingot
|
||||
public int getextrudeTime(ItemStack stack)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
// Checks if the item in question is registered as a copper ingot
|
||||
private boolean isCopperIngot(ItemStack stack)
|
||||
{
|
||||
NonNullList<ItemStack> copper = OreDictionary.getOres("ingotCopper");
|
||||
|
@ -531,11 +529,7 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create the container
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new ExtruderContainer(playerInventory, this);
|
||||
|
@ -559,6 +553,12 @@ public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedI
|
|||
}
|
||||
}
|
||||
|
||||
// Not used
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.droog71.prospect.tile_entity;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.FabricatorContainer;
|
||||
import com.droog71.prospect.items.Schematic;
|
||||
|
@ -300,6 +300,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
}
|
||||
|
||||
// Fabricate items and plays the sound effect
|
||||
private void doWork()
|
||||
{
|
||||
++fabricateTime;
|
||||
|
@ -320,6 +321,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
}
|
||||
|
||||
// Get values from the energy storage or ic2 energy sink
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
|
@ -346,6 +348,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
}
|
||||
|
||||
// Remove energy from the buffer
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
|
@ -374,11 +377,15 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
return false;
|
||||
}
|
||||
|
||||
public int getfabricateTime(ItemStack stack) //For now, all schematics take the same amount of time. This may change.
|
||||
// How long it takes to fabricate the item
|
||||
public int getfabricateTime(ItemStack stack)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if all ingredients relevant to the schematic are present in an adjacent inventory
|
||||
*/
|
||||
private boolean canCraft(ItemStack[] stacks, IInventory iinventory)
|
||||
{
|
||||
if (iinventory != null)
|
||||
|
@ -412,6 +419,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
return false;
|
||||
}
|
||||
|
||||
// Consumes ingredients in adjacent inventory when crafting an item
|
||||
private void consumeItems()
|
||||
{
|
||||
ItemStack[] stacks = null;
|
||||
|
@ -458,6 +466,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
}
|
||||
|
||||
// Returns an adjacent inventory containing the necessary ingredients for the current schematic
|
||||
public IInventory getInventoryForCrafting(ItemStack[] stacks)
|
||||
{
|
||||
List<IInventory> invList = new ArrayList<IInventory>();
|
||||
|
@ -479,6 +488,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
return null;
|
||||
}
|
||||
|
||||
// Returns IInventory instance at a given position
|
||||
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z)
|
||||
{
|
||||
IInventory iinventory = null;
|
||||
|
@ -518,7 +528,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the fabricator can fabricate an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
* Returns true if the fabricator can craft an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canFabricate()
|
||||
{
|
||||
|
@ -548,6 +558,7 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
}
|
||||
|
||||
// Creates the resulting item for the current schematic
|
||||
public void fabricateItem()
|
||||
{
|
||||
ItemStack result = new ItemStack(Items.AIR);
|
||||
|
@ -650,11 +661,13 @@ public class FabricatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
return true;
|
||||
}
|
||||
|
||||
// Not used
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Creates the container
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new FabricatorContainer(playerInventory, this);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
|
@ -283,77 +283,67 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
if (capsuleYpos == 0)
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.playSound(null, pos, ProspectSounds.capsuleSoundEvent, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
capsuleYpos = 1;
|
||||
}
|
||||
else if (capsuleYpos < 500)
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
world.setBlockState(new BlockPos(pos.getX(),pos.getY()+capsuleYpos,pos.getZ()), ProspectBlocks.capsule.getDefaultState());
|
||||
capsuleYpos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
doWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
capsuleYpos = 0;
|
||||
launchTime = 0;
|
||||
launchTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && launchTime > 0)
|
||||
}
|
||||
else if (launchTime > 0)
|
||||
{
|
||||
launchTime = MathHelper.clamp(launchTime - 2, 0, totalLaunchTime);
|
||||
launchTime = MathHelper.clamp(launchTime - 2, 0, totalLaunchTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (capsuleYpos > 0 && capsuleYpos < 500)
|
||||
{
|
||||
moveCapsule();
|
||||
}
|
||||
else if (capsuleYpos > 500)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spawns particle effects, plays sound and moves capsule 1 block above the launch pad
|
||||
private void launchCapsule()
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.playSound(null, pos, ProspectSounds.capsuleSoundEvent, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
capsuleYpos = 1;
|
||||
}
|
||||
|
||||
// Continues moving the capsule up 1 block each tick
|
||||
private void moveCapsule()
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
world.setBlockState(new BlockPos(pos.getX(),pos.getY()+capsuleYpos,pos.getZ()), ProspectBlocks.capsule.getDefaultState());
|
||||
capsuleYpos++;
|
||||
}
|
||||
|
||||
// Increases the progress each tick and launches the capsule at the end
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++launchTime;
|
||||
|
||||
++launchTime;
|
||||
if (launchTime == totalLaunchTime)
|
||||
{
|
||||
launchTime = 0;
|
||||
totalLaunchTime = getlaunchTime(launchPadItemStacks.get(0));
|
||||
launchItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Get values from the energy storage or ic2 energy sink
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
|
@ -380,6 +370,7 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
}
|
||||
}
|
||||
|
||||
// Remove energy from the buffer
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
|
@ -408,11 +399,13 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
return false;
|
||||
}
|
||||
|
||||
public int getlaunchTime(ItemStack stack) //Could be used to vary launch times depending on the item.
|
||||
// How long it takes to launch an item
|
||||
public int getlaunchTime(ItemStack stack)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
// Returns the amount of IGC the current item is worth
|
||||
private int getCurrentPayout()
|
||||
{
|
||||
Item item = launchPadItemStacks.get(0).getItem();
|
||||
|
@ -557,12 +550,19 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
}
|
||||
|
||||
/**
|
||||
* Turn one item from the launch pad source stack into the appropriate resulting item in the launch pad result stack
|
||||
* Launch the capsule, remove the item from the inventory and add IGC to the output slot
|
||||
*/
|
||||
public void launchItem()
|
||||
{
|
||||
if (canLaunch())
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
launchCapsule();
|
||||
|
||||
ItemStack itemstack = launchPadItemStacks.get(0);
|
||||
ItemStack itemstack1 = new ItemStack(ProspectItems.credit,currentPayout);
|
||||
ItemStack itemstack2 = launchPadItemStacks.get(2);
|
||||
|
@ -598,14 +598,12 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -656,6 +654,7 @@ public class LaunchPadTileEntity extends TileEntity implements ITickable, ISided
|
|||
return true;
|
||||
}
|
||||
|
||||
// Not used
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.PressContainer;
|
||||
|
@ -281,7 +281,7 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
pressTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && pressTime > 0)
|
||||
else if (pressTime > 0)
|
||||
{
|
||||
pressTime = MathHelper.clamp(pressTime - 2, 0, totalpressTime);
|
||||
}
|
||||
|
@ -290,16 +290,14 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++pressTime;
|
||||
|
||||
{
|
||||
++pressTime;
|
||||
if (pressTime == totalpressTime)
|
||||
{
|
||||
pressTime = 0;
|
||||
totalpressTime = getpressTime(pressItemStacks.get(0));
|
||||
pressItem();
|
||||
flag1 = true;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
|
@ -308,12 +306,9 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
world.playSound(null, pos, ProspectSounds.pressSoundEvent, SoundCategory.BLOCKS, 1.0f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Get values from the energy storage or ic2 energy sink
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
|
@ -339,7 +334,8 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove energy from the buffer
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
|
@ -368,11 +364,13 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
return false;
|
||||
}
|
||||
|
||||
public int getpressTime(ItemStack stack) //Could be used for varying press time for different ingots.
|
||||
// The amount of time it takes to press an ingot
|
||||
public int getpressTime(ItemStack stack)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
// Returns the plate the current ingot produces
|
||||
private ItemStack getPlate(ItemStack stack)
|
||||
{
|
||||
NonNullList<ItemStack> copper = OreDictionary.getOres("ingotCopper");
|
||||
|
@ -519,14 +517,12 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,6 +573,7 @@ public class PressTileEntity extends TileEntity implements ITickable, ISidedInve
|
|||
return true;
|
||||
}
|
||||
|
||||
// Not used
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.Iterator;
|
|||
import java.util.NoSuchElementException;
|
||||
import com.droog71.prospect.blocks.energy.Purifier;
|
||||
import com.droog71.prospect.config.ConfigHandler;
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -121,6 +121,7 @@ public class PurifierTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
// Spawn particles, play sound
|
||||
private void doWork()
|
||||
{
|
||||
effectsTimer++;
|
||||
|
@ -150,6 +151,7 @@ public class PurifierTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Remove energy from the buffer
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 32)
|
||||
|
|
|
@ -3,7 +3,8 @@ package com.droog71.prospect.tile_entity;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
|
@ -158,7 +159,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return compound;
|
||||
}
|
||||
|
||||
//Puts mined blocks and items into adjacent storage.
|
||||
// Puts mined blocks and items into adjacent storage
|
||||
private void transferItemOut(ItemStack stack)
|
||||
{
|
||||
IInventory iinventory = getInventoryForTransfer();
|
||||
|
@ -217,7 +218,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Checks if the block being mined is a liquid.
|
||||
// Checks if the block being mined is a liquid
|
||||
private boolean isLiquid(ItemStack stack)
|
||||
{
|
||||
Block b = Block.getBlockFromItem(stack.getItem());
|
||||
|
@ -231,7 +232,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Checks if an itemstack can be combined with another.
|
||||
// Checks if an itemstack can be combined with another
|
||||
private static boolean canCombine(ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if (stack1.getItem() != stack2.getItem())
|
||||
|
@ -252,7 +253,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Checks if given inventory is full.
|
||||
// Checks if given inventory is full
|
||||
private boolean isInventoryFull(IInventory inventoryIn)
|
||||
{
|
||||
if (inventoryIn instanceof ISidedInventory)
|
||||
|
@ -275,7 +276,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return true;
|
||||
}
|
||||
|
||||
//Checks if given inventory has any empty slots.
|
||||
// Checks if given inventory has any empty slots
|
||||
private boolean inventoryHasEmptySlot(IInventory inventoryIn)
|
||||
{
|
||||
if (inventoryIn instanceof ISidedInventory)
|
||||
|
@ -298,7 +299,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return false;
|
||||
}
|
||||
|
||||
//The adjacent inventory the quarry will use to transfer items out.
|
||||
// The adjacent inventory the quarry will use to transfer items out
|
||||
public IInventory getInventoryForTransfer()
|
||||
{
|
||||
List<IInventory> invList = new ArrayList<IInventory>();
|
||||
|
@ -346,7 +347,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return null;
|
||||
}
|
||||
|
||||
//Returns instance of IInventory at a given position.
|
||||
// Returns instance of IInventory at a given position
|
||||
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z)
|
||||
{
|
||||
IInventory iinventory = null;
|
||||
|
@ -385,7 +386,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return iinventory;
|
||||
}
|
||||
|
||||
//Sets the starting position for the quarry.
|
||||
// Sets the starting position for the quarry
|
||||
private void initPos()
|
||||
{
|
||||
if (miningX == 100000000)
|
||||
|
@ -398,7 +399,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Sound played when a block is mined.
|
||||
// Sound played when a block is mined
|
||||
private void playMiningSound(BlockPos p)
|
||||
{
|
||||
if (world.getBlockState(p).getBlock() != Blocks.AIR)
|
||||
|
@ -407,7 +408,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
//Amount of energy stored.
|
||||
// Amount of energy stored
|
||||
private int getEnergyStored()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
|
@ -433,7 +434,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return energyStored;
|
||||
}
|
||||
|
||||
//Attempts to consume energy and returns true if successful.
|
||||
// Attempts to consume energy and returns true if successful
|
||||
private boolean useEnergy(int amount)
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
|
@ -462,6 +463,146 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
return false;
|
||||
}
|
||||
|
||||
// Builds the quarry frame and tube 1 block below the quarry.
|
||||
private void buildLevelOne(BlockPos p)
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 || p.getX() == pos.getX() + 10 || p.getZ() == pos.getZ() - 10 || p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() != pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Mines blocks, places quarry frames, tubes and drills
|
||||
private void mineBlock(Block b, BlockPos p)
|
||||
{
|
||||
ItemStack stack = new ItemStack(Items.AIR);
|
||||
Item itemDropped = b.getItemDropped(b.getDefaultState(), new Random(), 0);
|
||||
if (itemDropped != Item.getItemFromBlock(b))
|
||||
{
|
||||
stack = new ItemStack(itemDropped); //Used for blocks that drop items; diamonds, coal, etc.
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = new ItemStack(Item.getItemFromBlock(b)); //All other blocks.
|
||||
}
|
||||
if (stack.getItem() != Items.AIR)
|
||||
{
|
||||
transferItemOut(stack); //Put the item collected in an adjacent storage container.
|
||||
}
|
||||
|
||||
if (level == 1)
|
||||
{
|
||||
buildLevelOne(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() + 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level == 2) //Prevents the frame on level 1 from being destroyed by the quarry.
|
||||
{
|
||||
if (p.getX() != pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
if (p.getX() != pos.getX() - 10 && p.getX() != pos.getX() + 10 && p.getZ() != pos.getZ() - 10 && p.getZ() != pos.getZ() + 10)
|
||||
{
|
||||
miningBlock = true; //A block will be removed at this position.
|
||||
}
|
||||
else
|
||||
{
|
||||
miningBlock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
miningBlock = true; //A block will be removed at this position.
|
||||
if (world.getBlockState(p).getBlock() != Blocks.AIR)
|
||||
{
|
||||
//Play sound and spawn particles at each block mined.
|
||||
playMiningSound(p);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, p.getX(), p.getY(), p.getZ(), 1, 0, 0, 0, 1, null);
|
||||
}
|
||||
}
|
||||
world.setBlockState(p, ProspectBlocks.quarry_drill.getDefaultState()); //Move the drill down to the next level.
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
if (miningBlock == true)
|
||||
{
|
||||
//Remove the old drill block.
|
||||
world.setBlockToAir(p.add(0,1,0));
|
||||
miningBlock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Speed of quarry scales with the amount of power received.
|
||||
private void increaseQuarryTimer()
|
||||
{
|
||||
if (getEnergyStored() >= 512)
|
||||
{
|
||||
useEnergy(512);
|
||||
quarryTimer += 32;
|
||||
}
|
||||
else if (getEnergyStored() >= 256)
|
||||
{
|
||||
useEnergy(256);
|
||||
quarryTimer += 16;
|
||||
}
|
||||
else if (getEnergyStored() >= 128)
|
||||
{
|
||||
useEnergy(128);
|
||||
quarryTimer += 8;
|
||||
}
|
||||
else if (getEnergyStored() >= 32)
|
||||
{
|
||||
useEnergy(32);
|
||||
quarryTimer += 4;
|
||||
}
|
||||
else if (getEnergyStored() >= 5)
|
||||
{
|
||||
useEnergy(5);
|
||||
quarryTimer += 2;
|
||||
}
|
||||
else if (getEnergyStored() >= 1)
|
||||
{
|
||||
useEnergy(1);
|
||||
quarryTimer += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
|
@ -485,38 +626,9 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
soundTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
increaseQuarryTimer();
|
||||
|
||||
//Speed of quarry scales with the amount of power received.
|
||||
if (getEnergyStored() >= 512)
|
||||
{
|
||||
useEnergy(512);
|
||||
quarryTimer += 32;
|
||||
}
|
||||
else if (getEnergyStored() >= 256)
|
||||
{
|
||||
useEnergy(256);
|
||||
quarryTimer += 16;
|
||||
}
|
||||
else if (getEnergyStored() >= 128)
|
||||
{
|
||||
useEnergy(128);
|
||||
quarryTimer += 8;
|
||||
}
|
||||
else if (getEnergyStored() >= 32)
|
||||
{
|
||||
useEnergy(32);
|
||||
quarryTimer += 4;
|
||||
}
|
||||
else if (getEnergyStored() >= 5)
|
||||
{
|
||||
useEnergy(5);
|
||||
quarryTimer += 2;
|
||||
}
|
||||
else if (getEnergyStored() >= 1)
|
||||
{
|
||||
useEnergy(1);
|
||||
quarryTimer += 1;
|
||||
}
|
||||
if (quarryTimer >= 32)
|
||||
{
|
||||
initPos();
|
||||
|
@ -528,100 +640,7 @@ public class QuarryTileEntity extends TileEntity implements ITickable
|
|||
Block b = world.getBlockState(p).getBlock();
|
||||
if (b != Blocks.BEDROCK) //Quarry stops when it hits bedrock.
|
||||
{
|
||||
ItemStack stack = new ItemStack(Items.AIR);
|
||||
Item itemDropped = b.getItemDropped(b.getDefaultState(), new Random(), 0);
|
||||
if (itemDropped != Item.getItemFromBlock(b))
|
||||
{
|
||||
stack = new ItemStack(itemDropped); //Used for blocks that drop items; diamonds, coal, etc.
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = new ItemStack(Item.getItemFromBlock(b)); //All other blocks.
|
||||
}
|
||||
if (stack.getItem() != Items.AIR)
|
||||
{
|
||||
transferItemOut(stack); //Put the item collected in an adjacent storage container.
|
||||
}
|
||||
|
||||
if (level == 1) //Builds the quarry frame and tube 1 block below the quarry.
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 || p.getX() == pos.getX() + 10 || p.getZ() == pos.getZ() - 10 || p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() != pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() + 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level == 2) //Prevents the frame on level 1 from being destroyed by the quarry.
|
||||
{
|
||||
if (p.getX() != pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
if (p.getX() != pos.getX() - 10 && p.getX() != pos.getX() + 10 && p.getZ() != pos.getZ() - 10 && p.getZ() != pos.getZ() + 10)
|
||||
{
|
||||
miningBlock = true; //A block will be removed at this position.
|
||||
}
|
||||
else
|
||||
{
|
||||
miningBlock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
miningBlock = true; //A block will be removed at this position.
|
||||
if (world.getBlockState(p).getBlock() != Blocks.AIR)
|
||||
{
|
||||
//Play sound and spawn particles at each block mined.
|
||||
playMiningSound(p);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, p.getX(), p.getY(), p.getZ(), 1, 0, 0, 0, 1, null);
|
||||
}
|
||||
}
|
||||
world.setBlockState(p, ProspectBlocks.quarry_drill.getDefaultState()); //Move the drill down to the next level.
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
if (miningBlock == true)
|
||||
{
|
||||
//Remove the old drill block.
|
||||
world.setBlockToAir(p.add(0,1,0));
|
||||
miningBlock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
mineBlock(b,p);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.ReplicatorContainer;
|
||||
import com.droog71.prospect.items.ReplicatorItems;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
@ -34,16 +36,17 @@ public class ReplicatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> replicatorItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private ReplicatorItems replicatorItems;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
private Object ic2EnergySink;
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int replicatorSpendTime;
|
||||
private int currentCreditSpendTime;
|
||||
private int replicateTime;
|
||||
private int totalreplicateTime;
|
||||
private Object ic2EnergySink;
|
||||
private int effectsTimer;
|
||||
private int itemTier;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
public int itemTier;
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
|
@ -409,117 +412,13 @@ public class ReplicatorTileEntity extends TileEntity implements ITickable, ISide
|
|||
}
|
||||
return 50;
|
||||
}
|
||||
|
||||
private boolean invalidReplicatorItem(ItemStack stack)
|
||||
{
|
||||
Item i = stack.getItem();
|
||||
if (i == Items.ENDER_PEARL || i == Items.GHAST_TEAR || i == Items.BLAZE_POWDER || i == Items.NETHER_WART)
|
||||
{
|
||||
itemTier = 5;
|
||||
return false;
|
||||
}
|
||||
if (i == Items.DIAMOND || i == Items.EMERALD)
|
||||
{
|
||||
itemTier = 4;
|
||||
return false;
|
||||
}
|
||||
if (i == Items.IRON_INGOT || i == Items.GOLD_INGOT || i == Items.REDSTONE)
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
if (i == Items.GLOWSTONE_DUST || i == Items.CLAY_BALL || i == Items.QUARTZ || i == Items.COAL || i == Items.STRING)
|
||||
{
|
||||
itemTier = 2;
|
||||
return false;
|
||||
}
|
||||
if (i == Item.getItemFromBlock(Blocks.PLANKS) || i == Item.getItemFromBlock(Blocks.COBBLESTONE) || i == Item.getItemFromBlock(Blocks.WOOL))
|
||||
{
|
||||
itemTier = 1;
|
||||
return false;
|
||||
}
|
||||
NonNullList<ItemStack> copper = OreDictionary.getOres("ingotCopper");
|
||||
for (ItemStack s : copper)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> tin = OreDictionary.getOres("ingotTin");
|
||||
for (ItemStack s : tin)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> silver = OreDictionary.getOres("ingotSilver");
|
||||
for (ItemStack s : silver)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> lead = OreDictionary.getOres("ingotLead");
|
||||
for (ItemStack s : lead)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> aluminum = OreDictionary.getOres("ingotAluminum");
|
||||
for (ItemStack s : aluminum)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> silicon = OreDictionary.getOres("silicon");
|
||||
for (ItemStack s : silicon)
|
||||
{
|
||||
if (s.getItem().getRegistryName() == stack.getItem().getRegistryName())
|
||||
{
|
||||
if (s.getMetadata() == stack.getMetadata())
|
||||
{
|
||||
itemTier = 3;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Invalid replicator item!");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transmitter can transmit an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canReplicate()
|
||||
{
|
||||
if (replicatorItemStacks.get(0).isEmpty() || invalidReplicatorItem(replicatorItemStacks.get(0)))
|
||||
if (replicatorItemStacks.get(0).isEmpty() || replicatorItems.replicatorItem(this,replicatorItemStacks.get(0)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
@ -110,6 +111,7 @@ public class SolarPanelTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
// Add energy to the buffer
|
||||
private void addEnergy()
|
||||
{
|
||||
if (world.canBlockSeeSky(pos.offset(EnumFacing.UP)))
|
||||
|
@ -125,6 +127,7 @@ public class SolarPanelTileEntity extends TileEntity implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
// Distributes energy
|
||||
private void doWork()
|
||||
{
|
||||
boolean connectedFE = false;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.droog71.prospect.tile_entity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import com.droog71.prospect.forge_energy.ProspectEnergyStorage;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class TransformerTileEntity extends TileEntity implements ITickable
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) //Everything is done on the server.
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
|
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue