mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 11:05:32 +00:00
Improve code readability in binnie.extratrees package
This commit is contained in:
1 parent
adccdd181a
commit
96e4814ae3
225 files changed
+8968
-9306
No files matched your search
@@ -1,37 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extratrees.carpentry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import binnie.extratrees.api.ICarpentryInterface;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignCategory;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import binnie.extratrees.api.ILayout;
|
||||
import binnie.extratrees.api.IPattern;
|
||||
import binnie.extratrees.api.IDesignCategory;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import java.util.Map;
|
||||
import binnie.extratrees.api.ICarpentryInterface;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CarpentryInterface implements ICarpentryInterface
|
||||
{
|
||||
static Map<Integer, IDesignMaterial> woodMap;
|
||||
static Map<Integer, IDesign> designMap;
|
||||
static Map<String, IDesignCategory> designCategories;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CarpentryInterface implements ICarpentryInterface {
|
||||
protected static Map<Integer, IDesignMaterial> woodMap = new LinkedHashMap<>();
|
||||
protected static Map<Integer, IDesign> designMap = new LinkedHashMap<>();
|
||||
protected static Map<String, IDesignCategory> designCategories = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean registerCarpentryWood(final int index, final IDesignMaterial wood) {
|
||||
public boolean registerCarpentryWood(int index, IDesignMaterial wood) {
|
||||
return wood != null && CarpentryInterface.woodMap.put(index, wood) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCarpentryWoodIndex(final IDesignMaterial wood) {
|
||||
for (final Integer integer : CarpentryInterface.woodMap.keySet()) {
|
||||
public int getCarpentryWoodIndex(IDesignMaterial wood) {
|
||||
for (Integer integer : CarpentryInterface.woodMap.keySet()) {
|
||||
if (CarpentryInterface.woodMap.get(integer).equals(wood)) {
|
||||
return integer;
|
||||
}
|
||||
@@ -40,18 +36,19 @@ public class CarpentryInterface implements ICarpentryInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getWoodMaterial(final int index) {
|
||||
public IDesignMaterial getWoodMaterial(int index) {
|
||||
return CarpentryInterface.woodMap.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerDesign(final int index, final IDesign wood) {
|
||||
return wood != null && CarpentryInterface.designMap.put(index, wood) == null;
|
||||
public boolean registerDesign(int index, IDesign wood) {
|
||||
return wood != null
|
||||
&& CarpentryInterface.designMap.put(index, wood) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDesignIndex(final IDesign wood) {
|
||||
for (final Integer integer : CarpentryInterface.designMap.keySet()) {
|
||||
public int getDesignIndex(IDesign wood) {
|
||||
for (Integer integer : CarpentryInterface.designMap.keySet()) {
|
||||
if (CarpentryInterface.designMap.get(integer).equals(wood)) {
|
||||
return integer;
|
||||
}
|
||||
@@ -60,29 +57,31 @@ public class CarpentryInterface implements ICarpentryInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesign getDesign(final int index) {
|
||||
public IDesign getDesign(int index) {
|
||||
return CarpentryInterface.designMap.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILayout getLayout(final IPattern pattern, final boolean inverted) {
|
||||
public ILayout getLayout(IPattern pattern, boolean inverted) {
|
||||
return Layout.get(pattern, inverted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerDesignCategory(final IDesignCategory category) {
|
||||
return category != null && category.getId() != null && CarpentryInterface.designCategories.put(category.getId(), category) == null;
|
||||
public boolean registerDesignCategory(IDesignCategory category) {
|
||||
return category != null
|
||||
&& category.getId() != null
|
||||
&& CarpentryInterface.designCategories.put(category.getId(), category) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignCategory getDesignCategory(final String id) {
|
||||
public IDesignCategory getDesignCategory(String id) {
|
||||
return CarpentryInterface.designCategories.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IDesignCategory> getAllDesignCategories() {
|
||||
final List<IDesignCategory> categories = new ArrayList<IDesignCategory>();
|
||||
for (final IDesignCategory category : CarpentryInterface.designCategories.values()) {
|
||||
List<IDesignCategory> categories = new ArrayList<IDesignCategory>();
|
||||
for (IDesignCategory category : CarpentryInterface.designCategories.values()) {
|
||||
if (category.getDesigns().size() > 0) {
|
||||
categories.add(category);
|
||||
}
|
||||
@@ -92,20 +91,21 @@ public class CarpentryInterface implements ICarpentryInterface
|
||||
|
||||
@Override
|
||||
public List<IDesign> getSortedDesigns() {
|
||||
final List<IDesign> designs = new ArrayList<IDesign>();
|
||||
for (final IDesignCategory category : this.getAllDesignCategories()) {
|
||||
List<IDesign> designs = new ArrayList<IDesign>();
|
||||
for (IDesignCategory category : getAllDesignCategories()) {
|
||||
designs.addAll(category.getDesigns());
|
||||
}
|
||||
return designs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getWoodMaterial(final ItemStack stack) {
|
||||
public IDesignMaterial getWoodMaterial(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Map.Entry<Integer, IDesignMaterial> entry : CarpentryInterface.woodMap.entrySet()) {
|
||||
final ItemStack key = entry.getValue().getStack();
|
||||
|
||||
for (Map.Entry<Integer, IDesignMaterial> entry : CarpentryInterface.woodMap.entrySet()) {
|
||||
ItemStack key = entry.getValue().getStack();
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -115,10 +115,4 @@ public class CarpentryInterface implements ICarpentryInterface
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
CarpentryInterface.woodMap = new LinkedHashMap<Integer, IDesignMaterial>();
|
||||
CarpentryInterface.designMap = new LinkedHashMap<Integer, IDesign>();
|
||||
CarpentryInterface.designCategories = new HashMap<String, IDesignCategory>();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user