Improve code readability in binnie.extratrees package

This commit is contained in:
kordum authored and mezz committed 2017-05-03 14:10:02 -07:00
1 parent adccdd181a
commit 96e4814ae3
225 files changed
+8968 -9306

No files matched your search

@@ -1,53 +1,51 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.extratrees.block;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Blocks;
import binnie.core.block.TileEntityMetadata;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.api.CarpentryManager;
import binnie.extratrees.api.IDesignMaterial;
import binnie.extratrees.block.decor.FenceDescription;
import binnie.extratrees.block.decor.FenceType;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import binnie.extratrees.api.IDesignMaterial;
import binnie.extratrees.api.CarpentryManager;
public class WoodManager
{
public static IPlankType getPlankType(final int index) {
final IDesignMaterial wood = CarpentryManager.carpentryInterface.getWoodMaterial(index);
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WoodManager {
public static IPlankType getPlankType(int index) {
IDesignMaterial wood = CarpentryManager.carpentryInterface.getWoodMaterial(index);
if (wood instanceof IPlankType) {
return (IPlankType) wood;
}
return PlankType.ExtraTreePlanks.Fir;
}
public static int getPlankTypeIndex(final IPlankType type) {
final int index = CarpentryManager.carpentryInterface.getCarpentryWoodIndex(type);
public static int getPlankTypeIndex(IPlankType type) {
int index = CarpentryManager.carpentryInterface.getCarpentryWoodIndex(type);
return (index < 0) ? 0 : index;
}
public static FenceType getFenceType(final ItemStack stack) {
final FenceDescription desc = getFenceDescription(stack);
public static FenceType getFenceType(ItemStack stack) {
FenceDescription desc = getFenceDescription(stack);
return (desc == null) ? null : desc.getFenceType();
}
public static FenceDescription getFenceDescription(final ItemStack stack) {
public static FenceDescription getFenceDescription(ItemStack stack) {
if (stack == null) {
return null;
}
if (stack.getItem() == Item.getItemFromBlock(ExtraTrees.blockMultiFence)) {
final int damage = TileEntityMetadata.getItemDamage(stack);
int damage = TileEntityMetadata.getItemDamage(stack);
return getFenceDescription(damage);
}
for (final IPlankType type : getAllPlankTypes()) {
for (IPlankType type : getAllPlankTypes()) {
if (type instanceof IFenceProvider) {
final ItemStack f = ((IFenceProvider) type).getFence();
ItemStack f = ((IFenceProvider) type).getFence();
if (f != null && ItemStack.areItemStacksEqual(stack, f)) {
return new FenceDescription(new FenceType(0), type, type);
}
@@ -57,65 +55,61 @@ public class WoodManager
return null;
}
public static FenceDescription getFenceDescription(final int meta) {
public static FenceDescription getFenceDescription(int meta) {
return new FenceDescription(meta);
}
public static FenceType getFenceType(final int meta) {
public static FenceType getFenceType(int meta) {
return getFenceDescription(meta).getFenceType();
}
public static ItemStack getGate(final IPlankType plank) {
public static ItemStack getGate(IPlankType plank) {
if (plank == PlankType.VanillaPlanks.OAK) {
return new ItemStack(Blocks.fence_gate);
}
return TileEntityMetadata.getItemStack(ExtraTrees.blockGate, getPlankTypeIndex(plank));
}
public static ItemStack getFence(final IPlankType plank, final FenceType type, final int amount) {
public static ItemStack getFence(IPlankType plank, FenceType type, int amount) {
return getFence(plank, plank, type, amount);
}
public static ItemStack getFence(final IPlankType plank, final IPlankType plank2, final FenceType type, final int amount) {
public static ItemStack getFence(IPlankType plank, IPlankType plank2, FenceType type, int amount) {
if (plank instanceof IFenceProvider && plank == plank2 && type.isPlain()) {
final ItemStack original = ((IFenceProvider) plank).getFence();
ItemStack original = ((IFenceProvider) plank).getFence();
if (original != null) {
original.stackSize = amount;
return original;
}
}
final int ord = type.ordinal();
final int i = getPlankTypeIndex(plank) + 256 * ord;
final ItemStack stack = TileEntityMetadata.getItemStack(ExtraTrees.blockMultiFence, i + 65536 * getPlankTypeIndex(plank2));
int ord = type.ordinal();
int i = getPlankTypeIndex(plank) + 256 * ord;
ItemStack stack = TileEntityMetadata.getItemStack(ExtraTrees.blockMultiFence, i + 65536 * getPlankTypeIndex(plank2));
stack.stackSize = amount;
return stack;
}
public static ItemStack getDoor(final IPlankType plank, final DoorType type) {
public static ItemStack getDoor(IPlankType plank, DoorType type) {
return TileEntityMetadata.getItemStack(ExtraTrees.blockDoor, type.ordinal() * 256 + getPlankTypeIndex(plank));
}
public static List<IPlankType> getAllPlankTypes() {
final List<IPlankType> list = new ArrayList<IPlankType>();
for (final IPlankType type : PlankType.ExtraTreePlanks.values()) {
list.add(type);
}
for (final IPlankType type : PlankType.ForestryPlanks.values()) {
list.add(type);
}
for (final IPlankType type : PlankType.ExtraBiomesPlank.values()) {
List<IPlankType> list = new ArrayList<IPlankType>();
Collections.addAll(list, PlankType.ExtraTreePlanks.values());
Collections.addAll(list, PlankType.ForestryPlanks.values());
for (IPlankType type : PlankType.ExtraBiomesPlank.values()) {
if (type.getStack() != null) {
list.add(type);
}
}
for (final IPlankType type : PlankType.VanillaPlanks.values()) {
list.add(type);
}
Collections.addAll(list, PlankType.VanillaPlanks.values());
return list;
}
public static IPlankType get(final ItemStack species) {
for (final IPlankType type : getAllPlankTypes()) {
public static IPlankType get(ItemStack species) {
for (IPlankType type : getAllPlankTypes()) {
if (type.getStack() != null && type.getStack().isItemEqual(species)) {
return type;
}