2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("TileEntityGrinder.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.tile;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
2021-08-31 00:44:39 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
2021-08-22 21:09:15 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPoweredFurnace;
|
2021-03-01 18:46:12 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerGrinder;
|
2016-12-06 18:10:43 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
2016-08-12 18:14:41 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
2018-08-10 05:04:07 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
2016-11-16 16:59:00 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraft.block.BlockState;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2021-03-01 18:46:12 +01:00
|
|
|
import net.minecraft.entity.player.PlayerInventory;
|
|
|
|
import net.minecraft.inventory.container.Container;
|
|
|
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
2015-03-07 02:23:31 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraft.nbt.CompoundNBT;
|
2021-08-31 00:44:39 +02:00
|
|
|
import net.minecraft.state.properties.BlockStateProperties;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraft.tileentity.TileEntityType;
|
|
|
|
import net.minecraft.util.Direction;
|
2016-05-01 22:26:26 +02:00
|
|
|
import net.minecraft.util.SoundCategory;
|
2021-03-01 18:46:12 +01:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
import net.minecraft.util.text.StringTextComponent;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraftforge.common.util.LazyOptional;
|
2016-11-26 08:58:42 +01:00
|
|
|
import net.minecraftforge.energy.IEnergyStorage;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2021-03-01 18:46:12 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2021-08-22 20:16:04 +02:00
|
|
|
public class TileEntityCrusher extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider {
|
2015-05-20 22:39:43 +02:00
|
|
|
|
2015-10-03 10:16:18 +02:00
|
|
|
public static final int SLOT_INPUT_1 = 0;
|
|
|
|
public static final int SLOT_OUTPUT_1_1 = 1;
|
|
|
|
public static final int SLOT_OUTPUT_1_2 = 2;
|
|
|
|
public static final int SLOT_INPUT_2 = 3;
|
|
|
|
public static final int SLOT_OUTPUT_2_1 = 4;
|
|
|
|
public static final int SLOT_OUTPUT_2_2 = 5;
|
2016-05-04 22:40:58 +02:00
|
|
|
public static final int ENERGY_USE = 40;
|
2016-11-26 20:43:50 +01:00
|
|
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 100, 0);
|
2021-02-27 13:24:45 +01:00
|
|
|
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
2015-10-03 10:16:18 +02:00
|
|
|
public int firstCrushTime;
|
|
|
|
public int secondCrushTime;
|
|
|
|
public boolean isDouble;
|
2016-09-12 20:45:29 +02:00
|
|
|
public boolean isAutoSplit;
|
2015-07-02 04:21:21 +02:00
|
|
|
private int lastEnergy;
|
2015-10-03 10:16:18 +02:00
|
|
|
private int lastFirstCrush;
|
|
|
|
private int lastSecondCrush;
|
2016-08-12 18:14:41 +02:00
|
|
|
private boolean lastAutoSplit;
|
2017-02-22 12:37:29 +01:00
|
|
|
private boolean lastCrushed;
|
2016-08-12 18:14:41 +02:00
|
|
|
|
2021-08-22 20:16:04 +02:00
|
|
|
public TileEntityCrusher(TileEntityType<?> type, int slots) {
|
2021-02-27 13:24:45 +01:00
|
|
|
super(type, slots);
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
|
2021-08-22 20:16:04 +02:00
|
|
|
public TileEntityCrusher() {
|
2021-08-31 00:44:39 +02:00
|
|
|
super(ActuallyBlocks.CRUSHER.getTileEntityType(), 3);
|
2015-10-03 10:16:18 +02:00
|
|
|
this.isDouble = false;
|
|
|
|
}
|
2015-05-20 22:39:43 +02:00
|
|
|
|
2016-02-01 20:32:49 +01:00
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
2018-08-10 05:04:07 +02:00
|
|
|
if (type != NBTType.SAVE_BLOCK) {
|
2021-02-27 13:24:45 +01:00
|
|
|
compound.putInt("FirstCrushTime", this.firstCrushTime);
|
|
|
|
compound.putInt("SecondCrushTime", this.secondCrushTime);
|
|
|
|
compound.putBoolean("IsAutoSplit", this.isAutoSplit);
|
2016-07-02 15:01:46 +02:00
|
|
|
}
|
2016-02-01 20:32:49 +01:00
|
|
|
this.storage.writeToNBT(compound);
|
2016-07-02 15:01:46 +02:00
|
|
|
super.writeSyncableNBT(compound, type);
|
2016-02-01 20:32:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
2018-08-10 05:04:07 +02:00
|
|
|
if (type != NBTType.SAVE_BLOCK) {
|
2021-02-27 13:24:45 +01:00
|
|
|
this.firstCrushTime = compound.getInt("FirstCrushTime");
|
|
|
|
this.secondCrushTime = compound.getInt("SecondCrushTime");
|
2016-08-12 18:14:41 +02:00
|
|
|
this.isAutoSplit = compound.getBoolean("IsAutoSplit");
|
2016-07-02 15:01:46 +02:00
|
|
|
}
|
2016-02-01 20:32:49 +01:00
|
|
|
this.storage.readFromNBT(compound);
|
2016-07-02 15:01:46 +02:00
|
|
|
super.readSyncableNBT(compound, type);
|
2016-02-01 20:32:49 +01:00
|
|
|
}
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
@Override
|
2018-08-10 05:04:07 +02:00
|
|
|
public void updateEntity() {
|
2015-11-18 23:11:24 +01:00
|
|
|
super.updateEntity();
|
2021-08-31 00:44:39 +02:00
|
|
|
if (!this.level.isClientSide) {
|
2018-08-10 05:04:07 +02:00
|
|
|
if (this.isDouble && this.isAutoSplit) {
|
2021-08-22 21:09:15 +02:00
|
|
|
TileEntityPoweredFurnace.autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2);
|
2016-08-12 18:14:41 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 12:37:29 +01:00
|
|
|
boolean crushed = false;
|
2015-06-21 02:28:49 +02:00
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
boolean canCrushOnFirst = this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2);
|
|
|
|
boolean canCrushOnSecond = false;
|
2018-08-10 05:04:07 +02:00
|
|
|
if (this.isDouble) {
|
2015-10-03 10:16:18 +02:00
|
|
|
canCrushOnSecond = this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2015-12-13 14:36:34 +01:00
|
|
|
boolean shouldPlaySound = false;
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
if (canCrushOnFirst) {
|
|
|
|
if (this.storage.getEnergyStored() >= ENERGY_USE) {
|
|
|
|
if (this.firstCrushTime % 20 == 0) {
|
2015-12-13 14:36:34 +01:00
|
|
|
shouldPlaySound = true;
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
this.firstCrushTime++;
|
2018-08-10 05:04:07 +02:00
|
|
|
if (this.firstCrushTime >= this.getMaxCrushTime()) {
|
2015-03-07 02:23:31 +01:00
|
|
|
this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2);
|
|
|
|
this.firstCrushTime = 0;
|
|
|
|
}
|
2016-11-23 18:10:55 +01:00
|
|
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
crushed = this.storage.getEnergyStored() >= ENERGY_USE;
|
2018-08-10 05:04:07 +02:00
|
|
|
} else {
|
2015-10-02 16:48:01 +02:00
|
|
|
this.firstCrushTime = 0;
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
if (this.isDouble) {
|
|
|
|
if (canCrushOnSecond) {
|
|
|
|
if (this.storage.getEnergyStored() >= ENERGY_USE) {
|
|
|
|
if (this.secondCrushTime % 20 == 0) {
|
2015-12-13 14:36:34 +01:00
|
|
|
shouldPlaySound = true;
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
this.secondCrushTime++;
|
2018-08-10 05:04:07 +02:00
|
|
|
if (this.secondCrushTime >= this.getMaxCrushTime()) {
|
2015-03-07 02:23:31 +01:00
|
|
|
this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
|
|
|
|
this.secondCrushTime = 0;
|
|
|
|
}
|
2016-11-23 18:10:55 +01:00
|
|
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
crushed = this.storage.getEnergyStored() >= ENERGY_USE;
|
2018-08-10 05:04:07 +02:00
|
|
|
} else {
|
2015-10-02 16:48:01 +02:00
|
|
|
this.secondCrushTime = 0;
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2021-08-31 00:44:39 +02:00
|
|
|
BlockState currState = this.level.getBlockState(this.worldPosition);
|
|
|
|
boolean current = currState.getValue(BlockStateProperties.LIT);
|
2019-03-03 23:09:59 +01:00
|
|
|
boolean changeTo = current;
|
2021-02-26 22:15:48 +01:00
|
|
|
if (this.lastCrushed != crushed) {
|
|
|
|
changeTo = crushed;
|
|
|
|
}
|
|
|
|
if (this.isRedstonePowered) {
|
|
|
|
changeTo = true;
|
|
|
|
}
|
|
|
|
if (!crushed && !this.isRedstonePowered) {
|
|
|
|
changeTo = false;
|
|
|
|
}
|
2019-03-03 23:09:59 +01:00
|
|
|
|
|
|
|
if (changeTo != current) {
|
2021-08-31 00:44:39 +02:00
|
|
|
this.level.setBlockAndUpdate(this.worldPosition, currState.setValue(BlockStateProperties.LIT, changeTo));
|
2017-02-22 12:37:29 +01:00
|
|
|
}
|
|
|
|
|
2019-03-03 23:09:59 +01:00
|
|
|
this.lastCrushed = crushed;
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
if ((this.lastEnergy != this.storage.getEnergyStored() || this.lastFirstCrush != this.firstCrushTime || this.lastSecondCrush != this.secondCrushTime || this.isAutoSplit != this.lastAutoSplit) && this.sendUpdateWithInterval()) {
|
2015-07-02 04:21:21 +02:00
|
|
|
this.lastEnergy = this.storage.getEnergyStored();
|
|
|
|
this.lastFirstCrush = this.firstCrushTime;
|
|
|
|
this.lastSecondCrush = this.secondCrushTime;
|
2016-08-12 18:14:41 +02:00
|
|
|
this.lastAutoSplit = this.isAutoSplit;
|
2015-07-02 04:21:21 +02:00
|
|
|
}
|
2015-12-13 14:36:34 +01:00
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
if (shouldPlaySound) {
|
2021-08-31 00:44:39 +02:00
|
|
|
this.level.playSound(null, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), SoundHandler.crusher, SoundCategory.BLOCKS, 0.025F, 1.0F);
|
2015-12-13 14:36:34 +01:00
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
@Override
|
2018-08-10 05:04:07 +02:00
|
|
|
public IAcceptor getAcceptor() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null;
|
2018-08-10 05:04:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IRemover getRemover() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return (slot, automation) -> !automation || slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2;
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) {
|
|
|
|
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
|
2019-02-27 19:53:05 +01:00
|
|
|
CrusherRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));
|
2021-02-26 22:15:48 +01:00
|
|
|
if (recipe == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-23 01:39:30 +02:00
|
|
|
ItemStack outputOne = recipe.getOutputOne();
|
|
|
|
ItemStack outputTwo = recipe.getOutputTwo();
|
2018-08-10 05:04:07 +02:00
|
|
|
if (StackUtil.isValid(outputOne)) {
|
2021-08-31 00:44:39 +02:00
|
|
|
/* //TODO
|
2021-02-27 13:24:45 +01:00
|
|
|
if (outputOne.getDamage() == Util.WILDCARD) {
|
|
|
|
outputOne.setDamage(0);
|
2016-10-30 17:13:46 +01:00
|
|
|
}
|
2021-02-27 13:24:45 +01:00
|
|
|
if (StackUtil.isValid(outputTwo) && outputTwo.getDamage() == Util.WILDCARD) {
|
|
|
|
outputTwo.setDamage(0);
|
2016-10-30 17:13:46 +01:00
|
|
|
}
|
2021-08-31 00:44:39 +02:00
|
|
|
*/
|
|
|
|
if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || this.inv.getStackInSlot(theFirstOutput).sameItem(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (!StackUtil.isValid(outputTwo) || !StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || this.inv.getStackInSlot(theSecondOutput).isItemEqual(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())) {
|
2021-02-26 22:15:48 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
private int getMaxCrushTime() {
|
2021-02-26 22:15:48 +01:00
|
|
|
return this.isDouble
|
|
|
|
? 150
|
|
|
|
: 100;
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput) {
|
2019-02-27 19:53:05 +01:00
|
|
|
CrusherRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));
|
2021-02-26 22:15:48 +01:00
|
|
|
if (recipe == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-23 01:39:30 +02:00
|
|
|
ItemStack outputOne = recipe.getOutputOne();
|
2018-08-10 05:04:07 +02:00
|
|
|
if (StackUtil.isValid(outputOne)) {
|
2021-08-31 00:44:39 +02:00
|
|
|
/* //TODO
|
2021-02-27 13:24:45 +01:00
|
|
|
if (outputOne.getDamage() == Util.WILDCARD) {
|
|
|
|
outputOne.setDamage(0);
|
2016-10-30 17:13:46 +01:00
|
|
|
}
|
2021-08-31 00:44:39 +02:00
|
|
|
*/
|
2018-08-10 05:04:07 +02:00
|
|
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput))) {
|
2018-06-23 01:39:30 +02:00
|
|
|
this.inv.setStackInSlot(theFirstOutput, outputOne.copy());
|
2018-08-10 05:04:07 +02:00
|
|
|
} else if (this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()) {
|
2018-06-23 01:39:30 +02:00
|
|
|
this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount()));
|
2015-10-02 16:48:01 +02:00
|
|
|
}
|
2015-06-21 02:28:49 +02:00
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
ItemStack outputTwo = recipe.getOutputTwo();
|
2018-08-10 05:04:07 +02:00
|
|
|
if (StackUtil.isValid(outputTwo)) {
|
2021-08-31 00:44:39 +02:00
|
|
|
/* //TODO
|
2021-02-27 13:24:45 +01:00
|
|
|
if (outputTwo.getDamage() == Util.WILDCARD) {
|
|
|
|
outputTwo.setDamage(0);
|
2016-10-30 17:13:46 +01:00
|
|
|
}
|
2021-08-31 00:44:39 +02:00
|
|
|
*/
|
|
|
|
int rand = this.level.random.nextInt(100) + 1;
|
2018-08-10 05:04:07 +02:00
|
|
|
if (rand <= recipe.getSecondChance()) {
|
|
|
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) {
|
2018-06-23 01:39:30 +02:00
|
|
|
this.inv.setStackInSlot(theSecondOutput, outputTwo.copy());
|
2018-08-10 05:04:07 +02:00
|
|
|
} else if (this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()) {
|
2018-06-23 01:39:30 +02:00
|
|
|
this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount()));
|
2015-10-02 16:48:01 +02:00
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
this.inv.getStackInSlot(theInput).shrink(1);
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
public int getEnergyScaled(int i) {
|
|
|
|
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
public int getFirstTimeToScale(int i) {
|
|
|
|
return this.firstCrushTime * i / this.getMaxCrushTime();
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2018-08-10 05:04:07 +02:00
|
|
|
public int getSecondTimeToScale(int i) {
|
|
|
|
return this.secondCrushTime * i / this.getMaxCrushTime();
|
2015-04-02 12:06:42 +02:00
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
|
2016-08-12 18:14:41 +02:00
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public void onButtonPressed(int buttonID, PlayerEntity player) {
|
2018-08-10 05:04:07 +02:00
|
|
|
if (buttonID == 0) {
|
2016-08-12 18:14:41 +02:00
|
|
|
this.isAutoSplit = !this.isAutoSplit;
|
2021-08-31 00:44:39 +02:00
|
|
|
this.setChanged();
|
2016-08-12 18:14:41 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-26 08:58:42 +01:00
|
|
|
|
|
|
|
@Override
|
2021-02-27 13:24:45 +01:00
|
|
|
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
|
|
|
return this.lazyEnergy;
|
2016-11-26 08:58:42 +01:00
|
|
|
}
|
2021-03-01 18:46:12 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ITextComponent getDisplayName() {
|
|
|
|
return StringTextComponent.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) {
|
|
|
|
return new ContainerGrinder(windowId, playerInventory, this);
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|