Added workaround for RailCraft partial IC2API
This commit is contained in:
parent
c2eeeee585
commit
d9644873cc
3 changed files with 51 additions and 64 deletions
|
@ -321,7 +321,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
GameRegistry.registerBlock(blockTransporter, "blockTransporter");
|
||||
GameRegistry.registerTileEntity(TileEntityTransporter.class, MODID + ":blockTransporter");
|
||||
|
||||
// REACTOR MONITOR
|
||||
// IC2 REACTOR LASER MONITOR
|
||||
if (WarpDriveConfig.isIndustrialCraft2loaded) {
|
||||
blockIC2reactorLaserMonitor = new BlockIC2reactorLaserMonitor(Material.rock);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import cr0s.warpdrive.data.Vector3;
|
||||
|
@ -32,6 +33,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
|
|||
private static int[] deltaZ = { 0, 0, 0, 0,-2, 2};
|
||||
|
||||
// returns IReactor tile entities
|
||||
@Optional.Method(modid = "IC2")
|
||||
private Set<IReactor> findReactors() {
|
||||
Set<IReactor> output = new HashSet<IReactor>();
|
||||
|
||||
|
@ -64,6 +66,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
|
|||
return output;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
private boolean coolReactor(IReactor reactor) {
|
||||
boolean didCoolReactor = false;
|
||||
for(int x = 0; x < 9 && !didCoolReactor; x++) {
|
||||
|
@ -87,6 +90,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
|
@ -122,6 +126,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public String getStatus() {
|
||||
Set<IReactor> reactors = findReactors();
|
||||
return getBlockType().getLocalizedName()
|
||||
|
|
|
@ -9,14 +9,12 @@ import net.minecraft.item.ItemStack;
|
|||
import cr0s.warpdrive.WarpDrive;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "ic2.api.reactor.IReactorComponent", modid = "IC2API")
|
||||
})
|
||||
public class ItemIC2reactorLaserFocus extends Item implements IReactorComponent
|
||||
{
|
||||
@Optional.Interface(iface = "ic2.api.reactor.IReactorComponent", modid = "IC2")
|
||||
})
|
||||
public class ItemIC2reactorLaserFocus extends Item implements IReactorComponent {
|
||||
private final static int maxHeat = 3000;
|
||||
|
||||
public ItemIC2reactorLaserFocus()
|
||||
{
|
||||
public ItemIC2reactorLaserFocus() {
|
||||
super();
|
||||
setMaxDamage(maxHeat);
|
||||
setCreativeTab(WarpDrive.creativeTabWarpDrive);
|
||||
|
@ -24,121 +22,105 @@ public class ItemIC2reactorLaserFocus extends Item implements IReactorComponent
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon("warpdrive:reactorFocus");
|
||||
}
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
this.itemIcon = par1IconRegister.registerIcon("warpdrive:reactorFocus");
|
||||
}
|
||||
|
||||
private static void damageComponent(ItemStack self,int damage)
|
||||
{
|
||||
//WarpDrive.debugPrint("ReactorCompDamage:" + damage);
|
||||
private static void damageComponent(ItemStack self, int damage) {
|
||||
int currDamage = self.getItemDamage();
|
||||
int nextDamage = Math.min(maxHeat,Math.max(0, currDamage + damage));
|
||||
int nextDamage = Math.min(maxHeat, Math.max(0, currDamage + damage));
|
||||
self.setItemDamage(nextDamage);
|
||||
}
|
||||
|
||||
private static void balanceComponent(ItemStack self, ItemStack other)
|
||||
{
|
||||
private static void balanceComponent(ItemStack self, ItemStack other) {
|
||||
final int selfBalance = 4;
|
||||
int otherDamage = other.getItemDamage();
|
||||
int myDamage = self.getItemDamage();
|
||||
int newOne = (otherDamage + (selfBalance-1)*myDamage) / selfBalance;
|
||||
int newOne = (otherDamage + (selfBalance - 1) * myDamage) / selfBalance;
|
||||
int newTwo = otherDamage - (newOne - myDamage);
|
||||
self.setItemDamage(newTwo);
|
||||
other.setItemDamage(newOne);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
private static void coolComponent(ItemStack self, IReactorComponent comp, IReactor reactor, ItemStack stack, int x, int y)
|
||||
{
|
||||
private static void coolComponent(ItemStack self, IReactorComponent comp, IReactor reactor, ItemStack stack, int x, int y) {
|
||||
int maxTransfer = maxHeat - self.getItemDamage();
|
||||
int compHeat = comp.getCurrentHeat(reactor, stack, x, y);
|
||||
int transferHeat = - Math.min(compHeat,maxTransfer);
|
||||
int transferHeat = -Math.min(compHeat, maxTransfer);
|
||||
int retained = comp.alterHeat(reactor, stack, x, y, transferHeat);
|
||||
damageComponent(self,retained - transferHeat);
|
||||
damageComponent(self, retained - transferHeat);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
private static void coolReactor(IReactor reactor, ItemStack stack)
|
||||
{
|
||||
private static void coolReactor(IReactor reactor, ItemStack stack) {
|
||||
int reactorHeat = reactor.getHeat();
|
||||
int myHeat = stack.getItemDamage();
|
||||
int transfer = Math.min(maxHeat - myHeat,reactorHeat);
|
||||
int transfer = Math.min(maxHeat - myHeat, reactorHeat);
|
||||
reactor.addHeat(-transfer);
|
||||
damageComponent(stack,transfer);
|
||||
damageComponent(stack, transfer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun)
|
||||
{
|
||||
if(heatrun)
|
||||
{
|
||||
int[] xDif = {-1,0,0,1};
|
||||
int[] yDif = {0,-1,1,0};
|
||||
for(int i=0;i<xDif.length;i++)
|
||||
{
|
||||
public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun) {
|
||||
if (heatrun) {
|
||||
int[] xDif = { -1, 0, 0, 1 };
|
||||
int[] yDif = { 0, -1, 1, 0 };
|
||||
for (int i = 0; i < xDif.length; i++) {
|
||||
int iX = x + xDif[i];
|
||||
int iY = y + yDif[i];
|
||||
ItemStack stack = reactor.getItemAt(iX,iY);
|
||||
if(stack != null)
|
||||
{
|
||||
ItemStack stack = reactor.getItemAt(iX, iY);
|
||||
if (stack != null) {
|
||||
Item item = stack.getItem();
|
||||
if(item instanceof ItemIC2reactorLaserFocus)
|
||||
balanceComponent(yourStack,stack);
|
||||
else if(item instanceof IReactorComponent)
|
||||
coolComponent(yourStack,(IReactorComponent) item, reactor, stack, iX, iY);
|
||||
if (item instanceof ItemIC2reactorLaserFocus) {
|
||||
balanceComponent(yourStack, stack);
|
||||
} else if (item instanceof IReactorComponent) {
|
||||
coolComponent(yourStack, (IReactorComponent) item, reactor, stack, iX, iY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coolReactor(reactor,yourStack);
|
||||
coolReactor(reactor, yourStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack,ItemStack pulsingStack,
|
||||
int youX, int youY, int pulseX, int pulseY, boolean heatrun)
|
||||
{
|
||||
public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y)
|
||||
{
|
||||
public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y)
|
||||
{
|
||||
public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y) {
|
||||
return maxHeat;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y)
|
||||
{
|
||||
public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y) {
|
||||
return yourStack.getItemDamage();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat)
|
||||
{
|
||||
public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat) {
|
||||
//WarpDrive.debugPrint("ReactorLaserAlter:" + heat);
|
||||
int transferred = Math.min(heat, maxHeat - yourStack.getItemDamage());
|
||||
damageComponent(yourStack,transferred);
|
||||
damageComponent(yourStack, transferred);
|
||||
return heat - transferred;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public float influenceExplosion(IReactor reactor, ItemStack yourStack)
|
||||
{
|
||||
public float influenceExplosion(IReactor reactor, ItemStack yourStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue