mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-26 00:46:54 +00:00
Remove direct support for beginner's turtles
As CCEdu has not been updated, and is unlikely to be updated as Dan does not have the rights to open source it, we're removing explicit support for now. If an alternative arises in the future, it would be good to support, but in a way which requires less workarounds in CC's core.
This commit is contained in:
parent
dd6bab5413
commit
4ead319092
@ -44,12 +44,10 @@ import java.util.List;
|
||||
|
||||
public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurtle>
|
||||
{
|
||||
private static ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle", "inventory" );
|
||||
private static ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_advanced", "inventory" );
|
||||
private static ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_white", "inventory" );
|
||||
private static ModelResourceLocation BEGINNER_TURTLE_MODEL = new ModelResourceLocation( "computercraftedu:CC-TurtleJunior", "inventory" );
|
||||
private static ModelResourceLocation BEGINNER_TURTLE_COLOUR_MODEL = new ModelResourceLocation( "computercraftedu:turtleJunior_white", "inventory" );
|
||||
private static ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft:turtle_elf_overlay", "inventory" );
|
||||
private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle", "inventory" );
|
||||
private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_advanced", "inventory" );
|
||||
private static final ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_white", "inventory" );
|
||||
private static final ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft:turtle_elf_overlay", "inventory" );
|
||||
|
||||
public TileEntityTurtleRenderer()
|
||||
{
|
||||
@ -85,8 +83,6 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
return coloured ? COLOUR_TURTLE_MODEL : NORMAL_TURTLE_MODEL;
|
||||
case Advanced:
|
||||
return coloured ? COLOUR_TURTLE_MODEL : ADVANCED_TURTLE_MODEL;
|
||||
case Beginners:
|
||||
return coloured ? BEGINNER_TURTLE_COLOUR_MODEL : BEGINNER_TURTLE_MODEL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +92,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
{
|
||||
return new ModelResourceLocation( overlay, "inventory" );
|
||||
}
|
||||
else if( christmas && family != ComputerFamily.Beginners )
|
||||
else if( christmas )
|
||||
{
|
||||
return ELF_OVERLAY_MODEL;
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ public enum ComputerFamily
|
||||
{
|
||||
Normal,
|
||||
Advanced,
|
||||
Beginners,
|
||||
@Deprecated Beginners,
|
||||
Command
|
||||
}
|
||||
|
@ -148,14 +148,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
|
||||
public static boolean isUpgradeSuitableForFamily( ComputerFamily family, ITurtleUpgrade upgrade )
|
||||
{
|
||||
if( family == ComputerFamily.Beginners )
|
||||
{
|
||||
return upgrade.getType().isTool();
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addAllUpgradedTurtles( ComputerFamily family, NonNullList<ItemStack> list )
|
||||
|
@ -21,7 +21,6 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@ -955,12 +954,6 @@ public class TurtleBrain implements ITurtleAccess
|
||||
m_owner.updateBlock();
|
||||
}
|
||||
|
||||
public boolean saveBlockChange( BlockPos coordinates, IBlockState previousState )
|
||||
{
|
||||
// Overriden by CCEdu
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
switch( m_animation )
|
||||
|
@ -95,13 +95,6 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
turtle.getInventory().setInventorySlotContents( turtle.getSelectedSlot(), remainder );
|
||||
turtle.getInventory().markDirty();
|
||||
|
||||
// Remember the old block
|
||||
if( turtle instanceof TurtleBrain && previousState != null )
|
||||
{
|
||||
TurtleBrain brain = (TurtleBrain) turtle;
|
||||
brain.saveBlockChange( coordinates, previousState );
|
||||
}
|
||||
|
||||
// Animate and return success
|
||||
turtle.playAnimation( TurtleAnimation.Wait );
|
||||
return TurtleCommandResult.success();
|
||||
|
@ -121,17 +121,9 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
{
|
||||
case Normal:
|
||||
default:
|
||||
{
|
||||
return "tile.computercraft:turtle";
|
||||
}
|
||||
case Advanced:
|
||||
{
|
||||
return "tile.computercraft:advanced_turtle";
|
||||
}
|
||||
case Beginners:
|
||||
{
|
||||
return "tile.computercraftedu:beginner_turtle";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@ import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.turtle.blocks.ITurtleTile;
|
||||
import dan200.computercraft.shared.util.ReflectionUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -34,16 +32,9 @@ public class TurtleItemFactory
|
||||
String label = computer.getLabel();
|
||||
if( label != null )
|
||||
{
|
||||
if( turtle.getFamily() != ComputerFamily.Beginners )
|
||||
{
|
||||
int id = computer.getID();
|
||||
int fuelLevel = turtle.getAccess().getFuelLevel();
|
||||
return create( id, label, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, fuelLevel, turtle.getOverlay() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return create( -1, label, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, 0, turtle.getOverlay() );
|
||||
}
|
||||
int id = computer.getID();
|
||||
int fuelLevel = turtle.getAccess().getFuelLevel();
|
||||
return create( id, label, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, fuelLevel, turtle.getOverlay() );
|
||||
}
|
||||
}
|
||||
return create( -1, null, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, 0, turtle.getOverlay() );
|
||||
@ -66,27 +57,8 @@ public class TurtleItemFactory
|
||||
ItemTurtleBase advanced = ((ItemTurtleBase) Item.getItemFromBlock( ComputerCraft.Blocks.turtleAdvanced ));
|
||||
return advanced.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
}
|
||||
case Beginners:
|
||||
{
|
||||
Block beginnersBlock = ReflectionUtil.safeGet(
|
||||
ReflectionUtil.getOptionalField(
|
||||
ReflectionUtil.getOptionalInnerClass(
|
||||
ReflectionUtil.getOptionalClass( "dan200.computercraftedu.ComputerCraftEdu" ),
|
||||
"Blocks"
|
||||
),
|
||||
"turtleJunior"
|
||||
),
|
||||
null,
|
||||
Block.class
|
||||
);
|
||||
if( beginnersBlock != null )
|
||||
{
|
||||
ItemTurtleBase beginnersItem = ((ItemTurtleBase) Item.getItemFromBlock( beginnersBlock ));
|
||||
return beginnersItem.create( id, label, colour, leftUpgrade, rightUpgrade, fuelLevel, overlay );
|
||||
}
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ public class TurtleRecipe extends ComputerConvertRecipe
|
||||
int computerID = item.getComputerID( stack );
|
||||
String label = item.getLabel( stack );
|
||||
|
||||
if( family == ComputerFamily.Beginners ) computerID = -1;
|
||||
|
||||
return TurtleItemFactory.create( computerID, label, -1, family, null, null, 0, null );
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import dan200.computercraft.api.turtle.event.TurtleAttackEvent;
|
||||
import dan200.computercraft.api.turtle.event.TurtleBlockEvent;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
@ -245,13 +244,6 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
|
||||
stopConsuming( turtle );
|
||||
|
||||
// Remember the previous block
|
||||
if( turtle instanceof TurtleBrain )
|
||||
{
|
||||
TurtleBrain brain = (TurtleBrain) turtle;
|
||||
brain.saveBlockChange( blockPosition, state );
|
||||
}
|
||||
|
||||
return TurtleCommandResult.success();
|
||||
|
||||
}
|
||||
|
@ -1,229 +0,0 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class ReflectionUtil
|
||||
{
|
||||
public static Class<?> getOptionalClass( String name )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Class.forName( name );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Class<?> getOptionalInnerClass( Class<?> enclosingClass, String name )
|
||||
{
|
||||
if( enclosingClass != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?>[] declaredClasses = enclosingClass.getDeclaredClasses();
|
||||
if( declaredClasses != null )
|
||||
{
|
||||
for( Class<?> declaredClass : declaredClasses )
|
||||
{
|
||||
if( declaredClass.getSimpleName().equals( name ) )
|
||||
{
|
||||
return declaredClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Method getOptionalMethod( Class<?> clazz, String name, Class<?>[] arguments )
|
||||
{
|
||||
if( clazz != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return clazz.getDeclaredMethod( name, arguments );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> Constructor<T> getOptionalConstructor( Class<T> clazz, Class<?>[] arguments )
|
||||
{
|
||||
if( clazz != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return clazz.getConstructor( arguments );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Field getOptionalField( Class<?> clazz, String name )
|
||||
{
|
||||
if( clazz != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
Field field = clazz.getDeclaredField( name );
|
||||
if( field != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
field.setAccessible( true );
|
||||
}
|
||||
catch( Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
return field;
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T safeNew( Constructor<T> constructor, Object[] arguments, Class<T> resultClass )
|
||||
{
|
||||
if( constructor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
T result = constructor.newInstance( arguments );
|
||||
if( result != null && resultClass.isInstance( result ) )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean safeInstanceOf( Object object, Class<?> clazz )
|
||||
{
|
||||
if( clazz != null )
|
||||
{
|
||||
return clazz.isInstance( object );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void safeInvoke( Method method, Object object, Object[] arguments )
|
||||
{
|
||||
if( method != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( object == null || method.getClass().isInstance( object ) )
|
||||
{
|
||||
method.invoke( object, arguments );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public static <T> T safeInvoke( Method method, Object object, Object[] arguments, Class<T> resultClass )
|
||||
{
|
||||
if( method != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( (object == null && Modifier.isStatic( method.getModifiers() )) ||
|
||||
method.getDeclaringClass().isInstance( object ) )
|
||||
{
|
||||
Object result = method.invoke( object, arguments );
|
||||
if( result != null && resultClass.isInstance( result ) )
|
||||
{
|
||||
return (T) result;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public static <T> T safeGet( Field field, Object object, Class<T> resultClass )
|
||||
{
|
||||
if( field != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( (object == null && Modifier.isStatic( field.getModifiers() )) ||
|
||||
field.getDeclaringClass().isInstance( object ) )
|
||||
{
|
||||
Object result = field.get( object );
|
||||
if( result != null && resultClass.isInstance( result ) )
|
||||
{
|
||||
return (T) result;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T safeSet( Field field, Object object, T value )
|
||||
{
|
||||
if( field != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( object == null || field.getClass().isInstance( object ) )
|
||||
{
|
||||
field.set( object, value );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user