2018-12-26 09:01:03 +00:00
|
|
|
/*
|
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2019-01-01 01:10:18 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
2018-12-26 09:01:03 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
package dan200.computercraft.api;
|
2018-12-26 09:01:03 +00:00
|
|
|
|
|
|
|
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
|
|
|
import dan200.computercraft.api.turtle.TurtleUpgradeType;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
/**
|
|
|
|
* A base class for {@link ITurtleUpgrade}s.
|
|
|
|
*
|
|
|
|
* One does not have to use this, but it does provide a convenient template.
|
|
|
|
*/
|
2018-12-26 09:01:03 +00:00
|
|
|
public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
|
|
|
{
|
|
|
|
private final ResourceLocation id;
|
|
|
|
private final int legacyId;
|
|
|
|
private final TurtleUpgradeType type;
|
|
|
|
private final String adjective;
|
|
|
|
private final ItemStack stack;
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, ItemStack stack )
|
2018-12-26 09:01:03 +00:00
|
|
|
{
|
|
|
|
this.id = id;
|
|
|
|
this.legacyId = legacyId;
|
|
|
|
this.type = type;
|
|
|
|
this.adjective = adjective;
|
|
|
|
this.stack = stack;
|
|
|
|
}
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Item item )
|
2018-12-26 09:01:03 +00:00
|
|
|
{
|
|
|
|
this( id, legacyId, type, adjective, new ItemStack( item ) );
|
|
|
|
}
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Block block )
|
2018-12-26 09:01:03 +00:00
|
|
|
{
|
|
|
|
this( id, legacyId, type, adjective, new ItemStack( block ) );
|
|
|
|
}
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, ItemStack stack )
|
2019-01-14 10:42:13 +00:00
|
|
|
{
|
|
|
|
this( id, legacyId, type, "upgrade." + id + ".adjective", stack );
|
|
|
|
}
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Item item )
|
2019-01-14 10:42:13 +00:00
|
|
|
{
|
|
|
|
this( id, legacyId, type, new ItemStack( item ) );
|
|
|
|
}
|
|
|
|
|
2019-04-02 10:50:13 +00:00
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Block block )
|
2019-01-14 10:42:13 +00:00
|
|
|
{
|
|
|
|
this( id, legacyId, type, new ItemStack( block ) );
|
|
|
|
}
|
|
|
|
|
2018-12-26 09:01:03 +00:00
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public final ResourceLocation getUpgradeID()
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final int getLegacyUpgradeID()
|
|
|
|
{
|
|
|
|
return legacyId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public final String getUnlocalisedAdjective()
|
|
|
|
{
|
|
|
|
return adjective;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public final TurtleUpgradeType getType()
|
|
|
|
{
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public final ItemStack getCraftingItem()
|
|
|
|
{
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|