mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-28 07:35:44 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
a711c0495e
commit
21f9083d10
83 files changed
+1855
-2448
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mantle.blocks.abstracts;
|
||||
|
||||
import static mantle.lib.CoreRepo.logger;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -8,60 +9,52 @@ import net.minecraft.util.MathHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author progwml6
|
||||
* base class for itemBlocks with different unlocalized names based on metadata
|
||||
* @author progwml6 base class for itemBlocks with different unlocalized names based on metadata
|
||||
*/
|
||||
|
||||
public class MultiItemBlock extends ItemBlock
|
||||
{
|
||||
public class MultiItemBlock extends ItemBlock {
|
||||
|
||||
private String blockType[];
|
||||
private String unlocalizedName;
|
||||
private String append;
|
||||
private int specialIndex[] = { -1, -1 };
|
||||
|
||||
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes)
|
||||
{
|
||||
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes) {
|
||||
super(b);
|
||||
if (itemBlockUnlocalizedName.isEmpty())
|
||||
this.unlocalizedName = super.getUnlocalizedName();
|
||||
else
|
||||
this.unlocalizedName = itemBlockUnlocalizedName;
|
||||
if (itemBlockUnlocalizedName.isEmpty()) this.unlocalizedName = super.getUnlocalizedName();
|
||||
else this.unlocalizedName = itemBlockUnlocalizedName;
|
||||
this.blockType = blockTypes;
|
||||
this.append = "";
|
||||
}
|
||||
|
||||
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String appendToEnd, String[] blockTypes)
|
||||
{
|
||||
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String appendToEnd, String[] blockTypes) {
|
||||
super(b);
|
||||
this.unlocalizedName = itemBlockUnlocalizedName;
|
||||
this.blockType = blockTypes;
|
||||
this.append = "." + appendToEnd;
|
||||
}
|
||||
|
||||
public void setSpecialIndex (int clampIndex, int stringBuilderIndex)
|
||||
{
|
||||
public void setSpecialIndex(int clampIndex, int stringBuilderIndex) {
|
||||
specialIndex[0] = clampIndex;
|
||||
specialIndex[1] = stringBuilderIndex;
|
||||
}
|
||||
|
||||
public int getMetadata (int meta)
|
||||
{
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName (ItemStack itemstack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
|
||||
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, (specialIndex[0] > -1) ? specialIndex[0] : (blockType.length - 1));
|
||||
int pos = MathHelper.clamp_int(
|
||||
itemstack.getItemDamage(),
|
||||
0,
|
||||
(specialIndex[0] > -1) ? specialIndex[0] : (blockType.length - 1));
|
||||
int sbIndex = (specialIndex[1] > -1) ? pos : (specialIndex[1] - pos);
|
||||
if (sbIndex < 0)
|
||||
sbIndex = -1 * sbIndex;
|
||||
try
|
||||
{
|
||||
return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex - 1]).append(append).toString();
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ex)
|
||||
{
|
||||
if (sbIndex < 0) sbIndex = -1 * sbIndex;
|
||||
try {
|
||||
return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex - 1])
|
||||
.append(append).toString();
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
logger.warn("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage());
|
||||
logger.warn("[MultiItemBlock] Returning unlocalized name: " + getUnlocalizedName());
|
||||
return getUnlocalizedName();
|
||||
|
||||
Reference in new issue
Block a user