blob: 36e46f67334ef318a2dc0b7ec1ef0780f4fd128f [file] [log] [blame] [raw]
package li.cil.oc.integration.vanilla;
import li.cil.oc.api.driver.EnvironmentAware;
import li.cil.oc.api.driver.NamedBlock;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.prefab.DriverTileEntity;
import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBrewingStand;
import net.minecraft.world.World;
public final class DriverBrewingStand extends DriverTileEntity implements EnvironmentAware {
@Override
public Class<?> getTileEntityClass() {
return TileEntityBrewingStand.class;
}
@Override
public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
return new Environment((TileEntityBrewingStand) world.getTileEntity(x, y, z));
}
@Override
public Class<? extends li.cil.oc.api.network.Environment> providedEnvironment(ItemStack stack) {
if (stack != null && stack.getItem() == Items.brewing_stand)
return Environment.class;
return null;
}
public static final class Environment extends ManagedTileEntityEnvironment<TileEntityBrewingStand> implements NamedBlock {
public Environment(final TileEntityBrewingStand tileEntity) {
super(tileEntity, "brewing_stand");
}
@Override
public String preferredName() {
return "brewing_stand";
}
@Override
public int priority() {
return 0;
}
@Callback(doc = "function():number -- Get the number of ticks remaining of the current brewing operation.")
public Object[] getBrewTime(final Context context, final Arguments args) {
return new Object[]{tileEntity.getBrewTime()};
}
}
}