mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-06-26 15:13:21 +00:00
2965fb666f
Are most of these changes small and petty? Yes. However, IMO they do make the code more readable. Anyway, a summary of some of the more interesting changes: - Expose Abstract*Upgrade classes in the API - Fix the spelling of Jonathan in the API docs (*shakes fist*) - Fix bug with printout not working in the offhand. - Rename any argments/variables accidentally named "m_*", and add an inspection to prevent it happening again. - Remove most of the Block*.Properties classes - just inline them in the parent class. - Return super.writeToNBT instead of reassigning at the top.
99 lines
2.7 KiB
Java
99 lines
2.7 KiB
Java
/*
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
*/
|
|
|
|
package dan200.computercraft.api;
|
|
|
|
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;
|
|
|
|
/**
|
|
* A base class for {@link ITurtleUpgrade}s.
|
|
*
|
|
* One does not have to use this, but it does provide a convenient template.
|
|
*/
|
|
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;
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, ItemStack stack )
|
|
{
|
|
this.id = id;
|
|
this.legacyId = legacyId;
|
|
this.type = type;
|
|
this.adjective = adjective;
|
|
this.stack = stack;
|
|
}
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Item item )
|
|
{
|
|
this( id, legacyId, type, adjective, new ItemStack( item ) );
|
|
}
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, String adjective, Block block )
|
|
{
|
|
this( id, legacyId, type, adjective, new ItemStack( block ) );
|
|
}
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, ItemStack stack )
|
|
{
|
|
this( id, legacyId, type, "upgrade." + id + ".adjective", stack );
|
|
}
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Item item )
|
|
{
|
|
this( id, legacyId, type, new ItemStack( item ) );
|
|
}
|
|
|
|
protected AbstractTurtleUpgrade( ResourceLocation id, int legacyId, TurtleUpgradeType type, Block block )
|
|
{
|
|
this( id, legacyId, type, new ItemStack( block ) );
|
|
}
|
|
|
|
@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;
|
|
}
|
|
}
|