mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
Improved the chisel variation logger, fixed an issue with the chisel commands, and made the aspect logger a bit nicer internally.
This commit is contained in:
1 parent
ad35d12c44
commit
e52a9b7a58
4 files changed
+109
-5
No files matched your search
@@ -17,12 +17,24 @@ public class ChiselHelper {
|
||||
{
|
||||
return CarvingUtils.getChiselRegistry().getGroup(name);
|
||||
}
|
||||
|
||||
public static ICarvingGroup getGroup(IItemStack stack)
|
||||
{
|
||||
return CarvingUtils.getChiselRegistry().getGroup(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage());
|
||||
}
|
||||
|
||||
public static ICarvingVariation getVariation(IItemStack stack)
|
||||
{
|
||||
return Carving.chisel.getVariation(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage());
|
||||
}
|
||||
|
||||
public static boolean groupContainsVariation(ICarvingGroup group, ICarvingVariation variation)
|
||||
{
|
||||
for(ICarvingVariation otherVariation : group.getVariations())
|
||||
{
|
||||
if(otherVariation.getBlock()==variation.getBlock() && otherVariation.getBlockMeta()==variation.getBlockMeta())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.item.Item;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
@@ -46,7 +47,7 @@ public class ChiselVariationLogger implements ICommandFunction{
|
||||
}
|
||||
System.out.println("Chisel Variations: " + variations.size());
|
||||
for (Entry<ICarvingVariation, ICarvingGroup> entry: variations.entrySet()) {
|
||||
String stringedVariation=entry.getKey().getBlock().getUnlocalizedName()+" "+entry.getKey().getBlockMeta();
|
||||
String stringedVariation="<"+Item.itemRegistry.getNameForObject(Item.getItemFromBlock(entry.getKey().getBlock()))+":"+entry.getKey().getBlockMeta()+">";
|
||||
if(arguments.length==0)
|
||||
stringedVariation+=" "+entry.getValue().getName();
|
||||
System.out.println("Chisel Variation " + stringedVariation);
|
||||
|
||||
@@ -7,6 +7,7 @@ import static modtweaker.helpers.StackHelper.areEqual;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
@@ -33,8 +34,52 @@ public class Groups {
|
||||
MineTweakerAPI.getLogger().logError("Can create variation from " + stack);
|
||||
return;
|
||||
}
|
||||
group.addVariation(variation);
|
||||
MineTweakerAPI.apply(new AddVariation(group,variation, stack.getDisplayName()));
|
||||
}
|
||||
|
||||
static class AddVariation implements IUndoableAction {
|
||||
|
||||
ICarvingGroup group;
|
||||
ICarvingVariation variation;
|
||||
String variationName;
|
||||
|
||||
public AddVariation(ICarvingGroup group,ICarvingVariation variation, String variationName) {
|
||||
this.group=group;
|
||||
this.variation=variation;
|
||||
this.variationName=variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
group.addVariation(variation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return group != null && variation != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Variation: " + variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Variation: " + variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
group.removeVariation(variation.getBlock(),variation.getBlockMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTransformation(String groupName, IItemStack stack) {
|
||||
@@ -50,11 +95,57 @@ public class Groups {
|
||||
MineTweakerAPI.getLogger().logError("Can create variation from " + stack);
|
||||
return;
|
||||
}
|
||||
if(!group.getVariations().contains(variation))
|
||||
if(!ChiselHelper.groupContainsVariation(group, variation))
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Variation doesn't exist in group " + groupName);
|
||||
return;
|
||||
}
|
||||
group.removeVariation(variation.getBlock(),variation.getBlockMeta());
|
||||
MineTweakerAPI.apply(new RemoveVariation(group,variation, stack.getDisplayName()));
|
||||
}
|
||||
|
||||
|
||||
static class RemoveVariation implements IUndoableAction {
|
||||
|
||||
ICarvingGroup group;
|
||||
ICarvingVariation variation;
|
||||
String variationName;
|
||||
|
||||
public RemoveVariation(ICarvingGroup group,ICarvingVariation variation, String variationName) {
|
||||
this.group=group;
|
||||
this.variation=variation;
|
||||
this.variationName=variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
group.removeVariation(variation.getBlock(),variation.getBlockMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return group != null && variation != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Variation: " + variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Adding Variation: " + variationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
group.addVariation(variation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class AspectLogger implements ICommandFunction{
|
||||
{
|
||||
Item item=(Item)entry.getKey().get(i);
|
||||
|
||||
itemList.add("<"+item.itemRegistry.getNameForObject(item)+":"+entry.getKey().get(i+1)+">");
|
||||
itemList.add("<"+Item.itemRegistry.getNameForObject(item)+":"+entry.getKey().get(i+1)+">");
|
||||
}
|
||||
lines.add(itemList.toString()+": "+ThaumcraftHelper.aspectsToString(entry.getValue()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user