RF support, critical bugfixes.

This commit is contained in:
Dragon2488 2017-01-08 15:49:39 +07:00
parent f8515e3b60
commit 317deb43a1
13 changed files with 67 additions and 73 deletions

View file

@ -1,7 +1,7 @@
minecraft.version=1.10.2
forge.version=12.18.1.2079
gt.version=5.10.33
gt.version=5.10.34
forestry.version=5.2.7.220
ic2.version=2.6.99-ex110

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -3,8 +3,11 @@ package gregtech.api.interfaces.tileentity;
import cofh.api.energy.IEnergyReceiver;
import gregtech.api.GregTech_API;
import gregtech.api.util.GT_Utility;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.tile.IEnergyStorage;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
@ -19,7 +22,7 @@ import static gregtech.api.enums.GT_Values.V;
* IColoredTileEntity is needed for not connecting differently coloured Blocks to each other.
* IHasWorldObjectAndCoords is needed for the InWorld related Stuff. @BaseTileEntity does implement most of that Interface.
*/
public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAndCoords, IEnergyEmitter {
public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAndCoords, IEnergyAcceptor, IEnergyEmitter {
/**
* Inject Energy Call for Electricity. Gets called by EnergyEmitters to inject Energy into your Block
* <p/>
@ -67,14 +70,12 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd
rUsedAmperes++;
}
} else if (tTileEntity instanceof IEnergyReceiver) {
System.out.println("Receive");
EnumFacing tDirection = EnumFacing.VALUES[i].getOpposite();
int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
rUsedAmperes++;
}
System.out.println(rUsedAmperes);
if (GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
if (rfOut > 32 * GregTech_API.mEUtoRF / 100) {
int aExplosionPower = rfOut;

View file

@ -150,9 +150,9 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
}
if (aStack.stackSize <= 0) {
aPlayer.setHeldItem(hand, null);
return EnumActionResult.FAIL;
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
return EnumActionResult.SUCCESS;
}
@ -169,13 +169,13 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) {
if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null);
return EnumActionResult.SUCCESS;
return EnumActionResult.PASS;
}
if (aStack.stackSize <= 0) {
aPlayer.setHeldItem(hand, null);
return EnumActionResult.SUCCESS;
return EnumActionResult.PASS;
}
return EnumActionResult.SUCCESS;
return EnumActionResult.PASS;
}
return EnumActionResult.PASS;
}

View file

@ -734,11 +734,19 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
IToolStats toolStats = getToolStats(stack);
IIconContainer head = toolStats.getIcon(true, stack);
IIconContainer handle = toolStats.getIcon(false, stack);
if(pass == 0 && handle != null) {
return handle.getIcon();
if(handle != null) {
if(pass == 0) {
return handle.getIcon();
} else if(pass == 1) {
return handle.getOverlayIcon();
}
}
if(pass == 1 && head != null) {
return head.getIcon();
if(head != null) {
if(pass == 2) {
return head.getIcon();
} else if(pass == 3) {
return head.getOverlayIcon();
}
}
return null;
}
@ -746,7 +754,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
@Override
@SideOnly(Side.CLIENT)
public int getRenderPasses(ItemStack stack) {
return 2;
return 4;
}
@Override

View file

@ -12,6 +12,7 @@ import gregtech.api.net.GT_Packet_TileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.*;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@ -1398,6 +1399,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
return true;
}
@Override
public boolean acceptsEnergyFrom(IEnergyEmitter iEnergyEmitter, EnumFacing enumFacing) {
return true;
}
@Override
public IFluidTankProperties[] getTankProperties() {
if(mMetaTileEntity != null) {

View file

@ -14,6 +14,7 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.*;
import gregtech.common.GT_Pollution;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.info.Info;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
@ -25,12 +26,12 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@ -279,7 +280,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
boolean aSideServer = isServerSide();
boolean aSideClient = isClientSide();
if (aSideServer && mTickTimer % 10 == 0) {
if (aSideServer && mTickTimer % 40 == 0) {
NW.sendToAllAround(worldObj, new GT_Packet_TileEntity(
getXCoord(), getYCoord(), getZCoord(), mID,
mCoverSides[0], mCoverSides[1], mCoverSides[2],
@ -1232,7 +1233,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
System.out.println("Screwdriver click");
setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, getXCoord(), getYCoord(), getZCoord());
@ -1605,7 +1605,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this);
if (tStack != null) {
tStack.setTagCompound(null);
EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack);
tEntity.motionX = 0;
tEntity.motionY = 0;
@ -1764,14 +1763,17 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount;
}
public boolean acceptsEnergyFrom(TileEntity aEmitter, EnumFacing aDirection) {
@Override
public boolean acceptsEnergyFrom(IEnergyEmitter aEmitter, EnumFacing aDirection) {
return inputEnergyFrom((byte) aDirection.ordinal());
}
public boolean emitsEnergyTo(TileEntity aReceiver, EnumFacing aDirection) {
@Override
public boolean emitsEnergyTo(IEnergyAcceptor aReceiver, EnumFacing aDirection) {
return outputsEnergyTo((byte) aDirection.ordinal());
}
public double getOfferedEnergy() {
return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0;
}
@ -1781,10 +1783,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
decreaseStoredEU((int) amount, true);
}
public int injectEnergy(EnumFacing aEnumFacing, int aAmount) {
return injectEnergyUnits((byte) aEnumFacing.ordinal(), aAmount, 1) > 0 ? 0 : aAmount;
}
public int addEnergy(int aEnergy) {
if (!canAccessData()) return 0;
if (aEnergy > 0)
@ -1914,11 +1912,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
}
@Override
public boolean emitsEnergyTo(IEnergyAcceptor iEnergyAcceptor, EnumFacing enumFacing) {
return true;
}
@Override
public String getName() {
return mMetaTileEntity.getName();

View file

@ -1,6 +1,8 @@
package gregtech.api.metatileentity.implementations;
import cofh.api.energy.IEnergyReceiver;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.Materials;
import gregtech.api.enums.TextureSet;
@ -15,6 +17,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -190,26 +193,21 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
} else {
rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes);
}
// } else if (tTileEntity instanceof IEnergySink) {
// EnumFacing tDirection = EnumFacing.getOrientation(i).getOpposite();
// if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
// if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++;
// }
} else if (tTileEntity instanceof IEnergySink) {
EnumFacing tDirection = EnumFacing.VALUES[i].getOpposite();
if (((IEnergySink) tTileEntity).acceptsEnergyFrom(getBaseMetaTileEntity(), tDirection)) {
if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage)
rUsedAmperes++;
}
} /*else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
EnumFacing tDirection = EnumFacing.getOrientation(i).getOpposite();
} else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
EnumFacing tDirection = EnumFacing.VALUES[i].getOpposite();
int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
rUsedAmperes++;
} else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) {
if (mRestRF == 0) {
int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) rfOut, false);
int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
rUsedAmperes++;
mRestRF = rfOut - RFtrans;
} else {
@ -220,7 +218,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
if (GregTech_API.mRFExplosions && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
if (rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
}
}*/
}
}
}
mTransferredAmperage += rUsedAmperes;
@ -267,16 +265,15 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
mConnections |= (1 << i);
}
//if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(EnumFacing.getOrientation(j))) {
// mConnections |= (1 << i);
// continue;
//}
/*
if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(EnumFacing.VALUES[j])) {
mConnections |= (1 << i);
continue;
}
if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, EnumFacing.getOrientation(j))) {
if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo(aBaseMetaTileEntity, EnumFacing.VALUES[j])) {
mConnections |= (1<<i);
continue;
}*/
}
}
}
}

View file

@ -1,5 +1,8 @@
package gregtech.api.metatileentity.implementations;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyStorage;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
@ -7,10 +10,12 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergySource;
import ic2.core.block.wiring.TileEntityElectricCESU;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import static gregtech.api.enums.GT_Values.V;
@ -136,39 +141,23 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi
for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++)
if (aBaseMetaTileEntity.inputEnergyFrom(i)) {
TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
if (tTileEntity instanceof IEnergySource && ((IEnergySource) tTileEntity).emitsEnergyTo((IEnergyAcceptor) aBaseMetaTileEntity, facing(GT_Utility.getOppositeSide(i)))) {
if (tTileEntity instanceof IEnergySource && ((IEnergySource) tTileEntity).emitsEnergyTo(aBaseMetaTileEntity, EnumFacing.VALUES[i].getOpposite())) {
long tEU = Math.min(maxEUInput(), (long) ((IEnergySource) tTileEntity).getOfferedEnergy());
((IEnergySource) tTileEntity).drawEnergy(tEU);
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, tEU, 1);
} /*else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) {
long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), (int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false);
} else if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) {
long tEU = Math.min(maxEUInput(), (long) ((ic2.api.tile.IEnergyStorage) tTileEntity).getOutput());
((ic2.api.tile.IEnergyStorage) tTileEntity).addEnergy((int) -tEU);
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, tEU, 1);
} else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(EnumFacing.VALUES[i].getOpposite(), 1, true) == 1) {
long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(EnumFacing.VALUES[i].getOpposite(), (int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false);
tEU = tEU * GregTech_API.mRFtoEU / 100;
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1);
} else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) {
long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy((int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false);
tEU = tEU * GregTech_API.mRFtoEU / 100;
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1);
} else if (GregTech_API.mInputRF && GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) {
int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored();
int extractRF = (int) maxEUInput() * 100 / GregTech_API.mRFtoEU;
long tEU = 0;
if (tTileEntity instanceof TileCapBank) {
ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork();
if (network != null && network.getEnergyStoredL() > 0) {
tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * GregTech_API.mRFtoEU / 100, maxEUInput());
network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU));
}
} else {
if (storedRF > extractRF) {
((IPowerContainer) tTileEntity).setEnergyStored(storedRF - extractRF);
tEU = maxEUInput();
} else {
((IPowerContainer) tTileEntity).setEnergyStored(0);
tEU = storedRF * GregTech_API.mRFtoEU / 100;
}
}
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1);
}*/
}
}
}
}

View file

@ -62,6 +62,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.*;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
@ -921,7 +922,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
return this.mDateFormat.format(new Date());
}
@SubscribeEvent
public void onPlayerInteraction(PlayerInteractEvent.RightClickBlock aEvent) {
ItemStack aStack = aEvent.getItemStack();
if (aStack != null && aStack.getItem() == Items.FLINT_AND_STEEL) {

View file

@ -271,10 +271,10 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
if (gregTechTileEntity.getTimer() < 50L) {
return false;
}
if (!worldIn.isRemote && gregTechTileEntity.isUseableByPlayer(playerIn)) {
gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, EnumHand.MAIN_HAND);
if (gregTechTileEntity.isUseableByPlayer(playerIn)) {
return gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, EnumHand.MAIN_HAND);
}
return true;
return false;
}