1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-27 07:52:18 +00:00

Don't use ModelResourceLocation class on dedicated server.

Missed this during the merge.
This commit is contained in:
Toad-Dev 2021-12-15 15:56:46 -08:00
parent a549400776
commit ad0080ef32
3 changed files with 64 additions and 23 deletions

View File

@ -21,8 +21,10 @@ import javax.annotation.Nonnull;
public class TurtleCraftingTable extends AbstractTurtleUpgrade
{
private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_left", "inventory" );
private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_right", "inventory" );
@Environment( EnvType.CLIENT )
private ModelResourceLocation leftModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation rightModel;
public TurtleCraftingTable( ResourceLocation id, ItemStack stack )
{
@ -40,6 +42,17 @@ public class TurtleCraftingTable extends AbstractTurtleUpgrade
@Environment( EnvType.CLIENT )
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
{
loadModelLocations();
return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel );
}
@Environment( EnvType.CLIENT )
private void loadModelLocations()
{
if( leftModel == null )
{
leftModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_left", "inventory" );
rightModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_right", "inventory" );
}
}
}

View File

@ -63,30 +63,19 @@ public class TurtleModem extends AbstractTurtleUpgrade
private final boolean advanced;
private final ModelResourceLocation leftOffModel;
private final ModelResourceLocation rightOffModel;
private final ModelResourceLocation leftOnModel;
private final ModelResourceLocation rightOnModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation leftOffModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation rightOffModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation leftOnModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation rightOnModel;
public TurtleModem( ResourceLocation id, ItemStack stack, boolean advanced )
{
super( id, TurtleUpgradeType.PERIPHERAL, advanced ? WirelessModemPeripheral.ADVANCED_ADJECTIVE : WirelessModemPeripheral.NORMAL_ADJECTIVE, stack );
this.advanced = advanced;
if( advanced )
{
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_left", "inventory" );
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_right", "inventory" );
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_left", "inventory" );
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_right", "inventory" );
}
else
{
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_left", "inventory" );
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_right", "inventory" );
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_left", "inventory" );
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_right", "inventory" );
}
}
@Override
@ -107,6 +96,8 @@ public class TurtleModem extends AbstractTurtleUpgrade
@Environment( EnvType.CLIENT )
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
{
loadModelLocations();
boolean active = false;
if( turtle != null )
{
@ -119,6 +110,30 @@ public class TurtleModem extends AbstractTurtleUpgrade
: TransformedModel.of( active ? rightOnModel : rightOffModel );
}
// This exists separate from the constructor because we can't use the class ModelResourceLocation on the dedicated
// server.
@Environment( EnvType.CLIENT )
private void loadModelLocations()
{
if( leftOffModel == null )
{
if( advanced )
{
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_left", "inventory" );
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_right", "inventory" );
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_left", "inventory" );
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_right", "inventory" );
}
else
{
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_left", "inventory" );
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_right", "inventory" );
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_left", "inventory" );
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_right", "inventory" );
}
}
}
@Override
public void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side )
{

View File

@ -25,8 +25,10 @@ import javax.annotation.Nonnull;
public class TurtleSpeaker extends AbstractTurtleUpgrade
{
private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_left", "inventory" );
private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_right", "inventory" );
@Environment( EnvType.CLIENT )
private ModelResourceLocation leftModel;
@Environment( EnvType.CLIENT )
private ModelResourceLocation rightModel;
private static class Peripheral extends UpgradeSpeakerPeripheral
{
@ -73,9 +75,20 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
@Environment( EnvType.CLIENT )
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
{
loadModelLocations();
return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel );
}
@Environment( EnvType.CLIENT )
private void loadModelLocations()
{
if( leftModel == null )
{
leftModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_left", "inventory" );
rightModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_right", "inventory" );
}
}
@Override
public void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide turtleSide )
{