mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 11:10:29 +00:00
Even more proxy pruning
- Move the "world directory" getter out of the proxy - we can just use Forge's code here. - Remove the server proxies, as both were empty. We don't tend to register any dedicated-server specific code, so I think we can leave them out.
This commit is contained in:
parent
63691707fc
commit
1c648850ab
@ -71,6 +71,7 @@ import net.minecraft.util.EnumHand;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.SidedProxy;
|
import net.minecraftforge.fml.common.SidedProxy;
|
||||||
@ -236,11 +237,17 @@ public class ComputerCraft
|
|||||||
@Mod.Instance( value = ComputerCraft.MOD_ID )
|
@Mod.Instance( value = ComputerCraft.MOD_ID )
|
||||||
public static ComputerCraft instance;
|
public static ComputerCraft instance;
|
||||||
|
|
||||||
@SidedProxy( clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient", serverSide = "dan200.computercraft.server.proxy.ComputerCraftProxyServer" )
|
@SidedProxy(
|
||||||
public static IComputerCraftProxy proxy;
|
clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient",
|
||||||
|
serverSide = "dan200.computercraft.shared.proxy.ComputerCraftProxyCommon"
|
||||||
|
)
|
||||||
|
private static IComputerCraftProxy proxy;
|
||||||
|
|
||||||
@SidedProxy( clientSide = "dan200.computercraft.client.proxy.CCTurtleProxyClient", serverSide = "dan200.computercraft.server.proxy.CCTurtleProxyServer" )
|
@SidedProxy(
|
||||||
public static ICCTurtleProxy turtleProxy;
|
clientSide = "dan200.computercraft.client.proxy.CCTurtleProxyClient",
|
||||||
|
serverSide = "dan200.computercraft.shared.proxy.CCTurtleProxyCommon"
|
||||||
|
)
|
||||||
|
private static ICCTurtleProxy turtleProxy;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit( FMLPreInitializationEvent event )
|
public void preInit( FMLPreInitializationEvent event )
|
||||||
@ -359,11 +366,6 @@ public class ComputerCraft
|
|||||||
return new File( getBaseDir(), "resourcepacks" );
|
return new File( getBaseDir(), "resourcepacks" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getWorldDir( World world )
|
|
||||||
{
|
|
||||||
return proxy.getWorldDir( world );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendToPlayer( EntityPlayer player, IMessage packet )
|
public static void sendToPlayer( EntityPlayer player, IMessage packet )
|
||||||
{
|
{
|
||||||
networkWrapper.sendTo( packet, (EntityPlayerMP) player );
|
networkWrapper.sendTo( packet, (EntityPlayerMP) player );
|
||||||
@ -460,7 +462,7 @@ public class ComputerCraft
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
|
public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
|
||||||
{
|
{
|
||||||
return IDAssigner.getNextIDFromDirectory( new File( getWorldDir( world ), parentSubPath ) );
|
return IDAssigner.getNextIDFromDirectory( parentSubPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -468,7 +470,7 @@ public class ComputerCraft
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new FileMount( new File( getWorldDir( world ), subPath ), capacity );
|
return new FileMount( new File( getWorldDir(), subPath ), capacity );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
@ -688,7 +690,18 @@ public class ComputerCraft
|
|||||||
dan200.computercraft.shared.TurtleUpgrades.register( upgrade );
|
dan200.computercraft.shared.TurtleUpgrades.register( upgrade );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getWorldDir()
|
||||||
|
{
|
||||||
|
return DimensionManager.getCurrentSaveRootDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
//region Compatibility
|
//region Compatibility
|
||||||
|
@Deprecated
|
||||||
|
public static File getWorldDir( World world )
|
||||||
|
{
|
||||||
|
return DimensionManager.getCurrentSaveRootDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static IMedia getMedia( ItemStack stack )
|
public static IMedia getMedia( ItemStack stack )
|
||||||
{
|
{
|
||||||
|
@ -83,12 +83,6 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||||||
ClientRegistry.bindTileEntitySpecialRenderer( TileCable.class, new TileEntityCableRenderer() );
|
ClientRegistry.bindTileEntitySpecialRenderer( TileCable.class, new TileEntityCableRenderer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getWorldDir( World world )
|
|
||||||
{
|
|
||||||
return world.getSaveHandler().getWorldDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playRecordClient( BlockPos pos, SoundEvent record, String info )
|
public void playRecordClient( BlockPos pos, SoundEvent record, String info )
|
||||||
{
|
{
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dan200.computercraft.server.proxy;
|
|
||||||
|
|
||||||
import dan200.computercraft.shared.proxy.CCTurtleProxyCommon;
|
|
||||||
|
|
||||||
public class CCTurtleProxyServer extends CCTurtleProxyCommon
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dan200.computercraft.server.proxy;
|
|
||||||
|
|
||||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class ComputerCraftProxyServer extends ComputerCraftProxyCommon
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public File getWorldDir( World world )
|
|
||||||
{
|
|
||||||
return DimensionManager.getWorld( 0 ).getSaveHandler().getWorldDirectory();
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,6 @@ import net.minecraftforge.common.util.Constants;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -66,10 +65,7 @@ public final class WiredModemLocalPeripheral
|
|||||||
else if( id < 0 || !type.equals( this.type ) )
|
else if( id < 0 || !type.equals( this.type ) )
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.id = IDAssigner.getNextIDFromFile( new File(
|
this.id = IDAssigner.getNextIDFromFile( "computer/lastid_" + type + ".txt" );
|
||||||
ComputerCraft.getWorldDir( world ),
|
|
||||||
"computer/lastid_" + type + ".txt"
|
|
||||||
) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldPeripheral == null || !oldPeripheral.equals( peripheral );
|
return oldPeripheral == null || !oldPeripheral.equals( peripheral );
|
||||||
|
@ -11,7 +11,7 @@ import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||||
|
|
||||||
public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
public class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void preInit()
|
public void preInit()
|
||||||
|
@ -63,7 +63,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import pl.asie.charset.ModCharset;
|
import pl.asie.charset.ModCharset;
|
||||||
|
|
||||||
public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
public class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void preInit()
|
public void preInit()
|
||||||
|
@ -10,9 +10,6 @@ import dan200.computercraft.shared.command.text.TableBuilder;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public interface IComputerCraftProxy
|
public interface IComputerCraftProxy
|
||||||
{
|
{
|
||||||
@ -22,8 +19,6 @@ public interface IComputerCraftProxy
|
|||||||
|
|
||||||
void initServer( MinecraftServer server );
|
void initServer( MinecraftServer server );
|
||||||
|
|
||||||
File getWorldDir( World world );
|
|
||||||
|
|
||||||
default void playRecordClient( BlockPos pos, SoundEvent record, String info )
|
default void playRecordClient( BlockPos pos, SoundEvent record, String info )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,16 @@ public class IDAssigner
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getNextIDFromDirectory( String path )
|
||||||
|
{
|
||||||
|
return getNextIDFromDirectory( new File( ComputerCraft.getWorldDir(), path ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNextIDFromFile( String path )
|
||||||
|
{
|
||||||
|
return getNextIDFromFile( new File( ComputerCraft.getWorldDir(), path ) );
|
||||||
|
}
|
||||||
|
|
||||||
public static int getNextIDFromDirectory( File dir )
|
public static int getNextIDFromDirectory( File dir )
|
||||||
{
|
{
|
||||||
return getNextID( dir, true );
|
return getNextID( dir, true );
|
||||||
|
Loading…
Reference in New Issue
Block a user