mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
The Great Reformat; moving to google-java-style w/ 4 space indent and 120 column line wrap
This commit is contained in:
1 parent
c632cc6af9
commit
e0b7ea62a4
933 files changed
+95734
-108818
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.MekanismItems;
|
||||
@@ -21,176 +21,148 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends
|
||||
TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE> {
|
||||
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE>
|
||||
{
|
||||
public TileEntityChanceMachine(String soundPath, String name, double maxEnergy, double baseEnergyUsage, int ticksRequired, ResourceLocation location)
|
||||
{
|
||||
super(soundPath, name, maxEnergy, baseEnergyUsage, 3, ticksRequired, location);
|
||||
private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate",
|
||||
"getMaxEnergy", "getEnergyNeeded"};
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2, 4}));
|
||||
public TileEntityChanceMachine(String soundPath, String name, double maxEnergy, double baseEnergyUsage,
|
||||
int ticksRequired, ResourceLocation location) {
|
||||
super(soundPath, name, maxEnergy, baseEnergyUsage, 3, ticksRequired, location);
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[]{1}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{2, 4}));
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[]{2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
ChargeUtils.discharge(1, this);
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
RECIPE recipe = getRecipe();
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick)
|
||||
{
|
||||
setActive(true);
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
electricityStored -= energyPerTick;
|
||||
if (!world.isRemote) {
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if((operatingTicks+1) < ticksRequired)
|
||||
{
|
||||
operatingTicks++;
|
||||
}
|
||||
else {
|
||||
operate(recipe);
|
||||
RECIPE recipe = getRecipe();
|
||||
|
||||
operatingTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(prevEnergy >= getEnergy())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) {
|
||||
setActive(true);
|
||||
|
||||
if(!canOperate(recipe))
|
||||
{
|
||||
operatingTicks = 0;
|
||||
}
|
||||
electricityStored -= energyPerTick;
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
if ((operatingTicks + 1) < ticksRequired) {
|
||||
operatingTicks++;
|
||||
} else {
|
||||
operate(recipe);
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack)
|
||||
{
|
||||
if(slotID == 3)
|
||||
{
|
||||
return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade;
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
return RecipeHandler.isInRecipe(itemstack, getRecipes());
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
operatingTicks = 0;
|
||||
}
|
||||
} else {
|
||||
if (prevEnergy >= getEnergy()) {
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!canOperate(recipe)) {
|
||||
operatingTicks = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStackInput getInput()
|
||||
{
|
||||
return new ItemStackInput(inventory.get(0));
|
||||
}
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operate(RECIPE recipe)
|
||||
{
|
||||
recipe.operate(inventory);
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) {
|
||||
if (slotID == 3) {
|
||||
return itemstack.getItem() == MekanismItems.SpeedUpgrade
|
||||
|| itemstack.getItem() == MekanismItems.EnergyUpgrade;
|
||||
} else if (slotID == 0) {
|
||||
return RecipeHandler.isInRecipe(itemstack, getRecipes());
|
||||
} else if (slotID == 1) {
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
ejectorComponent.outputItems();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOperate(RECIPE recipe)
|
||||
{
|
||||
return recipe != null && recipe.canOperate(inventory, 0, 2, 4);
|
||||
}
|
||||
@Override
|
||||
public ItemStackInput getInput() {
|
||||
return new ItemStackInput(inventory.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side)
|
||||
{
|
||||
if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
}
|
||||
else if(slotID == 2 || slotID == 4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void operate(RECIPE recipe) {
|
||||
recipe.operate(inventory);
|
||||
|
||||
return false;
|
||||
}
|
||||
markDirty();
|
||||
ejectorComponent.outputItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECIPE getRecipe()
|
||||
{
|
||||
ItemStackInput input = getInput();
|
||||
|
||||
if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput()))
|
||||
{
|
||||
cachedRecipe = RecipeHandler.getChanceRecipe(input, getRecipes());
|
||||
}
|
||||
|
||||
return cachedRecipe;
|
||||
}
|
||||
@Override
|
||||
public boolean canOperate(RECIPE recipe) {
|
||||
return recipe != null && recipe.canOperate(inventory, 0, 2, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ItemStackInput, RECIPE> getRecipes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) {
|
||||
if (slotID == 1) {
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
} else
|
||||
return slotID == 2 || slotID == 4;
|
||||
|
||||
private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethods()
|
||||
{
|
||||
return methods;
|
||||
}
|
||||
@Override
|
||||
public RECIPE getRecipe() {
|
||||
ItemStackInput input = getInput();
|
||||
|
||||
@Override
|
||||
public Object[] invoke(int method, Object[] arguments) throws Exception
|
||||
{
|
||||
switch(method)
|
||||
{
|
||||
case 0:
|
||||
return new Object[] {getEnergy()};
|
||||
case 1:
|
||||
return new Object[] {operatingTicks};
|
||||
case 2:
|
||||
return new Object[] {isActive};
|
||||
case 3:
|
||||
return new Object[] {facing};
|
||||
case 4:
|
||||
return new Object[] {canOperate(getRecipe())};
|
||||
case 5:
|
||||
return new Object[] {getMaxEnergy()};
|
||||
case 6:
|
||||
return new Object[] {getMaxEnergy()-getEnergy()};
|
||||
default:
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) {
|
||||
cachedRecipe = RecipeHandler.getChanceRecipe(input, getRecipes());
|
||||
}
|
||||
|
||||
return cachedRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ItemStackInput, RECIPE> getRecipes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] invoke(int method, Object[] arguments) throws Exception {
|
||||
switch (method) {
|
||||
case 0:
|
||||
return new Object[]{getEnergy()};
|
||||
case 1:
|
||||
return new Object[]{operatingTicks};
|
||||
case 2:
|
||||
return new Object[]{isActive};
|
||||
case 3:
|
||||
return new Object[]{facing};
|
||||
case 4:
|
||||
return new Object[]{canOperate(getRecipe())};
|
||||
case 5:
|
||||
return new Object[]{getMaxEnergy()};
|
||||
case 6:
|
||||
return new Object[]{getMaxEnergy() - getEnergy()};
|
||||
default:
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user