Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update gt, rename #27

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
compileOnly("com.github.GTNewHorizons:BuildCraft:7.1.39:dev")
compileOnly('li.cil.tis3d:TIS-3D:MC1.7.10-1.2.4.70:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.04.06:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.138:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.49.56:dev')
compileOnly('com.github.GTNewHorizons:Draconic-Evolution:1.3.6-GTNH:api')
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.13.9-GTNH:api')
compileOnly('com.github.GTNewHorizons:gendustry:1.8.0-GTNH:dev')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraftforge.common.util.ForgeDirection;

import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.metatileentity.implementations.MTEBasicBatteryBuffer;
import gregtech.api.util.GTModHandler;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import li.cil.oc.api.machine.Arguments;
Expand Down Expand Up @@ -37,15 +37,14 @@ public int priority() {
doc = "function(slot:number):number; Returns the amount of stored EU in the battery in the specified slot")
public Object[] getBatteryCharge(Context c, Arguments a) {
int slot = a.checkInteger(0);
if (slot <= 0
|| slot > ((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory.length) {
if (slot <= 0 || slot > ((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory.length) {
return new Object[] { null, "slot does not exist" };
}
if (((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1] == null) {
if (((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1] == null) {
return new Object[] { null, "slot is empty" };
}
ItemStack stack = ((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1];
if (GT_ModHandler.isElectricItem(stack)) {
ItemStack stack = ((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1];
if (GTModHandler.isElectricItem(stack)) {
return new Object[] { ElectricItem.manager.getCharge(stack) };
} else {
return new Object[] { null, "item in slot is not electric" };
Expand All @@ -56,17 +55,16 @@ public Object[] getBatteryCharge(Context c, Arguments a) {
doc = "function(slot:number):number; Returns the max amount of stored EU in the battery in the specified slot")
public Object[] getMaxBatteryCharge(Context c, Arguments a) {
int slot = a.checkInteger(0);
if (slot <= 0
|| slot > ((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory.length) {
if (slot <= 0 || slot > ((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory.length) {
return new Object[] { null, "slot does not exist" };
}
// System.out.println(((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1]
// == null);
if (((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1] == null) {
if (((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1] == null) {
return new Object[] { null, "slot is empty" };
}
ItemStack stack = ((GT_MetaTileEntity_BasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1];
if (GT_ModHandler.isElectricItem(stack)) {
ItemStack stack = ((MTEBasicBatteryBuffer) tile.getMetaTileEntity()).mInventory[slot - 1];
if (GTModHandler.isElectricItem(stack)) {
return new Object[] { ((IElectricItem) stack.getItem()).getMaxCharge(stack) };
} else {
return new Object[] { null, "item in slot is not electric" };
Expand All @@ -84,8 +82,7 @@ public Class<?> getTileEntityClass() {
public boolean worksWith(World world, int x, int y, int z, ForgeDirection side) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
return (tileEntity != null) && tileEntity instanceof BaseMetaTileEntity
&& ((BaseMetaTileEntity) tileEntity)
.getMetaTileEntity() instanceof GT_MetaTileEntity_BasicBatteryBuffer;
&& ((BaseMetaTileEntity) tileEntity).getMetaTileEntity() instanceof MTEBasicBatteryBuffer;
}

@Override
Expand Down