mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-17 19:25:06 +00:00
Begin refactor, make CarvingVariation and CarvingGroup interfaces
This commit is contained in:
1 parent
b268ebeca0
commit
155bc00f0e
12 files changed
+206
-75
No files matched your search
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
public class Carving {
|
||||
|
||||
@@ -29,26 +30,12 @@ public class Carving {
|
||||
return Block.blockRegistry.getNameForObject(block) + "|" + metadata;
|
||||
}
|
||||
|
||||
public boolean isVariationOfSameClass(Block target, int metadata1, Block block2, int metadata2) {
|
||||
CarvingGroup group1 = carvingGroupsByVariation.get(key(target, metadata1));
|
||||
if (group1 == null)
|
||||
return false;
|
||||
|
||||
CarvingGroup group2 = carvingGroupsByVariation.get(key(block2, metadata2));
|
||||
if (group2 == null)
|
||||
return false;
|
||||
|
||||
return group1 == group2 || group1.className.equals(group2.className) && !group1.className.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
public CarvingVariation[] getVariations(Block block, int metadata) {
|
||||
public List<ICarvingVariation> getVariations(Block block, int metadata) {
|
||||
CarvingGroup group = getGroup(block, metadata);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
CarvingVariation[] res = group.variations.toArray(new CarvingVariation[group.variations.size()]);
|
||||
return res;
|
||||
return group.getVariations();
|
||||
}
|
||||
|
||||
public String getOre(Block block, int metadata) {
|
||||
@@ -56,7 +43,7 @@ public class Carving {
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return group.oreName;
|
||||
return group.getOreName();
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getItems(ItemStack chiseledItem) {
|
||||
@@ -70,20 +57,23 @@ public class Carving {
|
||||
|
||||
HashMap<String, Integer> mapping = new HashMap<String, Integer>();
|
||||
|
||||
if (group.variations != null) {
|
||||
for (CarvingVariation v : group.variations) {
|
||||
List<ICarvingVariation> variations = group.getVariations();
|
||||
|
||||
String key = Block.getIdFromBlock(v.block) + "|" + v.damage;
|
||||
if (!group.getVariations().isEmpty()) {
|
||||
for (ICarvingVariation v : variations) {
|
||||
|
||||
String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta();
|
||||
if (mapping.containsKey(key))
|
||||
continue;
|
||||
mapping.put(key, 1);
|
||||
|
||||
items.add(new ItemStack(v.block, 1, v.damage));
|
||||
items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta()));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> ores;
|
||||
if (group.oreName != null && ((ores = OreDictionary.getOres(group.oreName)) != null)) {
|
||||
String oreName = group.getOreName();
|
||||
if (oreName != null && ((ores = OreDictionary.getOres(oreName)) != null)) {
|
||||
for (ItemStack stack : ores) {
|
||||
|
||||
String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage();
|
||||
@@ -124,7 +114,6 @@ public class Carving {
|
||||
CarvingGroup group = carvingGroupsByName.get(name);
|
||||
if (group == null) {
|
||||
group = new CarvingGroup(name);
|
||||
group.className = name;
|
||||
carvingGroupsByName.put(name, group);
|
||||
}
|
||||
|
||||
@@ -139,8 +128,7 @@ public class Carving {
|
||||
return null;
|
||||
|
||||
CarvingVariation variation = new CarvingVariation(block, metadata, order);
|
||||
group.variations.add(variation);
|
||||
Collections.sort(group.variations);
|
||||
group.addVariation(variation);
|
||||
carvingGroupsByVariation.put(key(block, metadata), group);
|
||||
|
||||
return variation;
|
||||
@@ -151,18 +139,12 @@ public class Carving {
|
||||
|
||||
carvingGroupsByOre.put(oreName, group);
|
||||
|
||||
group.oreName = oreName;
|
||||
}
|
||||
|
||||
public void setGroupClass(String name, String className) {
|
||||
CarvingGroup group = getGroup(name);
|
||||
|
||||
group.className = className;
|
||||
group.setOreName(oreName);
|
||||
}
|
||||
|
||||
public void setVariationSound(String name, String sound) {
|
||||
CarvingGroup group = getGroup(name);
|
||||
group.sound = sound;
|
||||
group.setSound(sound);
|
||||
}
|
||||
|
||||
public String getVariationSound(Block block, int metadata) {
|
||||
@@ -171,10 +153,10 @@ public class Carving {
|
||||
|
||||
public String getVariationSound(Item item, int metadata) {
|
||||
CarvingGroup blockGroup = carvingGroupsByVariation.get(key(item, metadata));
|
||||
if (blockGroup == null || blockGroup.sound == null)
|
||||
if (blockGroup == null || blockGroup.getSound() == null)
|
||||
return Chisel.MOD_ID + ":chisel.fallback";
|
||||
|
||||
return blockGroup.sound;
|
||||
return blockGroup.getSound();
|
||||
}
|
||||
|
||||
public List<String> getSortedGroupNames() {
|
||||
|
||||
Reference in new issue
Block a user