mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Remove craft tweaker integration
This commit is contained in:
parent
600227e481
commit
99de00e16e
@ -48,7 +48,6 @@ tasks.withType(JavaExec).configureEach {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
main.java {
|
main.java {
|
||||||
exclude 'dan200/computercraft/shared/integration/morered/**'
|
exclude 'dan200/computercraft/shared/integration/morered/**'
|
||||||
exclude 'dan200/computercraft/shared/integration/crafttweaker/**'
|
|
||||||
}
|
}
|
||||||
main.resources {
|
main.resources {
|
||||||
srcDir 'src/generated/resources'
|
srcDir 'src/generated/resources'
|
||||||
@ -153,7 +152,6 @@ dependencies {
|
|||||||
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||||
|
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api")
|
compileOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14:api")
|
||||||
// compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313")
|
|
||||||
// compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
|
// compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
|
||||||
|
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.17.1:8.0.0.14")
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.integration.crafttweaker;
|
|
||||||
|
|
||||||
import com.blamejared.crafttweaker.api.logger.ILogger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger which tracks if it has any messages.
|
|
||||||
*/
|
|
||||||
public final class TrackingLogger
|
|
||||||
{
|
|
||||||
private final ILogger logger;
|
|
||||||
private boolean ok = true;
|
|
||||||
|
|
||||||
public TrackingLogger( ILogger logger )
|
|
||||||
{
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOk()
|
|
||||||
{
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warning( String message )
|
|
||||||
{
|
|
||||||
logger.warning( message );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error( String message )
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
logger.error( message );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.integration.crafttweaker;
|
|
||||||
|
|
||||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
|
||||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
|
||||||
import com.blamejared.crafttweaker.api.item.IItemStack;
|
|
||||||
import dan200.computercraft.shared.integration.crafttweaker.actions.AddTurtleTool;
|
|
||||||
import dan200.computercraft.shared.integration.crafttweaker.actions.RemoveTurtleUpgradeByItem;
|
|
||||||
import dan200.computercraft.shared.integration.crafttweaker.actions.RemoveTurtleUpgradeByName;
|
|
||||||
import org.openzen.zencode.java.ZenCodeType;
|
|
||||||
|
|
||||||
@ZenRegister
|
|
||||||
@ZenCodeType.Name( "dan200.computercraft.turtle" )
|
|
||||||
public class TurtleTweaker
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Remove a turtle upgrade with the given id.
|
|
||||||
*
|
|
||||||
* @param upgrade The ID of the to remove
|
|
||||||
*/
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void removeUpgrade( String upgrade )
|
|
||||||
{
|
|
||||||
CraftTweakerAPI.apply( new RemoveTurtleUpgradeByName( upgrade ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a turtle upgrade crafted with the given item stack".
|
|
||||||
*
|
|
||||||
* @param stack The stack with which the upgrade is crafted.
|
|
||||||
*/
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void removeUpgrade( IItemStack stack )
|
|
||||||
{
|
|
||||||
CraftTweakerAPI.apply( new RemoveTurtleUpgradeByItem( stack.getInternal() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new turtle tool with the given id, which crafts and acts using the given stack.
|
|
||||||
*
|
|
||||||
* @param id The new upgrade's ID
|
|
||||||
* @param stack The stack used for crafting the upgrade and used by the turtle as a tool.
|
|
||||||
*/
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void addTool( String id, IItemStack stack )
|
|
||||||
{
|
|
||||||
addTool( id, stack, stack, "tool" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void addTool( String id, IItemStack craftingStack, IItemStack toolStack )
|
|
||||||
{
|
|
||||||
addTool( id, craftingStack, toolStack, "tool" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void addTool( String id, IItemStack stack, String kind )
|
|
||||||
{
|
|
||||||
addTool( id, stack, stack, kind );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCodeType.Method
|
|
||||||
public static void addTool( String id, IItemStack craftingStack, IItemStack toolStack, String kind )
|
|
||||||
{
|
|
||||||
CraftTweakerAPI.apply( new AddTurtleTool( id, craftingStack.getInternal(), toolStack.getInternal(), kind ) );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.integration.crafttweaker.actions;
|
|
||||||
|
|
||||||
import com.blamejared.crafttweaker.api.actions.IUndoableAction;
|
|
||||||
import com.blamejared.crafttweaker.api.logger.ILogger;
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
|
||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
|
||||||
import dan200.computercraft.shared.TurtleUpgrades;
|
|
||||||
import dan200.computercraft.shared.integration.crafttweaker.TrackingLogger;
|
|
||||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a new turtle tool.
|
|
||||||
*/
|
|
||||||
public class AddTurtleTool implements IUndoableAction
|
|
||||||
{
|
|
||||||
private interface Factory
|
|
||||||
{
|
|
||||||
TurtleTool create( ResourceLocation location, ItemStack craftItem, ItemStack toolItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Map<String, Factory> kinds = new HashMap<>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
kinds.put( "tool", TurtleTool::new );
|
|
||||||
kinds.put( "axe", TurtleAxe::new );
|
|
||||||
kinds.put( "hoe", TurtleHoe::new );
|
|
||||||
kinds.put( "shovel", TurtleShovel::new );
|
|
||||||
kinds.put( "sword", TurtleSword::new );
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
private final ItemStack craftItem;
|
|
||||||
private final ItemStack toolItem;
|
|
||||||
private final String kind;
|
|
||||||
|
|
||||||
private ITurtleUpgrade upgrade;
|
|
||||||
|
|
||||||
public AddTurtleTool( String id, ItemStack craftItem, ItemStack toolItem, String kind )
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.craftItem = craftItem;
|
|
||||||
this.toolItem = toolItem;
|
|
||||||
this.kind = kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply()
|
|
||||||
{
|
|
||||||
ITurtleUpgrade upgrade = this.upgrade;
|
|
||||||
if( upgrade == null )
|
|
||||||
{
|
|
||||||
Factory factory = kinds.get( kind );
|
|
||||||
if( factory == null )
|
|
||||||
{
|
|
||||||
ComputerCraft.log.error( "Unknown turtle upgrade kind '{}' (this should have been rejected by verify!)", kind );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrade = this.upgrade = factory.create( new ResourceLocation( id ), craftItem, toolItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
TurtleUpgrades.register( upgrade );
|
|
||||||
}
|
|
||||||
catch( RuntimeException e )
|
|
||||||
{
|
|
||||||
ComputerCraft.log.error( "Registration of turtle tool failed", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe()
|
|
||||||
{
|
|
||||||
return String.format( "Add new turtle %s '%s' (crafted with '%s', uses a '%s')", kind, id, craftItem, toolItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo()
|
|
||||||
{
|
|
||||||
if( upgrade != null ) TurtleUpgrades.remove( upgrade );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo()
|
|
||||||
{
|
|
||||||
return String.format( "Removing turtle upgrade %s.", id );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validate( ILogger logger )
|
|
||||||
{
|
|
||||||
TrackingLogger trackLog = new TrackingLogger( logger );
|
|
||||||
|
|
||||||
if( craftItem.isEmpty() ) trackLog.error( "Crafting item stack is empty." );
|
|
||||||
|
|
||||||
if( craftItem.isDamaged() || craftItem.isEnchanted() || craftItem.hasCustomHoverName() )
|
|
||||||
{
|
|
||||||
trackLog.warning( "Crafting item has NBT." );
|
|
||||||
}
|
|
||||||
if( toolItem.isEmpty() ) trackLog.error( "Tool item stack is empty." );
|
|
||||||
|
|
||||||
if( !kinds.containsKey( kind ) ) trackLog.error( String.format( "Unknown kind '%s'.", kind ) );
|
|
||||||
|
|
||||||
if( TurtleUpgrades.get( id ) != null )
|
|
||||||
{
|
|
||||||
trackLog.error( String.format( "An upgrade with the same name ('%s') has already been registered.", id ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return trackLog.isOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldApplyOn( LogicalSide side )
|
|
||||||
{
|
|
||||||
return shouldApplySingletons();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.integration.crafttweaker.actions;
|
|
||||||
|
|
||||||
import com.blamejared.crafttweaker.api.actions.IUndoableAction;
|
|
||||||
import com.blamejared.crafttweaker.api.logger.ILogger;
|
|
||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
|
||||||
import dan200.computercraft.shared.TurtleUpgrades;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a turtle upgrade crafted with the given stack.
|
|
||||||
*/
|
|
||||||
public class RemoveTurtleUpgradeByItem implements IUndoableAction
|
|
||||||
{
|
|
||||||
private final ItemStack stack;
|
|
||||||
private ITurtleUpgrade upgrade;
|
|
||||||
|
|
||||||
public RemoveTurtleUpgradeByItem( ItemStack stack )
|
|
||||||
{
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply()
|
|
||||||
{
|
|
||||||
ITurtleUpgrade upgrade = this.upgrade = TurtleUpgrades.get( stack );
|
|
||||||
if( upgrade != null ) TurtleUpgrades.disable( upgrade );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe()
|
|
||||||
{
|
|
||||||
return String.format( "Remove turtle upgrades crafted with '%s'", stack );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo()
|
|
||||||
{
|
|
||||||
if( upgrade != null ) TurtleUpgrades.enable( upgrade );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo()
|
|
||||||
{
|
|
||||||
return String.format( "Adding back turtle upgrades crafted with '%s'", stack );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validate( ILogger logger )
|
|
||||||
{
|
|
||||||
if( TurtleUpgrades.get( stack ) == null )
|
|
||||||
{
|
|
||||||
logger.error( String.format( "Unknown turtle upgrade crafted with '%s'.", stack ) );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldApplyOn( LogicalSide side )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.integration.crafttweaker.actions;
|
|
||||||
|
|
||||||
import com.blamejared.crafttweaker.api.actions.IUndoableAction;
|
|
||||||
import com.blamejared.crafttweaker.api.logger.ILogger;
|
|
||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
|
||||||
import dan200.computercraft.shared.TurtleUpgrades;
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a turtle upgrade with the given id.
|
|
||||||
*/
|
|
||||||
public class RemoveTurtleUpgradeByName implements IUndoableAction
|
|
||||||
{
|
|
||||||
private final String id;
|
|
||||||
private ITurtleUpgrade upgrade;
|
|
||||||
|
|
||||||
public RemoveTurtleUpgradeByName( String id )
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply()
|
|
||||||
{
|
|
||||||
ITurtleUpgrade upgrade = this.upgrade = TurtleUpgrades.get( id );
|
|
||||||
if( upgrade != null ) TurtleUpgrades.disable( upgrade );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe()
|
|
||||||
{
|
|
||||||
return String.format( "Remove turtle upgrade '%s'", id );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo()
|
|
||||||
{
|
|
||||||
if( upgrade != null ) TurtleUpgrades.enable( upgrade );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo()
|
|
||||||
{
|
|
||||||
return String.format( "Adding back turtle upgrade '%s'", id );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validate( ILogger logger )
|
|
||||||
{
|
|
||||||
if( TurtleUpgrades.get( id ) == null )
|
|
||||||
{
|
|
||||||
logger.error( String.format( "Unknown turtle upgrade '%s'.", id ) );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldApplyOn( LogicalSide side )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user