Merging DarkholmeTenk & cleanup

Updating chunkloader block
Addind decorative block
Updated registries to static (?)
Reverted interfaces back in main mod
Updated formating in TileEntityParticleBooster
Renamed BlockBeacon to BlockTransportBeacon for consistency
This commit is contained in:
LemADEC 2014-08-23 12:27:38 +02:00
parent a95a739976
commit 4284984439
37 changed files with 993 additions and 210 deletions

View file

@ -9,6 +9,12 @@ item.warpdrive.crafting.InterfacePower.name=Power Interface
item.warpdrive.crafting.PowerCore.name=Energy Core item.warpdrive.crafting.PowerCore.name=Energy Core
item.warpdrive.crafting.AirCanisterEmpty.name=Empty Air Canister item.warpdrive.crafting.AirCanisterEmpty.name=Empty Air Canister
item.warpdrive.upgrade.Power.name=Power Upgrade
item.warpdrive.upgrade.Speed.name=Speed Upgrade
item.warpdrive.upgrade.Range.name=Range Upgrade
item.warpdrive.upgrade.Energy.name=Energy Upgrade
item.warpdrive.items.ReactorLaserFocus.name=Reactor Laser Focus
item.warpdrive.items.AirCanisterFull.name=Air Canister item.warpdrive.items.AirCanisterFull.name=Air Canister
item.warpdrive.armor.Helmet.name=Warp Helmet item.warpdrive.armor.Helmet.name=Warp Helmet
@ -16,7 +22,11 @@ tile.warpdrive.blocks.Air.name=Air Block
tile.warpdrive.blocks.Gas.name=Gas Block tile.warpdrive.blocks.Gas.name=Gas Block
tile.warpdrive.blocks.WarpIsolation.name=Warp-field Isolation Block tile.warpdrive.blocks.WarpIsolation.name=Warp-field Isolation Block
tile.warpdrive.blocks.IridiumBlock.name=Iridium Block tile.warpdrive.blocks.IridiumBlock.name=Iridium Block
item.warpdrive.items.ReactorLaserFocus.name=Reactor Laser Focus
tile.warpdrive.decorative.Plain.name=Plain Block
tile.warpdrive.decorative.Energized.name=Energized Block
tile.warpdrive.decorative.Network.name=Network Block
tile.warpdrive.power.Reactor.name=Enantiomorphic Reactor tile.warpdrive.power.Reactor.name=Enantiomorphic Reactor
tile.warpdrive.power.Laser.name=Aurbis Reactor Stabilisation Laser tile.warpdrive.power.Laser.name=Aurbis Reactor Stabilisation Laser
tile.warpdrive.power.Store.name=Anuic Energy Store tile.warpdrive.power.Store.name=Anuic Energy Store
@ -36,4 +46,5 @@ tile.warpdrive.machines.LaserLift.name=Laser Lift
tile.warpdrive.machines.Transporter.name=Transporter tile.warpdrive.machines.Transporter.name=Transporter
tile.warpdrive.machines.Scanner.name=Ship Scanner tile.warpdrive.machines.Scanner.name=Ship Scanner
tile.warpdrive.machines.AirGenerator.name=Air Generator tile.warpdrive.machines.AirGenerator.name=Air Generator
tile.warpdrive.machines.ChunkLoader.name=Chunk Loader
tile.warpdrive.machines.LaserReactorMonitor.name=Laser Reactor Monitor tile.warpdrive.machines.LaserReactorMonitor.name=Laser Reactor Monitor

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

View file

@ -35,9 +35,12 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
@ -88,9 +91,12 @@ public class WarpDrive implements LoadingCallback {
public static Block iridiumBlock; public static Block iridiumBlock;
public static Block transportBeaconBlock; public static Block transportBeaconBlock;
public static Block chunkLoaderBlock;
public static BlockDecorative decorativeBlock;
public static Item reactorLaserFocusItem; public static Item reactorLaserFocusItem;
public static ItemWarpComponent componentItem; public static ItemWarpComponent componentItem;
public static ItemWarpUpgrade upgradeItem;
public static EnumArmorMaterial armorMaterial = EnumHelper.addArmorMaterial("WARP", 5, new int[]{1, 3, 2, 1}, 15); public static EnumArmorMaterial armorMaterial = EnumHelper.addArmorMaterial("WARP", 5, new int[]{1, 3, 2, 1}, 15);
public static ItemWarpArmor helmetItem; public static ItemWarpArmor helmetItem;
@ -113,12 +119,11 @@ public class WarpDrive implements LoadingCallback {
@SidedProxy(clientSide = "cr0s.WarpDrive.client.ClientProxy", serverSide = "cr0s.WarpDrive.CommonProxy") @SidedProxy(clientSide = "cr0s.WarpDrive.client.ClientProxy", serverSide = "cr0s.WarpDrive.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
public WarpCoresRegistry warpCores; public static WarpCoresRegistry warpCores;
public JumpgatesRegistry jumpgates; public static JumpgatesRegistry jumpgates;
public static CloakManager cloaks;
public CloakManager cloaks; public static CamRegistry cams;
public CamRegistry cams;
public boolean isOverlayEnabled = false; public boolean isOverlayEnabled = false;
public int overlayType = 0; public int overlayType = 0;
public String debugMessage = ""; public String debugMessage = "";
@ -127,8 +132,7 @@ public class WarpDrive implements LoadingCallback {
public static String defHelpStr = "help(\"functionName\"): returns help for the function specified"; public static String defHelpStr = "help(\"functionName\"): returns help for the function specified";
public static String defEnergyStr = "energy(): returns currently contained energy, max contained energy"; public static String defEnergyStr = "energy(): returns currently contained energy, max contained energy";
public static String defUpgradeStr = "upgrades(): returns a list of currently installed upgrades";
private LinkedList<Ticket> warpTickets = new LinkedList<Ticket>();
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
@ -288,13 +292,9 @@ public class WarpDrive implements LoadingCallback {
GameRegistry.registerTileEntity(TileEntityLaserReactorMonitor.class,"reactorMonitor"); GameRegistry.registerTileEntity(TileEntityLaserReactorMonitor.class,"reactorMonitor");
// TRANSPORT BEACON // TRANSPORT BEACON
/*transportBeaconBlock = new BlockTransportBeacon(WarpDriveConfig.transportBeaconID) transportBeaconBlock = new BlockTransportBeacon(WarpDriveConfig.transportBeaconID);
.setHardness(0.5F)
.setStepSound(Block.soundMetalFootstep)
.setCreativeTab(CreativeTabs.tabRedstone)
.setUnlocalizedName("warpdrive.blocks.TransporterBeacon");
GameRegistry.registerBlock(transportBeaconBlock, "transportBeacon");*/ GameRegistry.registerBlock(transportBeaconBlock, "transportBeacon");
// POWER STUFF // POWER STUFF
powerReactorBlock = new BlockPowerReactor(WarpDriveConfig.powerReactorID); powerReactorBlock = new BlockPowerReactor(WarpDriveConfig.powerReactorID);
@ -307,6 +307,15 @@ public class WarpDrive implements LoadingCallback {
GameRegistry.registerBlock(powerStoreBlock,"powerStore"); GameRegistry.registerBlock(powerStoreBlock,"powerStore");
GameRegistry.registerTileEntity(TileEntityPowerStore.class, "powerStore"); GameRegistry.registerTileEntity(TileEntityPowerStore.class, "powerStore");
// CHUNK LOADER
chunkLoaderBlock = new BlockChunkLoader(WarpDriveConfig.chunkLoaderID);
GameRegistry.registerBlock(chunkLoaderBlock, "chunkLoader");
GameRegistry.registerTileEntity(TileEntityChunkLoader.class, "chunkLoader");
// DECORATIVE
decorativeBlock = new BlockDecorative(WarpDriveConfig.decorativeID);
GameRegistry.registerBlock(decorativeBlock, ItemBlockDecorative.class, "decorative");
// REACTOR LASER FOCUS // REACTOR LASER FOCUS
reactorLaserFocusItem = new ItemReactorLaserFocus(WarpDriveConfig.reactorLaserFocusID); reactorLaserFocusItem = new ItemReactorLaserFocus(WarpDriveConfig.reactorLaserFocusID);
GameRegistry.registerItem(reactorLaserFocusItem, "reactorLaserFocus"); GameRegistry.registerItem(reactorLaserFocusItem, "reactorLaserFocus");
@ -321,6 +330,9 @@ public class WarpDrive implements LoadingCallback {
airCanisterItem = new ItemWarpAirCanister(WarpDriveConfig.airCanisterID); airCanisterItem = new ItemWarpAirCanister(WarpDriveConfig.airCanisterID);
GameRegistry.registerItem(airCanisterItem, "airCanisterFull"); GameRegistry.registerItem(airCanisterItem, "airCanisterFull");
upgradeItem = new ItemWarpUpgrade(WarpDriveConfig.upgradeID);
GameRegistry.registerItem(upgradeItem, "upgrade");
proxy.registerEntities(); proxy.registerEntities();
ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance); ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance);
@ -366,6 +378,9 @@ public class WarpDrive implements LoadingCallback {
private static void initVanillaRecipes() { private static void initVanillaRecipes() {
componentItem.registerRecipes(); componentItem.registerRecipes();
decorativeBlock.initRecipes();
upgradeItem.initRecipes();
//WarpCore //WarpCore
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(warpCore), false, "ipi", "ici", "idi", GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(warpCore), false, "ipi", "ici", "idi",
'i', Item.ingotIron, 'i', Item.ingotIron,
@ -478,14 +493,14 @@ public class WarpDrive implements LoadingCallback {
'n', Item.goldNugget)); 'n', Item.goldNugget));
//Power Laser //Power Laser
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerLaserBlock), false, "iii","ilg","ici", GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerLaserBlock), false, "iii", "ilg", "ici",
'i', Item.ingotIron, 'i', Item.ingotIron,
'g', Block.glass, 'g', Block.glass,
'c', componentItem.getIS(5), 'c', componentItem.getIS(5),
'l', componentItem.getIS(3))); 'l', componentItem.getIS(3)));
//Power Reactor //Power Reactor
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerReactorBlock), false, "ipi","gog","ici", GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerReactorBlock), false, "ipi", "gog", "ici",
'i', Item.ingotIron, 'i', Item.ingotIron,
'g', Block.glass, 'g', Block.glass,
'o', componentItem.getIS(4), 'o', componentItem.getIS(4),
@ -493,12 +508,19 @@ public class WarpDrive implements LoadingCallback {
'p', componentItem.getIS(6))); 'p', componentItem.getIS(6)));
//Power Store //Power Store
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerStoreBlock), false, "ipi","isi","ici", GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerStoreBlock), false, "ipi", "isi", "ici",
'i', Item.ingotIron, 'i', Item.ingotIron,
's', componentItem.getIS(7), 's', componentItem.getIS(7),
'c', componentItem.getIS(5), 'c', componentItem.getIS(5),
'p', componentItem.getIS(6))); 'p', componentItem.getIS(6)));
//Chunk Loader
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(chunkLoaderBlock), false, "ipi", "ici", "ifi",
'i', Item.ingotIron,
'p', componentItem.getIS(6),
'c', componentItem.getIS(0),
'f', componentItem.getIS(5)));
//Helmet //Helmet
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(helmetItem), false, "iii", "iwi", "gcg", GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(helmetItem), false, "iii", "iwi", "gcg",
'i', Item.ingotIron, 'i', Item.ingotIron,
@ -701,45 +723,12 @@ public class WarpDrive implements LoadingCallback {
event.registerServerCommand(new DebugCommand()); event.registerServerCommand(new DebugCommand());
} }
private ArrayList<Ticket> worldTickets(World worldObj) {
ArrayList<Ticket> worldTicks = new ArrayList<Ticket>(warpTickets.size());
for(Ticket t: warpTickets) {
if (t.world.equals(worldObj)) {
worldTicks.add(t);
}
}
return worldTicks;
}
public Ticket registerChunkLoadTE(WarpChunkTE te, boolean refreshLoading) { public Ticket registerChunkLoadTE(WarpChunkTE te, boolean refreshLoading) {
World worldObj = te.worldObj; World worldObj = te.worldObj;
ArrayList<Ticket> worldTicks = worldTickets(worldObj); if (ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0)
boolean isWorldTicketed = worldTicks.size() != 0;
if(isWorldTicketed)
{
if(ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0)
{
Ticket t = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL);
if(t != null)
{
te.giveTicket(t); // FIXME calling the caller is a bad idea
if(refreshLoading)
te.refreshLoading();
return t;
}
else {
WarpDrive.debugPrint("Ticket not granted");
}
}
else {
WarpDrive.debugPrint("No tickets left!");
}
}
else
{ {
Ticket t = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL); Ticket t = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL);
if(t != null) if (t != null) {
{
te.giveTicket(t); // FIXME calling the caller is a bad idea te.giveTicket(t); // FIXME calling the caller is a bad idea
if(refreshLoading) if(refreshLoading)
te.refreshLoading(); te.refreshLoading();
@ -750,31 +739,57 @@ public class WarpDrive implements LoadingCallback {
WarpDrive.debugPrint("Ticket not granted"); WarpDrive.debugPrint("Ticket not granted");
} }
} }
else
{
WarpDrive.debugPrint("No tickets left!");
}
return null; return null;
} }
public Ticket registerChunkLoadTE(WarpChunkTE te) public Ticket registerChunkLoadTE(WarpChunkTE te)
{ {
return registerChunkLoadTE(te,true); return registerChunkLoadTE(te, true);
} }
public Ticket getTicket(WarpChunkTE te) public Ticket getTicket(WarpChunkTE te)
{ {
return registerChunkLoadTE(te,false); return registerChunkLoadTE(te, false);
}
public void removeTicket(Ticket t)
{
for(Ticket ticket:warpTickets)
if(t.equals(ticket))
warpTickets.remove(ticket);
} }
@Override @Override
public void ticketsLoaded(List<Ticket> tickets, World world) public void ticketsLoaded(List<Ticket> tickets, World world)
{ {
for (Ticket ticket : tickets) for (Ticket ticket : tickets)
{
NBTTagCompound data = ticket.getModData();
if(data != null)
{
int w = data.getInteger("ticketWorldObj");
int x = data.getInteger("ticketX");
int y = data.getInteger("ticketY");
int z = data.getInteger("ticketZ");
if(w != 0 || x != 0 || y != 0 || z != 0)
{
WorldServer ws = DimensionManager.getWorld(w);
if(ws != null)
{
TileEntity te = ws.getBlockTileEntity(x, y, z);
if(te != null && te instanceof WarpChunkTE)
{
if(((WarpChunkTE)te).shouldChunkLoad())
{
WarpDrive.debugPrint("[TicketCallback] Regiving Ticket!");
((WarpChunkTE)te).giveTicket(ticket);
((WarpChunkTE)te).refreshLoading(true);
return;
}
}
}
}
}
ForgeChunkManager.releaseTicket(ticket); ForgeChunkManager.releaseTicket(ticket);
}
} }

View file

@ -1,4 +1,4 @@
package cr0s.WarpDriveCore; package cr0s.WarpDrive.api;
public interface IBlockUpdateDetector public interface IBlockUpdateDetector
{ {

View file

@ -0,0 +1,13 @@
package cr0s.WarpDrive.api;
import java.util.HashMap;
import java.util.Map;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import net.minecraft.item.ItemStack;
public interface IUpgradable
{
public boolean takeUpgrade(EnumUpgradeTypes upgradeType,boolean simulate);
public Map<EnumUpgradeTypes,Integer> getInstalledUpgrades();
}

View file

@ -1,14 +1,98 @@
package cr0s.WarpDrive.block; package cr0s.WarpDrive.block;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class BlockDecorative extends Block public class BlockDecorative extends Block
{ {
public static enum decorativeTypes { Plain , Energized , Network };
private ItemStack[] isCache = new ItemStack[decorativeTypes.values().length];
private Icon[] iconBuffer = new Icon[decorativeTypes.values().length];
public BlockDecorative(int par1, Material par2Material) public BlockDecorative(int par1)
{ {
super(par1, par2Material); super(par1, Material.iron);
setHardness(0.5f);
setStepSound(Block.soundMetalFootstep);
setCreativeTab(WarpDrive.warpdriveTab);
}
public boolean isValidDamage(int damage)
{
return damage >= 0 && damage < decorativeTypes.values().length;
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for(decorativeTypes val: decorativeTypes.values())
par3List.add(new ItemStack(par1, 1, val.ordinal()));
}
@Override
public void registerIcons(IconRegister ir)
{
for(decorativeTypes val: decorativeTypes.values())
iconBuffer[val.ordinal()] = ir.registerIcon("warpdrive:decorative" + val.toString());
}
@Override
public Icon getIcon(int side, int damage)
{
if(isValidDamage(damage))
return iconBuffer[damage];
return iconBuffer[0];
}
@Override
public int damageDropped(int damage)
{
return damage;
}
public ItemStack getIS(int damage)
{
if(!isValidDamage(damage))
return null;
if(isCache[damage] == null)
isCache[damage] = getISNoCache(damage);
return isCache[damage];
}
public ItemStack getISNoCache(int damage, int amount)
{
if(!isValidDamage(damage))
return null;
return new ItemStack(WarpDrive.decorativeBlock,amount,damage);
}
public ItemStack getISNoCache(int damage)
{
return getISNoCache(damage,1);
}
public void initRecipes()
{
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(0,8),false, "sss","scs","sss",
's', Block.stone,
'c', WarpDrive.componentItem.getIS(0)));
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(2,8),false, "sss","scs","sss",
's', getIS(0),
'c', WarpDrive.componentItem.getIS(5)));
} }
} }

View file

@ -6,14 +6,15 @@ import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockBeacon extends Block public class BlockTransportBeacon extends Block
{ {
public BlockBeacon(int par1) public BlockTransportBeacon(int par1)
{ {
super(par1, Material.iron); super(par1, Material.iron);
setHardness(0.5F); setHardness(0.5F);

View file

@ -0,0 +1,40 @@
package cr0s.WarpDrive.block;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockDecorative extends ItemBlock
{
public ItemBlockDecorative(int par1)
{
super(par1);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.block.decorative");
}
@Override
public int getMetadata (int damage)
{
return damage;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for(int i = 0; i < BlockDecorative.decorativeTypes.values().length;i++)
par3List.add(new ItemStack(par1,1,i));
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
if(itemstack == null)
return getUnlocalizedName();
return "tile.warpdrive.decorative." + BlockDecorative.decorativeTypes.values()[itemstack.getItemDamage()].toString();
}
}

View file

@ -0,0 +1,6 @@
package cr0s.WarpDrive.data;
public enum EnumUpgradeTypes
{
Power, Energy, Speed, Range;
}

View file

@ -1,19 +1,14 @@
package cr0s.WarpDrive.item; package cr0s.WarpDrive.item;
import java.util.Random;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.WarpDriveConfig;
import cr0s.WarpDrive.api.IAirCanister; import cr0s.WarpDrive.api.IAirCanister;
import cr0s.WarpDrive.api.IBreathingHelmet; import cr0s.WarpDrive.api.IBreathingHelmet;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;

View file

@ -23,7 +23,6 @@ public class ItemWarpComponent extends Item implements IAirCanister {
public ItemWarpComponent(int par1) { public ItemWarpComponent(int par1) {
super(par1); super(par1);
setHasSubtypes(true); setHasSubtypes(true);
//this.setMaxDamage(potentialUnlocalized.length);
setUnlocalizedName("warpdrive.crafting.Malformed"); setUnlocalizedName("warpdrive.crafting.Malformed");
setCreativeTab(WarpDrive.warpdriveTab); setCreativeTab(WarpDrive.warpdriveTab);

View file

@ -1,14 +1,137 @@
package cr0s.WarpDrive.item; package cr0s.WarpDrive.item;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class ItemWarpUpgrade extends Item { public class ItemWarpUpgrade extends Item
{
public static enum upgradeTypes { POWER, ENERGY, SPEED, RANGE }; private ItemStack[] isCache = new ItemStack[EnumUpgradeTypes.values().length];
private Icon[] iconBuffer = new Icon[EnumUpgradeTypes.values().length];
public ItemWarpUpgrade(int par1) public ItemWarpUpgrade(int par1)
{ {
super(par1); super(par1);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.upgrade.Malformed");
setCreativeTab(WarpDrive.warpdriveTab);
}
private boolean isValidDamage(int damage)
{
return damage >= 0 && damage < EnumUpgradeTypes.values().length;
}
public ItemStack getIS(int damage)
{
if(!isValidDamage(damage))
return null;
if(isCache[damage] == null)
isCache[damage] = getISNoCache(damage);
return isCache[damage];
}
public ItemStack getISNoCache(int damage)
{
if(!isValidDamage(damage))
return null;
return new ItemStack(WarpDrive.upgradeItem,1,damage);
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if(is == null)
return null;
int damage = is.getItemDamage();
if(isValidDamage(damage))
return "item.warpdrive.upgrade." + EnumUpgradeTypes.values()[damage].toString();
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for(int i=0;i<EnumUpgradeTypes.values().length;i++)
par3List.add(getIS(i));
}
@Override
public void addInformation(ItemStack is, EntityPlayer pl, List list, boolean par4)
{
if(is == null)
return;
int damage = is.getItemDamage();
if(damage == EnumUpgradeTypes.Energy.ordinal())
list.add("Increases the max energy of the machine");
else if(damage == EnumUpgradeTypes.Power.ordinal())
list.add( "Decreases the power usage of the machine");
else if(damage == EnumUpgradeTypes.Speed.ordinal())
list.add( "Increases the speed of the machine");
else if(damage == EnumUpgradeTypes.Range.ordinal())
list.add( "Increases the range of the machine");
}
public void initRecipes()
{
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Energy.ordinal()),false,"c","e","r",
'c', WarpDrive.componentItem.getIS(0),
'e', WarpDrive.componentItem.getIS(7),
'r', Item.redstone));
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Power.ordinal()),false,"c","e","r",
'c', WarpDrive.componentItem.getIS(0),
'e', WarpDrive.componentItem.getIS(6),
'r', Item.redstone));
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Speed.ordinal()),false,"c","e","r",
'c', WarpDrive.componentItem.getIS(0),
'e', Item.sugar,
'r', Item.redstone));
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Range.ordinal()),false,"c","e","r",
'c', WarpDrive.componentItem.getIS(0),
'e', WarpDrive.transportBeaconBlock,
'r', Item.redstone));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister ir)
{
for(EnumUpgradeTypes val : EnumUpgradeTypes.values())
{
iconBuffer[val.ordinal()] = ir.registerIcon("warpdrive:upgrade" + val.toString());
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIconFromDamage(int damage)
{
if(damage >= 0 && damage < EnumUpgradeTypes.values().length)
return iconBuffer[damage];
return iconBuffer[0];
} }
} }

View file

@ -0,0 +1,37 @@
package cr0s.WarpDrive.machines;
import cr0s.WarpDrive.machines.WarpBlockContainer;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class BlockChunkLoader extends WarpBlockContainer
{
Icon iconBuffer;
public BlockChunkLoader(int par1)
{
super(par1);
setUnlocalizedName("warpdrive.machines.ChunkLoader");
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityChunkLoader();
}
@Override
public void registerIcons(IconRegister ir)
{
iconBuffer = ir.registerIcon("warpdrive:chunkLoader");
}
@Override
public Icon getIcon(int side, int damage)
{
return iconBuffer;
}
}

View file

@ -2,9 +2,6 @@ package cr0s.WarpDrive.machines;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;

View file

@ -2,9 +2,6 @@ package cr0s.WarpDrive.machines;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;

View file

@ -6,22 +6,18 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockTransporter extends BlockContainer { public class BlockTransporter extends WarpBlockContainer {
private Icon[] iconBuffer; private Icon[] iconBuffer;
public BlockTransporter(int par1, Material par2Material) { public BlockTransporter(int par1, Material par2Material) {
super(par1, par2Material); super(par1, par2Material);
setHardness(0.5F);
setStepSound(Block.soundMetalFootstep);
setCreativeTab(WarpDrive.warpdriveTab);
setUnlocalizedName("warpdrive.machines.Transporter"); setUnlocalizedName("warpdrive.machines.Transporter");
} }
@ -48,20 +44,4 @@ public class BlockTransporter extends BlockContainer {
return iconBuffer[2]; return iconBuffer[2];
} }
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3) {
return this.blockID;
}
} }

View file

@ -0,0 +1,257 @@
package cr0s.WarpDrive.machines;
import java.util.Map;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.Chunk;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.WarpDriveConfig;
import cr0s.WarpDrive.api.IUpgradable;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityChunkLoader extends WarpChunkTE implements IPeripheral, IUpgradable
{
private boolean canLoad = false;
private boolean shouldLoad = false;
private boolean inited = false;
private ChunkCoordIntPair myChunk;
int negDX, posDX, negDZ, posDZ;
int area = 1;
private String[] methodArray = {
"energy",
"radius",
"bounds",
"active",
"upgrades",
"help"
};
{
negDX = 0;
negDZ = 0;
posDX = 0;
posDZ = 0;
}
@Override
public int getMaxEnergyStored()
{
return WarpDriveConfig.CL_MAX_ENERGY;
}
@Override
public boolean shouldChunkLoad()
{
return shouldLoad && canLoad;
}
@Override
public void updateEntity()
{
super.updateEntity();
if(!inited)
{
inited = true;
myChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair();
changedDistance();
}
if(shouldLoad)
{
canLoad = consumeEnergy(area * WarpDriveConfig.CL_RF_PER_CHUNKTICK, false);
}
else
{
canLoad = consumeEnergy(area * WarpDriveConfig.CL_RF_PER_CHUNKTICK, true);
}
}
private int clampDistance(int dis)
{
return clamp(dis,0,WarpDriveConfig.CL_MAX_DISTANCE);
}
private void changedDistance()
{
if(worldObj == null) {
return;
}
if (myChunk == null) {
Chunk aChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord);
if (aChunk != null) {
myChunk = aChunk.getChunkCoordIntPair();
} else {
return;
}
}
negDX = -clampDistance(negDX);
posDX = clampDistance(posDX);
negDZ = -clampDistance(negDZ);
posDZ = clampDistance(posDZ);
minChunk = new ChunkCoordIntPair(myChunk.chunkXPos+negDX,myChunk.chunkZPos+negDZ);
maxChunk = new ChunkCoordIntPair(myChunk.chunkXPos+posDX,myChunk.chunkZPos+posDZ);
area = (posDX - negDX + 1) * (posDZ - negDZ + 1);
refreshLoading(true);
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
negDX = nbt.getInteger("negDX");
negDZ = nbt.getInteger("negDZ");
posDX = nbt.getInteger("posDX");
posDZ = nbt.getInteger("posDZ");
changedDistance();
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setInteger("negDX", negDX);
nbt.setInteger("negDZ", negDZ);
nbt.setInteger("posDX", posDX);
nbt.setInteger("posDZ", posDZ);
}
@Override
public String getType()
{
return "warpdriveChunkloader";
}
@Override
public String[] getMethodNames()
{
return methodArray;
}
private String helpStr(Object[] args)
{
if(args.length == 1)
{
String m = args[0].toString().toLowerCase();
if(m.equals("energy"))
return WarpDrive.defEnergyStr;
else if(m.equals("radius"))
return "radius(int): sets the radius in chunks";
else if(m.equals("bounds"))
return "bounds(int,int,int,int): sets the bounds of chunks to load\nbounds(): returns the 4 bounds\nFormat is -X, +X, -Z, +Z";
else if(m.equals("active"))
return "active(): returns whether active or not\nactive(boolean): sets whether it should be active or not";
else if(m.equals("upgrades"))
return WarpDrive.defUpgradeStr;
}
return WarpDrive.defHelpStr;
}
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
{
String meth = methodArray[method];
if(meth.equals("energy"))
return getEnergyObject();
else if(meth.equals("radius"))
{
if(arguments.length == 1)
{
int dist = toInt(arguments[0]);
negDX = dist;
negDZ = dist;
posDX = dist;
posDZ = dist;
changedDistance();
return new Object[] { true };
}
return new Object[] { false };
}
else if(meth.equals("bounds"))
{
if(arguments.length == 4)
{
negDX = toInt(arguments[0]);
posDX = toInt(arguments[1]);
negDZ = toInt(arguments[2]);
posDZ = toInt(arguments[3]);
changedDistance();
}
return new Object[] { negDX, posDX, negDZ, posDZ };
}
else if(meth.equals("active"))
{
if(arguments.length == 1)
shouldLoad = toBool(arguments[0]);
return new Object[] { shouldChunkLoad() };
}
else if(meth.equals("upgrades"))
{
return getUpgrades();
}
else if(meth.equals("help"))
{
return new Object[] {helpStr(arguments) };
}
return null;
}
@Override
public void attach(IComputerAccess computer)
{
}
@Override
public void detach(IComputerAccess computer)
{
}
@Override
public boolean equals(IPeripheral other)
{
return false;
}
@Override
public boolean takeUpgrade(EnumUpgradeTypes upgradeType, boolean simulate)
{
int max = 0;
if(upgradeType == EnumUpgradeTypes.Energy)
max = 2;
else if(upgradeType == EnumUpgradeTypes.Power)
max = 2;
if(max == 0)
return false;
if(upgrades.containsKey(upgradeType))
if(upgrades.get(upgradeType) >= max)
return false;
if(!simulate)
{
int c = 0;
if(upgrades.containsKey(upgradeType))
c = upgrades.get(upgradeType);
upgrades.put(upgradeType, c+1);
}
return true;
}
@Override
public Map<EnumUpgradeTypes, Integer> getInstalledUpgrades()
{
return upgrades;
}
}

View file

@ -70,7 +70,7 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
updateTicks = ((tier == 1) ? 20 : (tier == 2) ? 10 : 20) * WarpDriveConfig.CD_FIELD_REFRESH_INTERVAL_SECONDS; // resetting timer updateTicks = ((tier == 1) ? 20 : (tier == 2) ? 10 : 20) * WarpDriveConfig.CD_FIELD_REFRESH_INTERVAL_SECONDS; // resetting timer
isValid = validateAssembly(); isValid = validateAssembly();
isCloaking = WarpDrive.instance.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord); isCloaking = WarpDrive.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord);
if (!isEnabled) {// disabled if (!isEnabled) {// disabled
if (isCloaking) {// disabled, cloaking => stop cloaking if (isCloaking) {// disabled, cloaking => stop cloaking
WarpDrive.debugPrint("" + this + " Disabled, cloak field going down..."); WarpDrive.debugPrint("" + this + " Disabled, cloak field going down...");
@ -85,14 +85,14 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
setCoilsState(true); setCoilsState(true);
// Register cloak // Register cloak
WarpDrive.instance.cloaks.addCloakedAreaWorld(worldObj, minX, minY, minZ, maxX, maxY, maxZ, xCoord, yCoord, zCoord, tier); WarpDrive.cloaks.addCloakedAreaWorld(worldObj, minX, minY, minZ, maxX, maxY, maxZ, xCoord, yCoord, zCoord, tier);
if (!soundPlayed) { if (!soundPlayed) {
soundPlayed = true; soundPlayed = true;
worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:cloak", 4F, 1F); worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:cloak", 4F, 1F);
} }
// Refresh the field // Refresh the field
CloakedArea area = WarpDrive.instance.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord); CloakedArea area = WarpDrive.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord);
if (area != null) { if (area != null) {
area.sendCloakPacketToPlayersEx(false); // recloak field area.sendCloakPacketToPlayersEx(false); // recloak field
} }
@ -108,7 +108,7 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
if (hasEnoughPower) {// enabled, cloaking and able to if (hasEnoughPower) {// enabled, cloaking and able to
// IDLE // IDLE
// Refresh the field !!! LemTest 2014-07-12 // Refresh the field !!! LemTest 2014-07-12
CloakedArea area = WarpDrive.instance.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord); CloakedArea area = WarpDrive.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord);
if (area != null) { if (area != null) {
area.sendCloakPacketToPlayersEx(false); // recloak field area.sendCloakPacketToPlayersEx(false); // recloak field
} }
@ -228,8 +228,8 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
public void disableCloakingField() { public void disableCloakingField() {
setCoilsState(false); setCoilsState(false);
if (WarpDrive.instance.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord)) { if (WarpDrive.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord)) {
WarpDrive.instance.cloaks.removeCloakedArea(worldObj, xCoord, yCoord, zCoord); WarpDrive.cloaks.removeCloakedArea(worldObj, xCoord, yCoord, zCoord);
if (!soundPlayed) { if (!soundPlayed) {
soundPlayed = true; soundPlayed = true;

View file

@ -9,6 +9,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cofh.api.transport.IItemConduit;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid; import net.minecraft.block.BlockFluid;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -17,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import appeng.api.WorldCoord; import appeng.api.WorldCoord;
@ -243,13 +245,28 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
List<ItemStack> stacks = getItemStackFromBlock(valuable.intX(), valuable.intY(), valuable.intZ(), blockID, blockMeta); List<ItemStack> stacks = getItemStackFromBlock(valuable.intX(), valuable.intY(), valuable.intZ(), blockID, blockMeta);
if (stacks != null) { if (stacks != null) {
boolean overflow = false; boolean overflow = false;
int qtyLeft = 0;
ItemStack stackLeft = null;
for (ItemStack stack : stacks) { for (ItemStack stack : stacks) {
if (grid != null && AENetworkReady) { qtyLeft = putInGrid(stack);
putInGrid(stack); /* if (qtyLeft > 0) { // FIXME: untested
} else { stackLeft = copyWithSize(stack, qtyLeft);
if (!putInChest(findChest(), stack)) { qtyLeft = putInPipe(stackLeft);
WarpDrive.debugPrint("" + this + " Overflow detected"); }/**/
overflow = true; if (qtyLeft > 0) {
stackLeft = copyWithSize(stack, qtyLeft);
qtyLeft = putInChest(findChest(), stackLeft);
}
if (qtyLeft > 0) {
WarpDrive.debugPrint("" + this + " Overflow detected");
overflow = true;
int transfer;
while (qtyLeft > 0) {
transfer = Math.min(qtyLeft, stack.getMaxStackSize());
ItemStack dropItemStack = copyWithSize(stack, transfer);
EntityItem itemEnt = new EntityItem(worldObj, xCoord + 0.5D, yCoord + 1.0D, zCoord + 0.5D, dropItemStack);
worldObj.spawnEntityInWorld(itemEnt);
qtyLeft -= transfer;
} }
} }
} }
@ -345,23 +362,38 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
return block.getBlockDropped(worldObj, i, j, k, blockMeta, 0); return block.getBlockDropped(worldObj, i, j, k, blockMeta, 0);
} }
public int putInGrid(ItemStack itemStackSource) private int putInGrid(ItemStack itemStackSource) {
{ int qtyLeft = itemStackSource.stackSize;
int transferred = itemStackSource.stackSize; if (grid != null && AENetworkReady) {
IMEInventoryHandler cellArray = grid.getCellArray(); IMEInventoryHandler cellArray = grid.getCellArray();
if (cellArray != null) if (cellArray != null) {
{ IAEItemStack ret = cellArray.addItems(Util.createItemStack(itemStackSource));
IAEItemStack ret = cellArray.addItems(Util.createItemStack(itemStackSource)); if (ret != null) {
if (ret != null) qtyLeft -= ret.getStackSize();
transferred -= ret.getStackSize(); }
} }
return transferred; }
return qtyLeft;
} }
public boolean putInChest(IInventory inventory, ItemStack itemStackSource) { private int putInPipe(ItemStack itemStackSource) {
ItemStack itemStackLeft = itemStackSource.copy();
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = worldObj.getBlockTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (te != null && te instanceof IItemConduit) {
WarpDrive.debugPrint("dumping to pipe");
itemStackLeft = ((IItemConduit)te).insertItem(direction.getOpposite(), itemStackLeft);
if (itemStackLeft == null) {
return 0;
}
}
}
return itemStackLeft.stackSize;
}
private int putInChest(IInventory inventory, ItemStack itemStackSource) {
if (itemStackSource == null) { if (itemStackSource == null) {
stop(); return 0;
return false;
} }
int qtyLeft = itemStackSource.stackSize; int qtyLeft = itemStackSource.stackSize;
@ -383,7 +415,7 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
itemStack.stackSize += transfer; itemStack.stackSize += transfer;
qtyLeft -= transfer; qtyLeft -= transfer;
if (qtyLeft <= 0) { if (qtyLeft <= 0) {
return true; return 0;
} }
} }
@ -404,20 +436,12 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
qtyLeft -= transfer; qtyLeft -= transfer;
if (qtyLeft <= 0) { if (qtyLeft <= 0) {
return true; return 0;
} }
} }
} }
while (qtyLeft > 0) { return qtyLeft;
transfer = Math.min(qtyLeft, itemStackSource.getMaxStackSize());
ItemStack dropItemStack = copyWithSize(itemStackSource, transfer);
EntityItem itemEnt = new EntityItem(worldObj, xCoord + 0.5D, yCoord + 1.0D, zCoord + 0.5D, dropItemStack);
worldObj.spawnEntityInWorld(itemEnt);
qtyLeft -= transfer;
}
return false;
} }
public static ItemStack copyWithSize(ItemStack itemStack, int newSize) public static ItemStack copyWithSize(ItemStack itemStack, int newSize)

View file

@ -6,49 +6,49 @@ import net.minecraftforge.common.ForgeDirection;
import cr0s.WarpDrive.*; import cr0s.WarpDrive.*;
public class TileEntityParticleBooster extends WarpEnergyTE { public class TileEntityParticleBooster extends WarpEnergyTE {
private int ticks = 0; private int ticks = 0;
@Override @Override
public void updateEntity() { public void updateEntity() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return; return;
} }
super.updateEntity(); super.updateEntity();
ticks++; ticks++;
if (ticks > 20) { if (ticks > 20) {
ticks = 0; ticks = 0;
int metadata = Math.max(0, Math.min(10, Math.round((getEnergyStored() * 10) / WarpDriveConfig.PB_MAX_ENERGY_VALUE))); int metadata = Math.max(0, Math.min(10, Math.round((getEnergyStored() * 10) / getMaxEnergyStored())));
if (getBlockMetadata() != metadata) { if (getBlockMetadata() != metadata) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3);
} }
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag); super.readFromNBT(tag);
} }
@Override @Override
public void writeToNBT(NBTTagCompound tag) { public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag); super.writeToNBT(tag);
} }
// IEnergySink methods implementation // IEnergySink methods implementation
@Override @Override
public int getMaxEnergyStored() { public int getMaxEnergyStored() {
return WarpDriveConfig.PB_MAX_ENERGY_VALUE; return WarpDriveConfig.PB_MAX_ENERGY_VALUE;
} }
@Override @Override
public int getMaxSafeInput() { public int getMaxSafeInput() {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
@Override @Override
public boolean canInputEnergy(ForgeDirection from) { public boolean canInputEnergy(ForgeDirection from) {
return true; return true;
} }
} }

View file

@ -1,8 +1,8 @@
package cr0s.WarpDrive.machines; package cr0s.WarpDrive.machines;
import cr0s.WarpDrive.api.IBlockUpdateDetector;
import cr0s.WarpDrive.data.Vector3; import cr0s.WarpDrive.data.Vector3;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDriveCore.IBlockUpdateDetector;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;

View file

@ -7,7 +7,7 @@ import java.util.Set;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.WarpDriveConfig; import cr0s.WarpDrive.WarpDriveConfig;
import cr0s.WarpDriveCore.IBlockUpdateDetector; import cr0s.WarpDrive.api.IBlockUpdateDetector;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;

View file

@ -2,7 +2,10 @@ package cr0s.WarpDrive.machines;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import cr0s.WarpDrive.api.IUpgradable;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import cr0s.WarpDrive.data.Vector3; import cr0s.WarpDrive.data.Vector3;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.WarpDriveConfig; import cr0s.WarpDrive.WarpDriveConfig;
@ -20,11 +23,13 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral, IUpgradable
{ {
private double scanRange=2; private double scanRange=2;
private int scanDist = 4; private int scanDist = 4;
private double beaconEffect = 0;
private double powerBoost = 1; private double powerBoost = 1;
private double baseLockStrength=-1; private double baseLockStrength=-1;
private double lockStrengthMul = 1; private double lockStrengthMul = 1;
@ -46,6 +51,7 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
"energy", "energy",
"powerBoost", "powerBoost",
"energyCost", "energyCost",
"upgrades",
"help" }; "help" };
@Override @Override
@ -94,6 +100,10 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
return "powerBoost(boostAmount): sets the level of power to use (1 being default), returns the level of power\npowerBoost(): returns the level of power"; return "powerBoost(boostAmount): sets the level of power to use (1 being default), returns the level of power\npowerBoost(): returns the level of power";
} else if(fun.equals("energycost")) { } else if(fun.equals("energycost")) {
return "energyCost(): returns the amount of energy it will take for a single entity to transport with the current settings"; return "energyCost(): returns the amount of energy it will take for a single entity to transport with the current settings";
} else if(fun.equals("upgrades")) {
return WarpDrive.defUpgradeStr;
} else if(fun.equals("energy")) {
return WarpDrive.defEnergyStr;
} }
} }
return WarpDrive.defHelpStr; return WarpDrive.defHelpStr;
@ -244,32 +254,61 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
} }
} }
private double beaconScan(int xV, int yV, int zV) // FIXME: never used private double beaconScan(int xV, int yV, int zV)
{ {
WarpDrive.debugPrint("BeaconScan:" + xV + ","+yV + "," + zV);
double beacon = 0; double beacon = 0;
for(int x=xV-scanDist;x<=xV+scanDist;x++) int beaconCount = 0;
int xL = xV - scanDist;
int xU = xV + scanDist;
int yL = yV - scanDist;
int yU = yV + scanDist;
int zL = zV - scanDist;
int zU = zV + scanDist;
for(int x=xL;x<=xU;x++)
{ {
for(int y=yV-scanDist;y<=yV+scanDist;y++) for(int y=yL;y<=yU;y++)
{ {
if(y < 0 || y > 254) if(y < 0 || y > 254) {
continue; continue;
}
for(int z=xV-scanDist;z<=xV+scanDist;z++) for(int z=zL;z<=zU;z++)
{ {
if(worldObj.getBlockId(x, y, z) != WarpDriveConfig.transportBeaconID) if(worldObj.getBlockId(x, y, z) != WarpDriveConfig.transportBeaconID) {
continue; continue;
double dist = Math.abs(x - xV) + Math.abs(y - yV) + Math.abs(z - zV); }
double dist = 1 + Math.abs(x - xV) + Math.abs(y - yV) + Math.abs(z - zV);
if(worldObj.getBlockMetadata(x, y, z) == 0) beaconCount++;
if (worldObj.getBlockMetadata(x, y, z) == 0) {
beacon += 1/dist; beacon += 1/dist;
else } else {
beacon -= 1/dist; beacon -= 1/dist;
}
} }
} }
} }
if (beaconCount > 0) {
beacon /= Math.sqrt(beaconCount);
}
return beacon; return beacon;
} }
private double beaconScan(Vector3 s, Vector3 d)
{
s = absoluteVector(s);
d = absoluteVector(d);
return beaconScan(toInt(s.x),toInt(s.y),toInt(s.z)) + beaconScan(toInt(d.x),toInt(d.y),toInt(d.z));
}
private Vector3 absoluteVector(Vector3 a)
{
if(WarpDriveConfig.TR_RELATIVE_COORDS)
return a.clone().translate(new Vector3(this));
else
return a;
}
private double calculatePower(Vector3 d) private double calculatePower(Vector3 d)
{ {
Vector3 myCoords; Vector3 myCoords;
@ -283,7 +322,7 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
private static double calculatePower(Vector3 s, Vector3 d) private static double calculatePower(Vector3 s, Vector3 d)
{ {
double dist = s.distanceTo(d); double dist = s.distanceTo(d);
return clamp(Math.pow(Math.E, -dist / 100) * (1/dist),0,1); return clamp(Math.pow(Math.E, -dist / 300), 0, 1);
} }
private static double min(double... ds) private static double min(double... ds)
@ -296,7 +335,10 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
private double getLockStrength() { private double getLockStrength() {
if (isLocked) { if (isLocked) {
return clamp(baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost - 1), 0, 1); double upgradeBoost = 1;
if (upgrades.containsKey(EnumUpgradeTypes.Range))
upgradeBoost = Math.pow(1.2, upgrades.get(EnumUpgradeTypes.Range));
return clamp(baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost-1) * upgradeBoost * (1 + beaconEffect), 0, 1);
} }
return -1; return -1;
} }
@ -309,6 +351,8 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
private double lock(Vector3 source,Vector3 dest) { private double lock(Vector3 source,Vector3 dest) {
if (source != null && dest != null) { if (source != null && dest != null) {
double basePower = min(calculatePower(source),calculatePower(dest),calculatePower(source,dest)); double basePower = min(calculatePower(source),calculatePower(dest),calculatePower(source,dest));
beaconEffect = beaconScan(source, dest);
WarpDrive.debugPrint("BEACON:" + beaconEffect);
baseLockStrength = basePower; baseLockStrength = basePower;
lockStrengthMul = 1; lockStrengthMul = 1;
isLocked = true; isLocked = true;
@ -361,7 +405,11 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
@Override @Override
public int getMaxEnergyStored() { public int getMaxEnergyStored() {
return WarpDriveConfig.TR_MAX_ENERGY; int max = WarpDriveConfig.TR_MAX_ENERGY;
if (upgrades.containsKey(EnumUpgradeTypes.Energy)) {
max = (int) Math.floor(max * Math.pow(1.2, upgrades.get(EnumUpgradeTypes.Energy)));
}
return max;
} }
@Override @Override
@ -412,4 +460,38 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
public boolean equals(IPeripheral other) { public boolean equals(IPeripheral other) {
return other == this; return other == this;
} }
@Override
public boolean takeUpgrade(EnumUpgradeTypes upgradeType, boolean simulate)
{
int max = 0;
if(upgradeType == EnumUpgradeTypes.Energy)
max = 2;
else if(upgradeType == EnumUpgradeTypes.Power)
max = 4;
else if(upgradeType == EnumUpgradeTypes.Range)
max = 4;
if(max == 0)
return false;
if(upgrades.containsKey(upgradeType))
if(upgrades.get(upgradeType) >= max)
return false;
if(!simulate)
{
int c = 0;
if(upgrades.containsKey(upgradeType))
c = upgrades.get(upgradeType);
upgrades.put(upgradeType, c+1);
}
return true;
}
@Override
public Map<EnumUpgradeTypes,Integer> getInstalledUpgrades()
{
return upgrades;
}
} }

View file

@ -1,10 +1,17 @@
package cr0s.WarpDrive.machines; package cr0s.WarpDrive.machines;
import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDriveCore.IBlockUpdateDetector; import cr0s.WarpDrive.api.IBlockUpdateDetector;
import cr0s.WarpDrive.api.IUpgradable;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import cr0s.WarpDrive.item.ItemWarpUpgrade;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -15,10 +22,6 @@ public abstract class WarpBlockContainer extends BlockContainer {
protected WarpBlockContainer(int par1, Material m) { protected WarpBlockContainer(int par1, Material m) {
super(par1, m); super(par1, m);
}
//lazy constructor method. Shhhhh, everything's fine.
{
setHardness(0.5F); setHardness(0.5F);
setStepSound(Block.soundMetalFootstep); setStepSound(Block.soundMetalFootstep);
setCreativeTab(WarpDrive.warpdriveTab); setCreativeTab(WarpDrive.warpdriveTab);
@ -33,6 +36,44 @@ public abstract class WarpBlockContainer extends BlockContainer {
} }
} }
/* FIXME untested
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
boolean hasResponse = false;
TileEntity te = world.getBlockTileEntity(x, y, z);
if(te != null && te instanceof IUpgradable)
{
IUpgradable upgradable = (IUpgradable)te;
ItemStack is = player.inventory.getCurrentItem();
if(is != null)
{
Item i = is.getItem();
if(i instanceof ItemWarpUpgrade)
{
if(upgradable.takeUpgrade(EnumUpgradeTypes.values()[is.getItemDamage()],false))
{
if(!player.capabilities.isCreativeMode)
player.inventory.decrStackSize(player.inventory.currentItem, 1);
player.addChatMessage("Upgrade accepted");
}
else
{
player.addChatMessage("Upgrade declined");
}
hasResponse = true;
}
}
}
return hasResponse;
}
/**/
@Override @Override
public void onNeighborBlockChange(World w, int x, int y, int z, int b) { public void onNeighborBlockChange(World w, int x, int y, int z, int b) {
super.onNeighborBlockChange(w, x, y, z, b); super.onNeighborBlockChange(w, x, y, z, b);

View file

@ -1,10 +1,11 @@
package cr0s.WarpDrive.machines; package cr0s.WarpDrive.machines;
import java.util.ArrayList; import java.util.ArrayList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Ticket;
@ -18,7 +19,6 @@ public abstract class WarpChunkTE extends WarpEnergyTE
protected ChunkCoordIntPair maxChunk = null; protected ChunkCoordIntPair maxChunk = null;
protected boolean areChunksLoaded = false; protected boolean areChunksLoaded = false;
private boolean isRefreshing = false;
// OVERRIDES // OVERRIDES
@Override @Override
@ -73,7 +73,6 @@ public abstract class WarpChunkTE extends WarpEnergyTE
} }
ForgeChunkManager.releaseTicket(ticket); ForgeChunkManager.releaseTicket(ticket);
WarpDrive.instance.removeTicket(ticket);
} }
ticketList.clear(); ticketList.clear();
areChunksLoaded = false; areChunksLoaded = false;
@ -88,6 +87,11 @@ public abstract class WarpChunkTE extends WarpEnergyTE
} }
public void giveTicket(Ticket t) { public void giveTicket(Ticket t) {
NBTTagCompound nbt = t.getModData();
nbt.setInteger("ticketWorldObj", worldObj.provider.dimensionId);
nbt.setInteger("ticketX", xCoord);
nbt.setInteger("ticketY", yCoord);
nbt.setInteger("ticketZ", zCoord);
ticketList.add(t); ticketList.add(t);
} }
@ -163,6 +167,43 @@ public abstract class WarpChunkTE extends WarpEnergyTE
return chunkList; return chunkList;
} }
@Override
public void writeToNBT(NBTTagCompound t)
{
super.writeToNBT(t);
if(minChunk == null)
minChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair();
if(maxChunk == null)
maxChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair();
t.setInteger("minChunkX", minChunk.chunkXPos);
t.setInteger("minChunkZ", minChunk.chunkZPos);
t.setInteger("maxChunkX", maxChunk.chunkXPos);
t.setInteger("maxChunkZ", maxChunk.chunkZPos);
}
@Override
public void readFromNBT(NBTTagCompound t)
{
super.readFromNBT(t);
if(t.hasKey("minChunkX"))
{
int mx = t.getInteger("minChunkX");
int mz = t.getInteger("minChunkZ");
minChunk = new ChunkCoordIntPair(mx,mz);
mx = t.getInteger("maxChunkX");
mz = t.getInteger("maxChunkZ");
maxChunk = new ChunkCoordIntPair(mx,mz);
}
}
@Override
public void invalidate() {
super.invalidate();
for(Ticket t : ticketList) {
ForgeChunkManager.releaseTicket(t);
}
}
public ArrayList<ChunkCoordIntPair> getChunksToLoad() public ArrayList<ChunkCoordIntPair> getChunksToLoad()
{ {

View file

@ -9,7 +9,8 @@ import ic2.api.energy.tile.IEnergySource;
import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDriveCore.IBlockUpdateDetector; import cr0s.WarpDrive.api.IBlockUpdateDetector;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -23,6 +24,20 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
private int scanTickCount = -1; private int scanTickCount = -1;
private IEnergyHandler[] TE_energyHandlers = new IEnergyHandler[ForgeDirection.VALID_DIRECTIONS.length]; private IEnergyHandler[] TE_energyHandlers = new IEnergyHandler[ForgeDirection.VALID_DIRECTIONS.length];
protected HashMap<EnumUpgradeTypes,Integer> upgrades = new HashMap<EnumUpgradeTypes,Integer>();
public Object[] getUpgrades()
{
Object[] retVal = new Object[EnumUpgradeTypes.values().length];
for(EnumUpgradeTypes type : EnumUpgradeTypes.values())
{
int am = 0;
if(upgrades.containsKey(type))
am = upgrades.get(type);
retVal[type.ordinal()] = type.toString() + ":" + am;
}
return retVal;
}
// WarpDrive methods // WarpDrive methods
protected static int convertInternalToRF(int energy) { protected static int convertInternalToRF(int energy) {
@ -69,6 +84,23 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
protected boolean consumeEnergy(int amount, boolean simulate) { protected boolean consumeEnergy(int amount, boolean simulate) {
int amountUpgraded = amount;
if (upgrades.containsKey(EnumUpgradeTypes.Power)) {
double valueMul = Math.pow(0.8,upgrades.get(EnumUpgradeTypes.Power));
amountUpgraded = (int) Math.ceil(valueMul * amountUpgraded);
}
if (upgrades.containsKey(EnumUpgradeTypes.Range)) {
double valueMul = Math.pow(1.2,upgrades.get(EnumUpgradeTypes.Range));
amountUpgraded = (int) Math.ceil(valueMul * amountUpgraded);
}
if (upgrades.containsKey(EnumUpgradeTypes.Speed)) {
double valueMul = Math.pow(1.2,upgrades.get(EnumUpgradeTypes.Speed));
amountUpgraded = (int) Math.ceil(valueMul * amountUpgraded);
}
// FIXME: upgrades balancing & implementation to be done...
if (getEnergyStored() >= amount) { if (getEnergyStored() >= amount) {
if (!simulate) { if (!simulate) {
energyStored_internal -= amount; energyStored_internal -= amount;
@ -272,6 +304,14 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
if (energyStored_internal > getMaxEnergyStored()) { if (energyStored_internal > getMaxEnergyStored()) {
energyStored_internal = getMaxEnergyStored(); energyStored_internal = getMaxEnergyStored();
} }
if (tag.hasKey("upgrades")) {
NBTTagCompound upgradeTag = tag.getCompoundTag("upgrades");
for(EnumUpgradeTypes type : EnumUpgradeTypes.values()) {
if (upgradeTag.hasKey(type.toString()) && upgradeTag.getInteger(type.toString()) != 0) {
upgrades.put(type, upgradeTag.getInteger(type.toString()));
}
}
}
} }
@Override @Override
@ -281,6 +321,15 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
energyStored_internal = 0; energyStored_internal = 0;
} }
tag.setInteger("energy", this.energyStored_internal); tag.setInteger("energy", this.energyStored_internal);
if (upgrades.size() > 0) {
NBTTagCompound upgradeTag = new NBTTagCompound();
for(EnumUpgradeTypes type : EnumUpgradeTypes.values()) {
if (upgrades.containsKey(type)) {
upgradeTag.setInteger(type.toString(), upgrades.get(type));
}
}
tag.setCompoundTag("upgrades", upgradeTag);
}
} }
// WarpDrive overrides // WarpDrive overrides

View file

@ -1,9 +0,0 @@
package cr0s.WarpDriveCore;
import java.util.Map;
public interface IUpgradable
{
public boolean takeUpgrade(int upgradeType,boolean simulate); //returns whether or not the upgrade should be installed
public Map <Integer,Integer> installedUpgrades(); //returns a map in the form <UpgradeType,NumInstalled>
}