From afa29f9b69d0990b1f1f6dfe30dbda5283d3b570 Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Sun, 4 Nov 2018 15:15:13 +0100 Subject: [PATCH] New base, cleaned code --- build.gradle | 67 ++++- gradle.properties | 2 +- .../orbsat/OrbitalSatellite.java | 64 +++++ .../orbsat/client/ClientProxy.java | 10 + .../orbsat/common/CommonProxy.java | 233 ++++++++++++++++++ .../orbsat/common/util/LogHelper.java | 47 ++++ src/main/resources/mcmod.info | 12 +- 7 files changed, 415 insertions(+), 20 deletions(-) create mode 100644 src/main/java/jackcartersmith/orbsat/OrbitalSatellite.java create mode 100644 src/main/java/jackcartersmith/orbsat/client/ClientProxy.java create mode 100644 src/main/java/jackcartersmith/orbsat/common/CommonProxy.java create mode 100644 src/main/java/jackcartersmith/orbsat/common/util/LogHelper.java diff --git a/build.gradle b/build.gradle index 29d4950..8c99770 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,8 @@ +import groovy.json.JsonOutput + +def mainVersion = "0.1" +def buildNumber = "1" + buildscript { repositories { jcenter() @@ -11,9 +16,11 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "3.0" -group = "fr.jackcartersmith.orbsat" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "orbsat" +version = "${mainVersion}-${buildNumber}" +//group = "fr.jackcartersmith.orbsat" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +group = "jackcartersmith" +def archiveGroup = group +archivesBaseName = "OrbitalSatellite" sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. compileJava { @@ -21,7 +28,7 @@ compileJava { } minecraft { - version = "1.12.2-14.23.4.2705" + version = "1.12.2-14.23.5.2768" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -30,11 +37,40 @@ minecraft { // Use non-default mappings at your own risk. they may not always work. // simply re-run your setup task after changing the mappings to update your workspace. mappings = "stable_39" + //mappings = "snapshot_20171003" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } repositories { - maven { url = "http://maven.cil.li/" } + maven { // JEI & Tinkers + name 'DVS1 Maven FS' + url 'http://dvs1.progwml6.com/files/maven' + } + maven { // HWYLA + name "TehNuts WAILA fork" + url "http://tehnut.info/maven" + } + maven { // OpenComputers + name "OpenComputers" + url "http://maven.cil.li/" + } + repositories {//Curseforge maven, in case some other maven goes offline + maven { + name = "CurseForge" + url = "https://minecraft.curseforge.com/api/maven/" + } + } + /*maven { //IC2 + name = "ic2" + url = "http://maven.ic2.player.to/" + }*/ + maven { // Redstone Flux + name 'CoFH Maven' + url "http://maven.covers1624.net/" + } + maven { // Albedo Lights + url 'https://repo.elytradev.com/' + } } dependencies { @@ -42,7 +78,6 @@ dependencies { // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" - compile "li.cil.oc:OpenComputers:MC1.12.2-1.7.+:api" // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env @@ -59,6 +94,14 @@ dependencies { // for more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html + + compileOnly "mezz.jei:jei_1.12.2:4.10.+" + compileOnly "cofh:RedstoneFlux:1.12-2.+:deobf" + compileOnly "opencomputers:OpenComputers:MC1.12.2:1.7.2.67"//li.cil.oc:OpenComputers:MC1.12.1-1.7.0.+" + compileOnly "mcp.mobius.waila:Hwyla:1.8.20-B35_1.12" + compileOnly 'industrial-craft:industrialcraft-2:release:ex112'//'net.industrial-craft:industrialcraft-2:2.8.+' + compileOnly 'baubles:Baubles:1.12:1.5.2' + deobfCompile 'elucent:albedo:2.0-SNAPSHOT' } @@ -69,14 +112,14 @@ processResources { // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - + include "mcmod.info" + // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version + expand "version": project.version, "mcversion": "1.12" } - - // copy everything else except the mcmod.info + + // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' + exclude "mcmod.info" } } diff --git a/gradle.properties b/gradle.properties index e9b9fd5..7cab1f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G +org.gradle.jvmargs=-Xmx4G diff --git a/src/main/java/jackcartersmith/orbsat/OrbitalSatellite.java b/src/main/java/jackcartersmith/orbsat/OrbitalSatellite.java new file mode 100644 index 0000000..02492a3 --- /dev/null +++ b/src/main/java/jackcartersmith/orbsat/OrbitalSatellite.java @@ -0,0 +1,64 @@ +package jackcartersmith.orbsat; + +import jackcartersmith.orbsat.common.CommonProxy; +import jackcartersmith.orbsat.common.util.LogHelper; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; + +@Mod(modid = OrbitalSatellite.MODID, name = OrbitalSatellite.NAME, version = OrbitalSatellite.VERSION, dependencies = "required-after:forge@[14.23.5.2768,)") +public class OrbitalSatellite { + public static final String MODID = "orbsat"; + public static final String NAME = "Orbital Satellite"; + public static final String VERSION = "${version}"; + + @Mod.Instance(MODID) + public static OrbitalSatellite instance = new OrbitalSatellite(); + @SidedProxy(clientSide = "jackcartersmith.orbsat.client.ClientProxy", serverSide = "jackcartersmith.orbsat.common.CommonProxy") + public static CommonProxy proxy; + + public static final SimpleNetworkWrapper packetHandler = NetworkRegistry.INSTANCE.newSimpleChannel(MODID); + + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + LogHelper.logger = event.getModLog(); + } + + @EventHandler + public void init(FMLInitializationEvent event) + { + // some example code + LogHelper.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) + { + + } + + public static CreativeTabs creativeTab = new CreativeTabs(MODID) + { + @Override + public ItemStack createIcon() + { + return ItemStack.EMPTY; + } + + + /*@Override + public ItemStack getIcon() + { + return new ItemStack(IEContent.blockMetalDecoration0, 1, 0); + }*/ + }; +} diff --git a/src/main/java/jackcartersmith/orbsat/client/ClientProxy.java b/src/main/java/jackcartersmith/orbsat/client/ClientProxy.java new file mode 100644 index 0000000..d085564 --- /dev/null +++ b/src/main/java/jackcartersmith/orbsat/client/ClientProxy.java @@ -0,0 +1,10 @@ +package jackcartersmith.orbsat.client; + +import jackcartersmith.orbsat.common.CommonProxy; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.relauncher.Side; + +@Mod.EventBusSubscriber(Side.CLIENT) +public class ClientProxy extends CommonProxy{ + +} diff --git a/src/main/java/jackcartersmith/orbsat/common/CommonProxy.java b/src/main/java/jackcartersmith/orbsat/common/CommonProxy.java new file mode 100644 index 0000000..876151b --- /dev/null +++ b/src/main/java/jackcartersmith/orbsat/common/CommonProxy.java @@ -0,0 +1,233 @@ +package jackcartersmith.orbsat.common; + +import java.util.UUID; + +import javax.annotation.Nonnull; + +import com.mojang.authlib.GameProfile; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.network.IGuiHandler; + +public class CommonProxy implements IGuiHandler { + public void preInit() + { + } + + public void preInitEnd() + { + } + + public void init() + { + } + + public void initEnd() + { + } + + public void postInit() + { + } + + public void postInitEnd() + { + } + + public void serverStarting() + { + } + + public void onWorldLoad() + { + } + + public static void openGuiForTile(@Nonnull EntityPlayer player, @Nonnull T tile) + { + player.openGui(OrbitalSatellite.instance, tile.getGuiID(), tile.getWorld(), tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ()); + } + + public static void openGuiForItem(@Nonnull EntityPlayer player, @Nonnull EntityEquipmentSlot slot) + { + ItemStack stack = player.getItemStackFromSlot(slot); + if(stack.isEmpty()||!(stack.getItem() instanceof IGuiItem)) + return; + IGuiItem gui = (IGuiItem)stack.getItem(); + player.openGui(ImmersiveEngineering.instance, 100*slot.ordinal()+gui.getGuiID(stack), player.world, (int)player.posX, (int)player.posY, (int)player.posZ); + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + if(ID >= Lib.GUIID_Base_Item) + { + EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID/100]; + ID %= 100;//Slot determined, get actual ID + ItemStack item = player.getItemStackFromSlot(slot); + if(!item.isEmpty()&&item.getItem() instanceof IGuiItem&&((IGuiItem)item.getItem()).getGuiID(item)==ID) + { + if(ID==Lib.GUIID_Revolver&&item.getItem() instanceof IEItemInterfaces.IBulletContainer) + return new ContainerRevolver(player.inventory, world, slot, item); + if(ID==Lib.GUIID_Toolbox&&item.getItem() instanceof ItemToolbox) + return new ContainerToolbox(player.inventory, world, slot, item); + } + } + else + { + TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); + if(te instanceof IGuiTile) + { + Object gui = null; + if(ID==Lib.GUIID_CokeOven&&te instanceof TileEntityCokeOven) + gui = new ContainerCokeOven(player.inventory, (TileEntityCokeOven)te); + if(ID==Lib.GUIID_AlloySmelter&&te instanceof TileEntityAlloySmelter) + gui = new ContainerAlloySmelter(player.inventory, (TileEntityAlloySmelter)te); + if(ID==Lib.GUIID_BlastFurnace&&te instanceof TileEntityBlastFurnace) + gui = new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace)te); + if(ID==Lib.GUIID_WoodenCrate&&te instanceof TileEntityWoodenCrate) + gui = new ContainerCrate(player.inventory, (TileEntityWoodenCrate)te); + if(ID==Lib.GUIID_Workbench&&te instanceof TileEntityModWorkbench) + gui = new ContainerModWorkbench(player.inventory, (TileEntityModWorkbench)te); + if(ID==Lib.GUIID_Sorter&&te instanceof TileEntitySorter) + gui = new ContainerSorter(player.inventory, (TileEntitySorter)te); + if(ID==Lib.GUIID_Squeezer&&te instanceof TileEntitySqueezer) + gui = new ContainerSqueezer(player.inventory, (TileEntitySqueezer)te); + if(ID==Lib.GUIID_Fermenter&&te instanceof TileEntityFermenter) + gui = new ContainerFermenter(player.inventory, (TileEntityFermenter)te); + if(ID==Lib.GUIID_Refinery&&te instanceof TileEntityRefinery) + gui = new ContainerRefinery(player.inventory, (TileEntityRefinery)te); + if(ID==Lib.GUIID_ArcFurnace&&te instanceof TileEntityArcFurnace) + gui = new ContainerArcFurnace(player.inventory, (TileEntityArcFurnace)te); + if(ID==Lib.GUIID_Assembler&&te instanceof TileEntityAssembler) + gui = new ContainerAssembler(player.inventory, (TileEntityAssembler)te); + if(ID==Lib.GUIID_AutoWorkbench&&te instanceof TileEntityAutoWorkbench) + gui = new ContainerAutoWorkbench(player.inventory, (TileEntityAutoWorkbench)te); + if(ID==Lib.GUIID_Mixer&&te instanceof TileEntityMixer) + gui = new ContainerMixer(player.inventory, (TileEntityMixer)te); + if(ID==Lib.GUIID_Turret&&te instanceof TileEntityTurret) + gui = new ContainerTurret(player.inventory, (TileEntityTurret)te); + if(ID==Lib.GUIID_FluidSorter&&te instanceof TileEntityFluidSorter) + gui = new ContainerFluidSorter(player.inventory, (TileEntityFluidSorter)te); + if(ID==Lib.GUIID_Belljar&&te instanceof TileEntityBelljar) + gui = new ContainerBelljar(player.inventory, (TileEntityBelljar)te); + if(ID==Lib.GUIID_ToolboxBlock&&te instanceof TileEntityToolbox) + gui = new ContainerToolboxBlock(player.inventory, (TileEntityToolbox)te); + if(gui!=null) + ((IGuiTile)te).onGuiOpened(player, false); + return gui; + } + } + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + return null; + } + + public void handleTileSound(SoundEvent soundEvent, TileEntity tile, boolean tileActive, float volume, float pitch) + { + } + + public void stopTileSound(String soundName, TileEntity tile) + { + } + + public void spawnBucketWheelFX(TileEntityBucketWheel tile, ItemStack stack) + { + } + + public void spawnSparkFX(World world, double x, double y, double z, double mx, double my, double mz) + { + } + + public void spawnRedstoneFX(World world, double x, double y, double z, double mx, double my, double mz, float size, float r, float g, float b) + { + } + + public void spawnFluidSplashFX(World world, FluidStack fs, double x, double y, double z, double mx, double my, double mz) + { + } + + public void spawnBubbleFX(World world, FluidStack fs, double x, double y, double z, double mx, double my, double mz) + { + } + + public void spawnFractalFX(World world, double x, double y, double z, Vec3d direction, double scale, int prefixColour, float[][] colour) + { + } + + public void draw3DBlockCauldron() + { + } + + public void drawSpecificFluidPipe(String configuration) + { + } + + public boolean armorHasCustomModel(ItemStack stack) + { + return false; + } + + public boolean drawConveyorInGui(String conveyor, EnumFacing facing) + { + return false; + } + + public void drawFluidPumpTop() + { + } + + public String[] splitStringOnWidth(String s, int w) + { + return new String[]{s}; + } + + public World getClientWorld() + { + return null; + } + + public EntityPlayer getClientPlayer() + { + return null; + } + + public String getNameFromUUID(String uuid) + { + return FMLCommonHandler.instance().getMinecraftServerInstance().getMinecraftSessionService().fillProfileProperties(new GameProfile(UUID.fromString(uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")), null), false).getName(); + } + + public void reInitGui() + { + } + + public void removeStateFromSmartModelCache(IExtendedBlockState state) + { + } + + public void removeStateFromConnectionModelCache(IExtendedBlockState state) + { + } + + public void clearConnectionModelCache() + { + } + + public void clearRenderCaches() + { + } +} diff --git a/src/main/java/jackcartersmith/orbsat/common/util/LogHelper.java b/src/main/java/jackcartersmith/orbsat/common/util/LogHelper.java new file mode 100644 index 0000000..43eeca5 --- /dev/null +++ b/src/main/java/jackcartersmith/orbsat/common/util/LogHelper.java @@ -0,0 +1,47 @@ +/* + * Based on the work of BluSunrize + */ + +package jackcartersmith.orbsat.common.util; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; + +public class LogHelper { + public static Logger logger; + + public static void log(Level logLevel, Object object) + { + logger.log(logLevel, String.valueOf(object)); + } + + public static void error(Object object) + { + log(Level.ERROR, object); + } + + public static void info(Object object) + { + log(Level.INFO, object); + } + + public static void warn(Object object) + { + log(Level.WARN, object); + } + + public static void error(String message, Object... params) + { + logger.log(Level.ERROR, message, params); + } + + public static void info(String message, Object... params) + { + logger.log(Level.INFO, message, params); + } + + public static void warn(String message, Object... params) + { + logger.log(Level.WARN, message, params); + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f480667..a4ae0f9 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,16 +1,14 @@ [ { - "modid": "examplemod", - "name": "Example Mod", - "description": "Example placeholder mod.", + "modid": "orbsat", + "name": "Orbital Satellite", + "description": "Multi-usage satellite with control center and launch bay.", "version": "${version}", "mcversion": "${mcversion}", "url": "", - "updateUrl": "", - "authorList": ["ExampleDude"], - "credits": "The Forge and FML guys, for making this example", + "authorList": ["JackCarterSmith"], + "credits": "Thanks for Forge community, Discord and BluSunrize!", "logoFile": "", - "screenshots": [], "dependencies": [] } ]