mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 02:55:13 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// 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.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;
|
||||
|
||||
public class CarpentryInterface implements ICarpentryInterface
|
||||
{
|
||||
static Map<Integer, IDesignMaterial> woodMap;
|
||||
static Map<Integer, IDesign> designMap;
|
||||
static Map<String, IDesignCategory> designCategories;
|
||||
|
||||
@Override
|
||||
public boolean registerCarpentryWood(final int index, final 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()) {
|
||||
if (CarpentryInterface.woodMap.get(integer).equals(wood)) {
|
||||
return integer;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getWoodMaterial(final 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDesignIndex(final IDesign wood) {
|
||||
for (final Integer integer : CarpentryInterface.designMap.keySet()) {
|
||||
if (CarpentryInterface.designMap.get(integer).equals(wood)) {
|
||||
return integer;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesign getDesign(final int index) {
|
||||
return CarpentryInterface.designMap.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILayout getLayout(final IPattern pattern, final 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignCategory getDesignCategory(final 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()) {
|
||||
if (category.getDesigns().size() > 0) {
|
||||
categories.add(category);
|
||||
}
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDesign> getSortedDesigns() {
|
||||
final List<IDesign> designs = new ArrayList<IDesign>();
|
||||
for (final IDesignCategory category : this.getAllDesignCategories()) {
|
||||
designs.addAll(category.getDesigns());
|
||||
}
|
||||
return designs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getWoodMaterial(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Map.Entry<Integer, IDesignMaterial> entry : CarpentryInterface.woodMap.entrySet()) {
|
||||
final ItemStack key = entry.getValue().getStack();
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
if (key.isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
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