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:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user