mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-20 20:32:24 +00:00
Add variation removal support to API, add ICarvingRegistry
This commit is contained in:
1 parent
fd7fabf397
commit
974ceec043
10 files changed
+85
-12
No files matched your search
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api;
|
||||
|
||||
public class ChiselAPIProps {
|
||||
|
||||
public static final String VERSION = "0.0.1";
|
||||
public static final String VERSION = "0.0.2";
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CarvingUtils {
|
||||
@@ -27,4 +29,30 @@ public class CarvingUtils {
|
||||
public static ItemStack getStack(ICarvingVariation variation) {
|
||||
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
|
||||
}
|
||||
|
||||
private static Field _chisel;
|
||||
private static boolean errored = false;
|
||||
private static final String CARVING_CLASS = "com.cricketcraft.chisel.carving.Carving";
|
||||
|
||||
/**
|
||||
* @return The instance of the chisel carving registry from the chisel mod.
|
||||
* <p>
|
||||
* If chisel is not installed or some other error occurs this will return null.
|
||||
*/
|
||||
public static ICarvingRegistry getChiselRegistry() {
|
||||
if (errored) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (_chisel == null) {
|
||||
_chisel = Class.forName(CARVING_CLASS).getDeclaredField("chisel");
|
||||
}
|
||||
return (ICarvingRegistry) _chisel.get(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errored = true;
|
||||
return getChiselRegistry();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Represents a group of chiselable blocks.
|
||||
* <p>
|
||||
@@ -63,4 +65,15 @@ public interface ICarvingGroup {
|
||||
* An {@link ICarvingVariation} to add to this group
|
||||
*/
|
||||
void addVariation(ICarvingVariation variation);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from this group.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata);
|
||||
}
|
||||
Reference in new issue
Block a user