Slots fixes

Removed 0 slot from all machines
Fixed canPull & canPut stack methods
This commit is contained in:
TheDarkDnKTv 2021-04-14 02:01:26 +03:00
parent 9473d451ad
commit 1aa774e21f
11 changed files with 57 additions and 50 deletions

View file

@ -26,14 +26,14 @@ public class GT_Container_BasicMachine extends GT_ContainerMetaTile_Machine {
@Override
public void addSlots(InventoryPlayer aInventoryPlayer) {
addSlotToContainer(new Slot(mTileEntity, 1, 35, 25));
addSlotToContainer(new Slot(mTileEntity, 2, 53, 25));
addSlotToContainer(new Slot(mTileEntity, 5, 80, 63));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 3, 107, 25));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 4, 125, 25));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 44, 63, false, true, 1));
addSlotToContainer(new Slot(mTileEntity, 0, 35, 25));
addSlotToContainer(new Slot(mTileEntity, 1, 53, 25));
addSlotToContainer(new Slot(mTileEntity, 4, 80, 63));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 2, 107, 25));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 3, 125, 25));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 44, 63, false, true, 1));
}
public final SyncedField<Boolean> mOutputting = new SyncedField<Boolean>("mOutputting", Boolean.FALSE);

View file

@ -28,6 +28,11 @@ public class GT_Slot_Holo extends Slot {
return mMaxStacksize;
}
@Override
public ItemStack getStack() {
return super.getStack();
}
@Override
public boolean getHasStack() {
return false;

View file

@ -9,6 +9,7 @@ import gregtechmod.api.util.GT_ModHandler;
import gregtechmod.api.util.GT_Utility;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -22,6 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -389,6 +391,12 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
@Override
public ArrayList<String> getSpecialDebugInfo(EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) {
if (!aPlayer.worldObj.isRemote && mInventory != null) {
aList.add("Facing: " + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()));
aList.add("Inventory size: " + mInventory.length);
aList.add("Inventory: " + Arrays.toString(mInventory));
}
return aList;
}

View file

@ -1,7 +1,5 @@
package gregtechmod.api.metatileentity.examples;
import java.util.List;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
@ -9,7 +7,6 @@ import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMac
import gregtechmod.api.recipe.RecipeMap;
import gregtechmod.api.util.GT_OreDictUnificator;
import gregtechmod.api.util.GT_Utility;
import gregtechmod.api.util.ListAdapter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -90,16 +87,6 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine
getBaseMetaTileEntity().openGUI(aPlayer, 135, GregTech_API.gregtechmod);
}
@Override
public List<ItemStack> getInputItems() {
return new ListAdapter<>(mInventory, 1, 2);
}
@Override
public List<ItemStack> getOutputItems() {
return new ListAdapter<>(mInventory, 3, 4);
}
@Override
public void doSound(byte aIndex, double aX, double aY, double aZ) {
super.doSound(aIndex, aX, aY, aZ);

View file

@ -51,7 +51,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override public boolean isTransformerUpgradable() {return getElectricTier()>0;}
@Override public boolean isBatteryUpgradable() {return getElectricTier()>0;}
@Override public boolean isElectric() {return getElectricTier()>0;}
@Override public boolean isValidSlot(int aIndex) {return aIndex > 0 && aIndex < dechargerSlotStartIndex();}
@Override public boolean isValidSlot(int aIndex) {return aIndex >= 0 && aIndex < dechargerSlotStartIndex();}
@Override public boolean isFacingValid(byte aFacing) {return (mMainFacing > 1 || aFacing > 1);}
@Override public boolean isEnetInput() {return getElectricTier()>0;}
@Override public boolean isEnetOutput() {return getElectricTier()>0;}
@ -64,8 +64,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override public int maxEUStore() {return getElectricTier()*getElectricTier()*2000;}
@Override public int maxRFStore() {return maxEUStore();}
@Override public int maxSteamStore() {return maxEUStore();}
@Override public int getInvSize() {return 6;}
@Override public int dechargerSlotStartIndex() {return 5;}
@Override public int getInvSize() {return 5;}
@Override public int dechargerSlotStartIndex() {return 4;}
@Override public int dechargerSlotCount() {return getElectricTier()>0?1:0;}
@Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;}
@Override public RecipeLogic getRecipeLogic() {return recipeLogic;}
@ -173,12 +173,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override
public List<ItemStack> getInputItems() {
return new ListAdapter<>(mInventory, 1, 2);
return new ListAdapter<>(mInventory, 0, 1);
}
@Override
public List<ItemStack> getOutputItems() {
return new ListAdapter<>(mInventory, 3, 4);
return new ListAdapter<>(mInventory, 2, 3);
}
@Override
@ -342,25 +342,25 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override
public boolean allowPullStack(int aIndex, byte aSide, ItemStack aStack) {
return aSide!=mMainFacing?aIndex==3||aIndex==4:false;
return aSide!=mMainFacing?aIndex==2||aIndex==3:false;
}
@Override
public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) {
if (aSide == mMainFacing || (!bAlloyInputFromOutputSide && aSide == getBaseMetaTileEntity().getFrontFacing())) return false;
if (hasTwoSeperateInputs()&&GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[aIndex==1?2:1])) return false;
if (hasTwoSeperateInputs()&&GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[aIndex==0?1:0])) return false;
if (bSeperatedInputs) {
ForgeDirection dir = ForgeDirection.getOrientation(aSide);
ForgeDirection front = ForgeDirection.getOrientation(mMainFacing);
if (front.getRotation(ForgeDirection.UP) == dir) {
return aIndex == 1;
return aIndex == 0;
} else if (front.getRotation(ForgeDirection.DOWN) == dir) {
return aIndex == 2;
return aIndex == 1;
} else {
return false;
}
} else {
return aIndex==1||aIndex==2;
return aIndex==0||aIndex==1;
}
}
}

View file

@ -28,7 +28,7 @@ public class RecipeLogic {
public final RecipeMap<?> recipeMap;
public int MAX_FLUID_STACK = 16_000;
public int batterySlot = 5;
public int batterySlot = 4;
/** Custom fucntion called every recipe progress time update, if you want to speed up machine because of some factor, just increase the value up */
protected IntUnaryOperator progressTimeManipulator = i -> i;
protected Predicate<Recipe> metadataVerifier = recipe -> true;

View file

@ -23,8 +23,8 @@ public class GT_Container_Printer extends GT_Container_BasicMachine {
addSlotToContainer(new Slot(mTileEntity, 3, 80, 63));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 4, 107, 25));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 5, 125, 25));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 44, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 44, 63, false, true, 1));
}
}

View file

@ -30,19 +30,19 @@ public class UniversalMacerator extends GT_Container_BasicMachine {
@Override
public void addSlots(InventoryPlayer aInventoryPlayer) {
addSlotToContainer(new Slot(mTileEntity, 1, 35, 25));
addSlotToContainer(new Slot(mTileEntity, 2, 53, 25));
addSlotToContainer(new Slot(mTileEntity, 7, 80, 63));
addSlotToContainer(new Slot(mTileEntity, 0, 35, 25));
addSlotToContainer(new Slot(mTileEntity, 1, 53, 25));
addSlotToContainer(new Slot(mTileEntity, 6, 80, 63));
List<ItemStack> outputs = ((IRecipeWorkable) mTileEntity.getMetaTileEntity()).getOutputItems();
for (int i = 0; i < outputs.size(); i++) {
int xOffset = 18 * (i % 2);
int yOffset = 18 * (i / 2);
addSlotToContainer(new GT_Slot_Output(mTileEntity, 3 + i, 107 + xOffset, 16 + yOffset));
addSlotToContainer(new GT_Slot_Output(mTileEntity, 2 + i, 107 + xOffset, 16 + yOffset));
}
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 44, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 8, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 26, 63, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(mTileEntity, -1, 44, 63, false, true, 1));
}
@Override

View file

@ -28,7 +28,7 @@ public class GT_MetaTileEntity_Electrolyzer extends BasicFluidWorkable {
@Override public int getOutputSlot() {return 2;}
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 109);}
@Override public List<ItemStack> getInputItems() {return new ListAdapter<>(mInventory, 0, 1);}
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);} // TODO electrolyzer fluid slot etc
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {

View file

@ -49,7 +49,7 @@ public class GT_MetaTileEntity_Extruder extends GT_MetaTileEntity_BasicMachine {
}
public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) {
return aIndex == 1 && super.allowPutStack(aIndex, aSide, aStack);
return aIndex == 0 && super.allowPutStack(aIndex, aSide, aStack);
}
public int getTopFacingInactive() {

View file

@ -24,10 +24,17 @@ public class GT_MetaTileEntity_Pulverizer extends GT_MetaTileEntity_BasicMachine
loopLen = 290;
}
@Override public void onRightclick(EntityPlayer aPlayer) {
@Override
public void onRightclick(EntityPlayer aPlayer) {
getBaseMetaTileEntity().openGUI(aPlayer, 149);
}
@Override
protected void initRecipeLogic(RecipeMap<?> recipeMap) {
super.initRecipeLogic(recipeMap);
this.recipeLogic.batterySlot = 6;
}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Pulverizer(recipeLogic.recipeMap);
@ -48,27 +55,27 @@ public class GT_MetaTileEntity_Pulverizer extends GT_MetaTileEntity_BasicMachine
@Override
public List<ItemStack> getInputItems() {
return new ListAdapter<>(mInventory, 1, 2);
return new ListAdapter<>(mInventory, 0, 1);
}
@Override
public List<ItemStack> getOutputItems() {
return new ListAdapter<>(mInventory, 3, 6);
return new ListAdapter<>(mInventory, 2, 5);
}
@Override
public boolean allowPullStack(int aIndex, byte aSide, ItemStack aStack) {
return aSide!=mMainFacing?aIndex>=3||aIndex<8:false;
return aSide!=mMainFacing?aIndex>=2&&aIndex<7:false;
}
@Override
public int getInvSize() {
return 8;
return 7;
}
@Override
public int dechargerSlotStartIndex() {
return 7;
return 6;
}
@Override