1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-17 21:55:12 +00:00

Basic Minetweaker support (#327)

This provides the following methods:

 - dan200.computercraft.turtle.removeUpgrade(id: String)
 - dan200.computercraft.turtle.removeUpgrade(stack: IItemStack)
 - dan200.computercraft.turtle.addTool(id: String, craftItem: IItemStack[, toolItem: IItemStack][, kind: string])

While it's pretty minimal, it should allow for a reasonable amount of
functionality.

Closes #327 and #97.
This commit is contained in:
Jonathan Coates
2019-12-18 15:29:24 +00:00
committed by GitHub
parent 03b6d2f1ab
commit 3a5d50e572
13 changed files with 409 additions and 46 deletions

View File

@@ -48,13 +48,11 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
ItemStack normalStack = TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null );
if( !normalStack.isEmpty() && normalStack.getItem() == this ) list.add( normalStack );
for( ITurtleUpgrade upgrade : TurtleUpgrades.getVanillaUpgrades() )
{
if( !TurtleUpgrades.suitableForFamily( family, upgrade ) ) continue;
ItemStack stack = TurtleItemFactory.create( -1, null, -1, family, null, upgrade, 0, null );
if( !stack.isEmpty() && stack.getItem() == this ) list.add( stack );
}
TurtleUpgrades.getVanillaUpgrades()
.filter( x -> TurtleUpgrades.suitableForFamily( family, x ) )
.map( x -> TurtleItemFactory.create( -1, null, -1, family, null, x, 0, null ) )
.filter( x -> !x.isEmpty() && x.getItem() == this )
.forEach( list::add );
}
@Nonnull

View File

@@ -7,6 +7,7 @@
package dan200.computercraft.shared.turtle.upgrades;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class TurtleAxe extends TurtleTool
@@ -21,6 +22,11 @@ public class TurtleAxe extends TurtleTool
super( id, legacyId, item );
}
public TurtleAxe( ResourceLocation id, ItemStack craftItem, ItemStack toolItem )
{
super( id, craftItem, toolItem );
}
@Override
protected float getDamageMultiplier()
{

View File

@@ -35,6 +35,11 @@ public class TurtleHoe extends TurtleTool
super( id, legacyId, item );
}
public TurtleHoe( ResourceLocation id, ItemStack craftItem, ItemStack toolItem )
{
super( id, craftItem, toolItem );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@@ -35,6 +35,11 @@ public class TurtleShovel extends TurtleTool
super( id, legacyId, item );
}
public TurtleShovel( ResourceLocation id, ItemStack craftItem, ItemStack toolItem )
{
super( id, craftItem, toolItem );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@@ -10,6 +10,7 @@ import dan200.computercraft.shared.turtle.core.TurtlePlayer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -26,6 +27,11 @@ public class TurtleSword extends TurtleTool
super( id, legacyId, item );
}
public TurtleSword( ResourceLocation id, ItemStack craftItem, ItemStack toolItem )
{
super( id, craftItem, toolItem );
}
@Override
protected boolean canBreakBlock( IBlockState state, World world, BlockPos pos, TurtlePlayer player )
{

View File

@@ -62,6 +62,12 @@ public class TurtleTool extends AbstractTurtleUpgrade
this.item = new ItemStack( item, 1, 0 );
}
public TurtleTool( ResourceLocation id, ItemStack craftItem, ItemStack toolItem )
{
super( id, -1, TurtleUpgradeType.Tool, craftItem );
this.item = toolItem;
}
@Nonnull
@Override
@SideOnly( Side.CLIENT )
@@ -76,7 +82,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
);
Minecraft mc = Minecraft.getMinecraft();
return Pair.of(
mc.getRenderItem().getItemModelMesher().getItemModel( item ),
mc.getRenderItem().getItemModelMesher().getItemModel( getCraftingItem() ),
transform
);
}