diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2a130e6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.gradle/ +.idea/ +*.iml +lib/* +!lib/README.txt +build/ +classes/ +run/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index b33f504e..b9fd86e2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,31 +1,49 @@ buildscript { repositories { + mavenCentral() + mavenLocal() jcenter() - maven { url = "http://files.minecraftforge.net/maven" } + maven { + url = "http://files.minecraftforge.net/maven" + } + maven { + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } } -apply plugin: 'net.minecraftforge.gradle.forge' -//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. +apply plugin: 'net.minecraftforge.gradle.forge' -//version = "1.0" -//group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = jarName +repositories { + maven { url = "http://maven.cil.li/" } + maven { + name = 'oss-sonatype-public' + url = 'https://oss.sonatype.org/content/groups/public/' + } + maven { url = "http://maven.ic2.player.to" } + maven { url = "http://repo.spongepowered.org/maven" } + maven { url = "http://cc.crzd.me/maven/" } +} + +dependencies { + compile "li.cil.oc:OpenComputers:MC1.12.1-1.7.1.52" + compile "net.industrial-craft:industrialcraft-2:2.8.93-ex112:api" + deobfCompile "dan200.computercraft:ComputerCraft:1.80pr1-build4" +} + +deobfMcMCP { failOnAtError = false } +deobfMcSRG { failOnAtError = false } + minecraft { - version = "1.10.2-12.18.2.2099" + 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. - // snapshot_YYYYMMDD snapshot are built nightly. - // stable_# stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not allways work. - // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "snapshot_20160518" - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. + mappings = 'snapshot_20180808' + useDepAts = true } sourceSets.main { @@ -34,10 +52,6 @@ sourceSets.main { resources.srcDirs "src/resources" } -//jar { -// exclude "ic2" -//} - processResources { // this will ensure that this task is redone when the versions change. diff --git a/gradle.properties b/gradle.properties index 37fc3413..00a61e8a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version = 1.13.2-mc1.10.2 -mcversion = [1.10.2,1.10.2] +version = 1.15.8-forge-release +mcversion = [1.12.2,1.12.2] group = gcewing.sg jarName = SGCraft diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..667288ad Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9397848f..5d1c4e02 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Sep 14 12:28:28 PDT 2015 +#Fri Sep 30 11:48:54 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-3.5-all.zip diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..d7855f79 --- /dev/null +++ b/readme.md @@ -0,0 +1,16 @@ +This repo contains several continuations of the original SGCraft mod developed by gcewing. + +Downloads are available here: https://ore.spongepowered.org/Dockter/SGCraft + +The following branches are active: +- 1.12.2 -> Active fixes for 1.12.2 +- api-7 -> All fixes from 1.12.2 branch plus Sponge permissions checks and event firings. +- feature/zpm -> Everything from api-7 + a custom zpm module implementation specifically designed for usage with IC2 and the Almura mod. + +feature/zpm branch, use this: +- vm options: -Xincgc -Xms1024M -Xmx2048M -Dfml.coreMods.load=org.spongepowered.mod.SpongeCoremod +- program arguments: --noCoreSearch + +Any questions please create an issue. + +Thanks. diff --git a/src/base/gcewing/sg/BaseAORenderingManager.java b/src/base/gcewing/sg/BaseAORenderingManager.java index 4d07344b..934e5a5e 100644 --- a/src/base/gcewing/sg/BaseAORenderingManager.java +++ b/src/base/gcewing/sg/BaseAORenderingManager.java @@ -13,9 +13,9 @@ import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -66,10 +66,10 @@ public void renderBlockDamage(IBlockState state, BlockPos pos, TextureAtlasSprit Trans3 t = Trans3.blockCenter; Block block = state.getBlock(); for (BlockRenderLayer layer : BlockRenderLayer.values()) - if (block.canRenderInLayer(layer)) + if (block.canRenderInLayer(state,layer)) rend.renderBlock(world, pos, state, target, layer, t); IBakedModel model = target.getBakedModel(); - VertexBuffer tess = Tessellator.getInstance().getBuffer(); + BufferBuilder tess = Tessellator.getInstance().getBuffer(); getBlockModelRenderer().renderModel(world, model, state, pos, tess, false); //TODO chould checkSides be false? } else @@ -77,7 +77,7 @@ public void renderBlockDamage(IBlockState state, BlockPos pos, TextureAtlasSprit } @Override - public boolean renderBlock(IBlockState state, BlockPos pos, IBlockAccess world, VertexBuffer tess) { + public boolean renderBlock(IBlockState state, BlockPos pos, IBlockAccess world, BufferBuilder tess) { ICustomRenderer rend = getCustomRenderer(world, pos, state); if (rend != null) return customRenderBlockToWorld(world, pos, state, tess, null, rend); @@ -85,7 +85,7 @@ public boolean renderBlock(IBlockState state, BlockPos pos, IBlockAccess world, return base.renderBlock(state, pos, world, tess); } - protected boolean customRenderBlockToWorld(IBlockAccess world, BlockPos pos, IBlockState state, VertexBuffer tess, + protected boolean customRenderBlockToWorld(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder tess, TextureAtlasSprite icon, ICustomRenderer rend) { BaseWorldRenderTarget target = new BaseWorldRenderTarget(world, pos, tess, icon); diff --git a/src/base/gcewing/sg/BaseBakedRenderTarget.java b/src/base/gcewing/sg/BaseBakedRenderTarget.java index 667a7da0..2b5e77d6 100644 --- a/src/base/gcewing/sg/BaseBakedRenderTarget.java +++ b/src/base/gcewing/sg/BaseBakedRenderTarget.java @@ -6,28 +6,24 @@ package gcewing.sg; -import java.util.*; -import java.nio.*; -//import javax.vecmath.Vector3f; +import net.minecraft.client.renderer.block.model.*; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import org.lwjgl.util.vector.Vector3f; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.block.*; -import net.minecraft.block.state.*; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.renderer.vertex.*; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.item.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static net.minecraft.client.renderer.vertex.DefaultVertexFormats.*; -import net.minecraftforge.client.model.*; - -import gcewing.sg.BaseModClient.ITexture; +//import javax.vecmath.Vector3f; public class BaseBakedRenderTarget extends BaseRenderTarget { @@ -53,7 +49,7 @@ public class BaseBakedRenderTarget extends BaseRenderTarget { //protected VertexFormat format = Attributes.DEFAULT_BAKED_FORMAT; //protected VertexFormat format = DefaultVertexFormats.ITEM; protected VertexFormat format = theFormat; - protected int bytesPerVertex = format.getNextOffset(); + protected int bytesPerVertex = format.getSize(); protected int intsPerVertex = bytesPerVertex / 4; protected ByteBuffer buf = ByteBuffer.allocate(bytesPerVertex * 4); diff --git a/src/base/gcewing/sg/BaseBlock.java b/src/base/gcewing/sg/BaseBlock.java index fb3039de..5b462585 100644 --- a/src/base/gcewing/sg/BaseBlock.java +++ b/src/base/gcewing/sg/BaseBlock.java @@ -13,13 +13,10 @@ import net.minecraft.block.properties.*; import net.minecraft.block.state.*; import net.minecraft.client.particle.*; -import net.minecraft.client.renderer.texture.*; import net.minecraft.entity.*; -import net.minecraft.entity.item.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.*; import net.minecraft.item.*; -import net.minecraft.nbt.*; import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.math.*; @@ -30,8 +27,6 @@ import static gcewing.sg.BaseMod.*; import static gcewing.sg.BaseModClient.*; -import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.BaseBlockUtils.*; public class BaseBlock extends BlockContainer implements BaseMod.IBlock @@ -347,8 +342,7 @@ public TileEntity createNewTileEntity(World world, int meta) { // ------------------------------------------------------------------- @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, - float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { IBlockState state = getOrientationHandler().onBlockPlaced(this, world, pos, side, hitX, hitY, hitZ, getStateFromMeta(meta), placer); @@ -395,9 +389,9 @@ public boolean addHitEffects(IBlockState blockState, World world, RayTraceResult int k = pos.getZ(); AxisAlignedBB boundingBox = blockState.getBoundingBox(world, pos); float f = 0.1F; - double d0 = i + RANDOM.nextDouble() * (boundingBox.maxX - boundingBox.minX - (f * 2.0F)) + f + boundingBox.minX; - double d1 = j + RANDOM.nextDouble() * (boundingBox.maxY - boundingBox.minY - (f * 2.0F)) + f + boundingBox.minY; - double d2 = k + RANDOM.nextDouble() * (boundingBox.maxZ - boundingBox.minZ - (f * 2.0F)) + f + boundingBox.minZ; + double d0 = i + RANDOM.nextDouble() * (boundingBox.maxX - boundingBox.minX - (f * 2F)) + f + boundingBox.minX; + double d1 = j + RANDOM.nextDouble() * (boundingBox.maxY - boundingBox.minY - (f * 2F)) + f + boundingBox.minY; + double d2 = k + RANDOM.nextDouble() * (boundingBox.maxZ - boundingBox.minZ - (f * 2F)) + f + boundingBox.minZ; switch (target.sideHit) { case DOWN: d1 = j + boundingBox.minY - f; break; case UP: d1 = j + boundingBox.maxY + f; break; @@ -493,8 +487,8 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, Block return super.getBoundingBox(state, world, pos); } - @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) { + // Update: This had an override above the method, may be needed. return getBoundingBox(state, world, pos); } @@ -513,15 +507,15 @@ protected AxisAlignedBB getLocalBounds(IBlockAccess world, BlockPos pos, IBlockS @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, - AxisAlignedBB clip, List result, Entity entity) + AxisAlignedBB clip, List result, Entity entity, boolean enableStats) { List list = getGlobalCollisionBoxes(world, pos, state, entity); if (list != null) for (AxisAlignedBB box : list) - if (clip.intersectsWith(box)) + if (clip.intersects(box)) result.add(box); else - super.addCollisionBoxToList(state, world, pos, clip, result, entity); + super.addCollisionBoxToList(state, world, pos, clip, result, entity, enableStats); } protected List getGlobalCollisionBoxes(IBlockAccess world, BlockPos pos, @@ -550,5 +544,4 @@ protected List getCollisionBoxes(IBlockAccess world, BlockPos pos } return null; } - } diff --git a/src/base/gcewing/sg/BaseBlockUtils.java b/src/base/gcewing/sg/BaseBlockUtils.java index 0f338548..3a9123d6 100644 --- a/src/base/gcewing/sg/BaseBlockUtils.java +++ b/src/base/gcewing/sg/BaseBlockUtils.java @@ -9,15 +9,12 @@ import java.io.*; import net.minecraft.block.*; -import net.minecraft.block.material.*; import net.minecraft.block.state.*; -import net.minecraft.client.renderer.texture.*; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.util.*; import static gcewing.sg.BaseUtils.*; @@ -89,7 +86,8 @@ public static void setWorldBlockState(World world, BlockPos pos, IBlockState sta // } public static void notifyWorldNeighborsOfStateChange(World world, BlockPos pos, Block block) { - world.notifyNeighborsOfStateChange(pos, block); + // Update: Updating observers may be wrong here. + world.notifyNeighborsOfStateChange(pos, block, true); } public static TileEntity getWorldTileEntity(IBlockAccess world, BlockPos pos) { @@ -105,7 +103,7 @@ public static BlockPos getTileEntityPos(TileEntity te) { } public static boolean blockCanRenderInLayer(Block block, BlockRenderLayer layer) { - return block.canRenderInLayer(layer); + return block.canRenderInLayer((IBlockState) block.getBlockState(),layer); } public static ItemStack blockStackWithState(IBlockState state, int size) { diff --git a/src/base/gcewing/sg/BaseConfiguration.java b/src/base/gcewing/sg/BaseConfiguration.java index 016e7d34..67c3e280 100644 --- a/src/base/gcewing/sg/BaseConfiguration.java +++ b/src/base/gcewing/sg/BaseConfiguration.java @@ -7,10 +7,8 @@ package gcewing.sg; import java.io.*; -import java.util.*; -import net.minecraftforge.common.*; + import net.minecraftforge.common.config.*; -import net.minecraftforge.fml.common.registry.*; public class BaseConfiguration extends Configuration { diff --git a/src/base/gcewing/sg/BaseContainer.java b/src/base/gcewing/sg/BaseContainer.java index 9e53554f..f3fa8bcc 100644 --- a/src/base/gcewing/sg/BaseContainer.java +++ b/src/base/gcewing/sg/BaseContainer.java @@ -88,19 +88,23 @@ public void detectAndSendChanges() { // mergeItemStack as appropriate. @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { - ItemStack result = null; + ItemStack result = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); ItemStack stack = slot.getStack(); if (slot != null && slot.getHasStack()) { SlotRange destRange = transferSlotRange(index, stack); if (destRange != null) { - result = stack.copy(); - if (!mergeItemStackIntoRange(stack, destRange)) - return null; - if (stack.stackSize == 0) - slot.putStack(null); + if (index >= destRange.numSlots) { + result = stack.copy(); + if (!mergeItemStackIntoRange(stack, destRange)) + return ItemStack.EMPTY; + if (stack.getCount() == 0) + slot.putStack(ItemStack.EMPTY); + else + slot.onSlotChanged(); + } else - slot.onSlotChanged(); + player.inventory.addItemStackToInventory(stack); } } return result; diff --git a/src/base/gcewing/sg/BaseDataChannel.java b/src/base/gcewing/sg/BaseDataChannel.java index 8f3cb4b9..a2248d43 100644 --- a/src/base/gcewing/sg/BaseDataChannel.java +++ b/src/base/gcewing/sg/BaseDataChannel.java @@ -16,14 +16,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.player.*; -import net.minecraft.nbt.*; import net.minecraft.network.*; -import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; import net.minecraftforge.fml.common.network.*; import net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget; -import net.minecraftforge.fml.common.registry.*; import net.minecraftforge.fml.relauncher.*; public class BaseDataChannel { @@ -92,7 +89,7 @@ public void onServerContainerMessage(EntityPlayer player, ChannelInput data) { @SideOnly(Side.CLIENT) @ClientMessageHandler(".container.") public void onClientContainerMessage(ChannelInput data) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = Minecraft.getMinecraft().player; String message = data.readUTF(); doClientDispatch(player.openContainer, message, data); } @@ -418,8 +415,8 @@ protected void handleProxyPacket(ChannelHandlerContext ctx, FMLProxyPacket msg) ChannelInput data = new ChannelInputStream(msg.payload()); if (ctx.channel() == channel.pipes.get(Side.SERVER)) { INetHandler net = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); - EntityPlayer player = ((NetHandlerPlayServer)net).playerEntity; - channel.onReceiveFromClient(player, data); + EntityPlayer player = ((NetHandlerPlayServer)net).player; + player.getServer().addScheduledTask(() -> channel.onReceiveFromClient(player, data)); } else channel.onReceiveFromServer(data); diff --git a/src/base/gcewing/sg/BaseEntityRenderer.java b/src/base/gcewing/sg/BaseEntityRenderer.java index 2f8b0275..99a2a363 100644 --- a/src/base/gcewing/sg/BaseEntityRenderer.java +++ b/src/base/gcewing/sg/BaseEntityRenderer.java @@ -7,7 +7,6 @@ package gcewing.sg; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.entity.*; import net.minecraft.entity.*; import net.minecraft.util.ResourceLocation; diff --git a/src/base/gcewing/sg/BaseGui.java b/src/base/gcewing/sg/BaseGui.java index a663bbeb..35de3820 100644 --- a/src/base/gcewing/sg/BaseGui.java +++ b/src/base/gcewing/sg/BaseGui.java @@ -9,21 +9,17 @@ import java.io.IOException; import java.lang.reflect.*; import java.util.*; -import org.lwjgl.input.*; + import org.lwjgl.opengl.*; import static org.lwjgl.opengl.GL11.*; import net.minecraft.client.*; -import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.*; import net.minecraft.client.renderer.*; -import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.util.*; import net.minecraft.util.text.translation.I18n; -import net.minecraftforge.client.*; - import static gcewing.sg.BaseUtils.*; //------------------------------------------------------------------------------------------------ @@ -38,7 +34,7 @@ public static class Screen extends GuiContainer implements BaseMod.ISetMod { protected Root root; protected String title; protected Tessellator tess; - protected VertexBuffer vb; + protected BufferBuilder vb; protected IWidget mouseWidget; protected GState gstate; @@ -70,18 +66,19 @@ public void initGui() { root.layout(); } -// @Override -// public void drawScreen(int par1, int par2, float par3) { -// resetColor(); -// textColor = defaultTextColor; -// textShadow = false; -// super.drawScreen(par1, par2, par3); -// } + /** + * Draws the screen and all the components in it. + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + this.renderHoveredToolTip(mouseX, mouseY); + } @Override protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { GL11.glPushMatrix(); - GL11.glTranslatef(guiLeft, guiTop, 0.0F); + GL11.glTranslatef(guiLeft, guiTop, 0F); drawBackgroundLayer(); if (title != null) drawTitle(title); @@ -104,7 +101,7 @@ protected void drawForegroundLayer() { public void close() { dispatchClosure(root); onClose(); - mc.thePlayer.closeScreen(); + mc.player.closeScreen(); } protected void onClose() { @@ -258,15 +255,15 @@ public void setTextShadow(boolean state) { } public void drawString(String s, int x, int y) { - fontRendererObj.drawString(s, x, y, gstate.textColor, gstate.textShadow); + fontRenderer.drawString(s, x, y, gstate.textColor, gstate.textShadow); } public void drawCenteredString(String s, int x, int y) { - fontRendererObj.drawString(s, x - fontRendererObj.getStringWidth(s) / 2, y, gstate.textColor, gstate.textShadow); + fontRenderer.drawString(s, x - fontRenderer.getStringWidth(s) / 2, y, gstate.textColor, gstate.textShadow); } public void drawRightAlignedString(String s, int x, int y) { - fontRendererObj.drawString(s, x - fontRendererObj.getStringWidth(s), y, gstate.textColor, gstate.textShadow); + fontRenderer.drawString(s, x - fontRenderer.getStringWidth(s), y, gstate.textColor, gstate.textShadow); } public void drawTitle(String s) { @@ -331,9 +328,9 @@ protected void mouseReleased(int x, int y, int button) { } void closeOldFocus(IWidget clickedWidget) { - if (!isFocused(clickedWidget)) { + if (!BaseGui.isFocused(clickedWidget)) { IWidgetContainer parent = clickedWidget.parent(); - while (!isFocused(parent)) + while (!BaseGui.isFocused(parent)) parent = parent.parent(); dispatchClosure(parent.getFocus()); } @@ -369,7 +366,7 @@ public void focusOn(IWidget newFocus) { if (parent != null) { IWidget oldFocus = parent.getFocus(); //System.out.printf("BaseGui.Screen.focusOn: Old parent focus = %s\n", name(oldFocus)); - if (isFocused(parent)) { + if (BaseGui.isFocused(parent)) { //System.out.printf("BaseGui.Screen.focusOn: Parent is focused\n"); if (oldFocus != newFocus) { tellFocusChanged(oldFocus, false); @@ -506,7 +503,7 @@ public boolean dispatchKeyPress(char c, int key) { } public static int stringWidth(String s) { - return Minecraft.getMinecraft().fontRendererObj.getStringWidth(s); + return Minecraft.getMinecraft().fontRenderer.getStringWidth(s); } public void addPopup(int x, int y, IWidget widget) { diff --git a/src/base/gcewing/sg/BaseMod.java b/src/base/gcewing/sg/BaseMod.java index efbbd0ea..603de9f9 100644 --- a/src/base/gcewing/sg/BaseMod.java +++ b/src/base/gcewing/sg/BaseMod.java @@ -6,54 +6,67 @@ package gcewing.sg; -import java.io.*; -import java.lang.annotation.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; -import java.util.jar.*; - import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.Gson; - -import net.minecraft.block.*; +import gcewing.sg.BaseModClient.IModel; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.*; -import net.minecraft.entity.*; -import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; -import net.minecraft.item.*; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.Packet; -import net.minecraft.server.management.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; -import net.minecraft.world.storage.loot.*; - -import net.minecraftforge.common.*; -import net.minecraftforge.common.config.*; -import net.minecraftforge.client.*; -import net.minecraftforge.oredict.*; - +import net.minecraft.server.management.PlayerChunkMap; +import net.minecraft.server.management.PlayerList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.world.storage.loot.LootTableManager; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.LootTableLoadEvent; - -import net.minecraftforge.fml.common.*; -import net.minecraftforge.fml.common.event.*; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.Mod; +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.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.network.*; -import net.minecraftforge.fml.common.registry.*; -import net.minecraftforge.fml.common.registry.VillagerRegistry.*; -import net.minecraftforge.fml.relauncher.*; - -import gcewing.sg.BaseModClient.IModel; +import net.minecraftforge.fml.common.network.IGuiHandler; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.registry.EntityEntry; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.OreDictionary; + +import java.io.File; +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class BaseMod> extends BaseSubsystem implements IGuiHandler { - public boolean debugLoot = true; + public boolean debugLoot = false; protected Map modelCache = new HashMap(); @@ -123,8 +136,8 @@ public ModelSpec(String model, Vector3 origin, String... textures) { public List subsystems = new ArrayList(); public boolean debugGui = false; - public boolean debugBlockRegistration = false; - public boolean debugCreativeTabs = false; + public boolean debugBlockRegistration = true; + public boolean debugCreativeTabs = true; public String resourcePath(String fileName) { return resourceDir + fileName; @@ -157,6 +170,7 @@ public static boolean isModLoaded(String modid) { return Loader.isModLoaded(modid); } + @Override public void preInit(FMLPreInitializationEvent e) { serverSide = e.getSide().isServer(); clientSide = e.getSide().isClient(); @@ -184,28 +198,41 @@ public void preInit(FMLPreInitializationEvent e) { if (client != null) client.preInit(e); } - + + @Override public void init(FMLInitializationEvent e) { MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); - if (client != null) + if (client != null) { client.init(e); - for (BaseSubsystem sub : subsystems) - if (sub != this) + } + + for (BaseSubsystem sub : subsystems) { + if (sub != this) { sub.init(e); + } + sub.registerRecipes(); + } } - + + @Override public void postInit(FMLPostInitializationEvent e) { for (BaseSubsystem sub : subsystems) { - if (sub != this) + if (sub != this) { sub.postInit(e); - sub.registerRecipes(); + } + sub.registerOther(); } - if (client != null) + + if (client != null) { client.postInit(e); - if (proxy == null) + } + + if (proxy == null) { proxy = this; + } + NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy); saveConfig(); } @@ -344,13 +371,11 @@ public ITEM newItem(String name, Class cls) { public ITEM addItem(ITEM item, String name) { String qualName = assetKey + ":" + name; - item.setUnlocalizedName(qualName); - GameRegistry.registerItem(item, name); - if (debugBlockRegistration) - System.out.printf("BaseMod.addItem: Registered %s as %s\n", item, name); + item.setTranslationKey(qualName); + item.setRegistryName(assetKey, name); + ForgeRegistries.ITEMS.register(item); + if (creativeTab != null) { - if (debugCreativeTabs) - System.out.printf("BaseMod.addItem: Setting creativeTab of %s to %s\n", name, creativeTab); item.setCreativeTab(creativeTab); } registeredItems.add(item); @@ -385,17 +410,26 @@ public BLOCK addBlock(BLOCK block, String name) { public BLOCK addBlock(BLOCK block, String name, Class itemClass) { String qualName = assetKey + ":" + name; - block.setUnlocalizedName(qualName); -// block.setBlockTextureName(qualName); - //System.out.printf("BaseMod.addBlock: name '%s' qualName '%s' %s\n", name, qualName, block); - GameRegistry.registerBlock(block, itemClass, name); + block.setTranslationKey(qualName); + block.setRegistryName(assetKey, name); + ForgeRegistries.BLOCKS.register(block); + + final Item item = new ItemBlock(block).setRegistryName(block.getRegistryName()); + + if (block instanceof SGRingBlock) { + final Item ringItem = new SGRingItem(block).setRegistryName(block.getRegistryName()); + ForgeRegistries.ITEMS.register(ringItem); + } else { + ForgeRegistries.ITEMS.register(item); + } + if (creativeTab != null) { - //System.out.printf("BaseMod.addBlock: Setting creativeTab to %s\n", creativeTab); block.setCreativeTab(creativeTab); } if (block instanceof BaseBlock) ((BaseBlock)block).mod = this; registeredBlocks.add(block); + return block; } @@ -430,28 +464,29 @@ public static boolean stackMatchesOre(ItemStack stack, String name) { //--------------- Recipe construction ---------------------------------------------------------- - public void newRecipe(Item product, int qty, Object... params) { - newRecipe(new ItemStack(product, qty), params); + public void newRecipe(String name, Item product, int qty, Object... params) { + newRecipe(name, new ItemStack(product, qty), params); } - public void newRecipe(Block product, int qty, Object... params) { - newRecipe(new ItemStack(product, qty), params); + public void newRecipe(String name, Block product, int qty, Object... params) { + newRecipe(name, new ItemStack(product, qty), params); } - public void newRecipe(ItemStack product, Object... params) { - GameRegistry.addRecipe(new ShapedOreRecipe(product, params)); + public void newRecipe(String name, ItemStack product, Object... params) { + // Todo: Recipe needs group registration + GameRegistry.addShapedRecipe(new ResourceLocation("sgcraft", name),new ResourceLocation("sgcraft","Stargate"), product, params); } - public void newShapelessRecipe(Block product, int qty, Object... params) { - newShapelessRecipe(new ItemStack(product, qty), params); - } + //public void newShapelessRecipe(Block product, int qty, Ingredient... params) { + // newShapelessRecipe(new ItemStack(product, qty), params); + //} - public void newShapelessRecipe(Item product, int qty, Object... params) { - newShapelessRecipe(new ItemStack(product, qty), params); + public void newShapelessRecipe(String name, Item product, int qty, Ingredient... params) { + newShapelessRecipe(name, new ItemStack(product, qty), params); } - public void newShapelessRecipe(ItemStack product, Object... params) { - GameRegistry.addRecipe(new ShapelessOreRecipe(product, params)); + public void newShapelessRecipe(String name, ItemStack product, Ingredient... params) { + GameRegistry.addShapelessRecipe(new ResourceLocation("sgcraft",name), new ResourceLocation("sgcraft","Stargate"), product, params); } public void newSmeltingRecipe(Item product, int qty, Item input) { @@ -461,7 +496,7 @@ public void newSmeltingRecipe(Item product, int qty, Item input) { public void newSmeltingRecipe(Item product, int qty, Item input, int xp) { GameRegistry.addSmelting(input, new ItemStack(product, qty), xp); } - + public void newSmeltingRecipe(Item product, int qty, Block input) { newSmeltingRecipe(product, qty, input, 0); } @@ -469,7 +504,7 @@ public void newSmeltingRecipe(Item product, int qty, Block input) { public void newSmeltingRecipe(Item product, int qty, Block input, int xp) { GameRegistry.addSmelting(input, new ItemStack(product, qty), xp); } - + //--------------- Dungeon loot ---------------------------------------------------------- // public void addRandomChestItem(ItemStack stack, int minQty, int maxQty, int weight, String... category) { @@ -494,12 +529,13 @@ public void addEntity(Class cls, String name, Enum id, addEntity(cls, name, id.ordinal(), updateFrequency, sendVelocityUpdates); } - public void addEntity(Class cls, String name, int id, - int updateFrequency, boolean sendVelocityUpdates) - { + public void addEntity(Class cls, String name, int id, int updateFrequency, boolean sendVelocityUpdates) { System.out.printf("%s: BaseMod.addEntity: %s, \"%s\", %s\n", getClass().getSimpleName(), cls.getSimpleName(), name, id); - EntityRegistry.registerModEntity(cls, name, id, /*base*/this, 256, updateFrequency, sendVelocityUpdates); + EntityEntry toRegister = new EntityEntry(cls, name); + toRegister.setRegistryName(name); + //EntityRegistry.registerModEntity(cls, name, id, /*base*/this, 256, updateFrequency, sendVelocityUpdates); + ForgeRegistries.ENTITIES.register(toRegister); } //--------------- Villager registration ------------------------------------------------- @@ -528,7 +564,7 @@ public SoundEvent newSound(String name) { ResourceLocation loc = resourceLocation(name); SoundEvent result = new SoundEvent(loc); result.setRegistryName(loc); - GameData.getSoundEventRegistry().register(result); + ForgeRegistries.SOUND_EVENTS.register(result); return result; } catch (Exception e) { @@ -563,44 +599,7 @@ public IModel getModel(String name) { } return model; } - -// @SideOnly(Side.CLIENT) -// public IIcon getIcon(IIconRegister reg, String name) { -// return reg.registerIcon(assetKey + ":" + name); -// } -// public Set listResources(String subdir) { -// try { -// Setresult = new HashSet(); -// if (resourceURL != null) { -// String protocol = resourceURL.getProtocol(); -// if (protocol.equals("jar")) { -// String resPath = resourceURL.getPath(); -// int pling = resPath.lastIndexOf("!"); -// URL jarURL = new URL(resPath.substring(0, pling)); -// String resDirInJar = resPath.substring(pling + 2); -// String prefix = resDirInJar + subdir + "/"; -// //System.out.printf("BaseMod.listResources: looking for names starting with %s\n", prefix); -// JarFile jar = new JarFile(new File(jarURL.toURI())); -// Enumeration entries = jar.entries(); -// while (entries.hasMoreElements()) { -// String name = entries.nextElement().getName(); -// if (name.startsWith(prefix) && !name.endsWith("/") && !name.contains("/.")) { -// //System.out.printf("BaseMod.listResources: name = %s\n", name); -// result.add(name.substring(prefix.length())); -// } -// } -// } -// else -// throw new RuntimeException("Resource URL protocol " + protocol + " not supported"); -// } -// return result; -// } -// catch (Exception e) { -// throw new RuntimeException(e); -// } -// } - //------------------------- Network -------------------------------------------------- public static void sendTileEntityUpdate(TileEntity te) { @@ -613,7 +612,7 @@ public static void sendTileEntityUpdate(TileEntity te) { WorldServer world = (WorldServer)te.getWorld(); PlayerList cm = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); PlayerChunkMap pm = world.getPlayerChunkMap(); - for (EntityPlayerMP player : cm.getPlayerList()) + for (EntityPlayerMP player : cm.getPlayers()) if (pm.isPlayerWatchingChunk(player, x, z)) { //System.out.printf("BaseMod.sendTileEntityUpdate: to %s\n", player); player.connection.sendPacket(packet); @@ -798,8 +797,8 @@ public void onLootTableLoad(LootTableLoadEvent event) { //if (debugLoot) // System.out.printf("BaseMod.onLootTableLoad\n"); ResourceLocation locn = event.getName(); - if (locn.getResourceDomain().equals("minecraft")) { - String path = String.format("/assets/%s/loot_tables/%s.json", assetKey, locn.getResourcePath()); + if (locn.getNamespace().equals("minecraft")) { + String path = String.format("/assets/%s/loot_tables/%s.json", assetKey, locn.getPath()); //if (debugLoot) // System.out.printf("BaseMod.onLootTableLoad: Looking for %s\n", path); URL url = getClass().getResource(path); @@ -817,7 +816,7 @@ public void onLootTableLoad(LootTableLoadEvent event) { // System.out.printf("BaseMod.onLootTableLoad: data = %s\n", data); Gson gson = (Gson)BaseReflectionUtils.getField(null, lootGsonField); LootTable table = event.getTable(); - LootTable newTable = ForgeHooks.loadLootTable(gson, locn, data, true); + LootTable newTable = ForgeHooks.loadLootTable(gson, locn, data, true, null); List newPools = (List)BaseReflectionUtils.getField(newTable, lootPoolsField); int i = 0; for (LootPool pool : newPools) { diff --git a/src/base/gcewing/sg/BaseModClient.java b/src/base/gcewing/sg/BaseModClient.java index 30ad4dd9..86dc6f74 100644 --- a/src/base/gcewing/sg/BaseModClient.java +++ b/src/base/gcewing/sg/BaseModClient.java @@ -6,48 +6,43 @@ package gcewing.sg; -import java.net.*; -import java.util.*; -import java.lang.reflect.*; -import java.lang.Thread; - -import net.minecraft.block.*; +import gcewing.sg.BaseMod.ITextureConsumer; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.*; -import net.minecraft.client.gui.*; -import net.minecraft.client.audio.*; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.entity.*; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.renderer.tileentity.*; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.creativetab.*; -import net.minecraft.entity.*; -import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; -import net.minecraft.item.*; -import net.minecraft.network.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; - -import net.minecraftforge.common.*; -import net.minecraftforge.client.*; -import net.minecraftforge.client.event.*; -import net.minecraftforge.client.model.*; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.common.FMLCommonHandler; +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.IGuiHandler; -import net.minecraftforge.fml.client.*; -import net.minecraftforge.fml.client.registry.*; -import net.minecraftforge.fml.common.*; -import net.minecraftforge.fml.common.event.*; -import net.minecraftforge.fml.common.eventhandler.*; -import net.minecraftforge.fml.common.network.*; -import net.minecraftforge.fml.common.registry.*; +import java.lang.reflect.Constructor; +import java.util.HashMap; +import java.util.List; +import java.util.Map; //import gcewing.sg.BaseMod.IBlock; -import gcewing.sg.BaseMod.*; public class BaseModClient> implements IGuiHandler { diff --git a/src/base/gcewing/sg/BaseModel.java b/src/base/gcewing/sg/BaseModel.java index 60921121..99817e2d 100644 --- a/src/base/gcewing/sg/BaseModel.java +++ b/src/base/gcewing/sg/BaseModel.java @@ -6,13 +6,16 @@ package gcewing.sg; -import java.io.*; -import java.util.*; -import com.google.gson.*; -import net.minecraft.client.Minecraft; +import com.google.gson.Gson; +import gcewing.sg.BaseModClient.IModel; +import gcewing.sg.BaseModClient.IRenderTarget; +import gcewing.sg.BaseModClient.ITexture; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; -import gcewing.sg.BaseModClient.*; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; public class BaseModel implements IModel { @@ -32,7 +35,7 @@ public static class Face { public static BaseModel fromResource(ResourceLocation location) { // Can't use resource manager because this needs to work on the server - String path = String.format("/assets/%s/%s", location.getResourceDomain(), location.getResourcePath()); + String path = String.format("/assets/%s/%s", location.getNamespace(), location.getPath()); InputStream in = BaseModel.class.getResourceAsStream(path); BaseModel model = gson.fromJson(new InputStreamReader(in), BaseModel.class); if (in == null) @@ -56,11 +59,12 @@ void prepare() { public void addBoxesToList(Trans3 t, List list) { if (boxes != null && boxes.length > 0) { - for (int i = 0; i < boxes.length; i++) - addBoxToList(boxes[i], t, list); - } - else + for (double[] box : boxes) { + addBoxToList(box, t, list); + } + } else { addBoxToList(bounds, t, list); + } } protected void addBoxToList(double[] b, Trans3 t, List list) { diff --git a/src/base/gcewing/sg/BaseRenderTarget.java b/src/base/gcewing/sg/BaseRenderTarget.java index 6709e06c..3e8928bc 100644 --- a/src/base/gcewing/sg/BaseRenderTarget.java +++ b/src/base/gcewing/sg/BaseRenderTarget.java @@ -6,21 +6,8 @@ package gcewing.sg; -import java.util.*; -import java.nio.*; -import static java.lang.Math.*; - -import net.minecraft.block.*; -import net.minecraft.block.state.*; -import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.item.*; import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; - -import net.minecraftforge.client.model.*; import gcewing.sg.BaseModClient.ITexture; diff --git a/src/base/gcewing/sg/BaseRenderingManager.java b/src/base/gcewing/sg/BaseRenderingManager.java index a67a3382..00af60d0 100644 --- a/src/base/gcewing/sg/BaseRenderingManager.java +++ b/src/base/gcewing/sg/BaseRenderingManager.java @@ -6,36 +6,47 @@ package gcewing.sg; -import java.net.*; -import java.util.*; - -import static org.lwjgl.opengl.GL11.*; import com.google.common.collect.ImmutableList; - -import net.minecraft.block.*; +import gcewing.sg.BaseMod.IBlock; +import gcewing.sg.BaseMod.IItem; +import gcewing.sg.BaseMod.ITextureConsumer; +import gcewing.sg.BaseMod.ModelSpec; +import gcewing.sg.BaseModClient.*; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.*; -import net.minecraft.client.renderer.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockModelShapes; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.block.statemap.DefaultStateMapper; -import net.minecraft.client.renderer.block.statemap.IStateMapper; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.entity.*; -import net.minecraft.item.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; - -import net.minecraftforge.client.event.*; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.*; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import gcewing.sg.BaseMod.*; -import gcewing.sg.BaseModClient.*; -import static gcewing.sg.BaseReflectionUtils.setField; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.lwjgl.opengl.GL11.GL_SMOOTH; public class BaseRenderingManager> implements IRenderingManager { @@ -242,13 +253,13 @@ protected void registerDefaultModelLocations() { registerModelLocationForItem(item, itemDisp); } else - registerInventoryLocationForItem(item, block.getUnlocalizedName()); + registerInventoryLocationForItem(item, block.getTranslationKey()); } for (Item item : client.base.registeredItems) { if (itemNeedsCustomRendering(item)) registerModelLocationForItem(item, itemDisp); else - registerInventoryLocationForItem(item, item.getUnlocalizedName()); + registerInventoryLocationForItem(item, item.getTranslationKey()); } } @@ -289,7 +300,7 @@ protected void registerModelLocationForSubtypes(Item item, ModelResourceLocation int numVariants = getNumItemSubtypes(item); if (debugModelRegistration) System.out.printf("BaseModClient: Registering model location %s for %d subtypes of %s\n", - location, numVariants, item.getUnlocalizedName()); + location, numVariants, item.getTranslationKey()); for (int i = 0; i < numVariants; i++) ModelLoader.setCustomModelResourceLocation(item, i, location); } @@ -476,7 +487,7 @@ public boolean renderAlternateBlock(IBlockAccess world, BlockPos pos, IBlockStat Block block = state.getBlock(); if (!block.hasTileEntity(state)) { try { - VertexBuffer tess = ((BaseWorldRenderTarget)target).getWorldRenderer(); + BufferBuilder tess = ((BaseWorldRenderTarget)target).getWorldRenderer(); return blockRendererDispatcher.renderBlock(state, pos, world, tess); } catch (Exception e) { diff --git a/src/base/gcewing/sg/BaseSubsystem.java b/src/base/gcewing/sg/BaseSubsystem.java index 0e78e163..90dd5d37 100644 --- a/src/base/gcewing/sg/BaseSubsystem.java +++ b/src/base/gcewing/sg/BaseSubsystem.java @@ -7,6 +7,7 @@ package gcewing.sg; import net.minecraft.item.*; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.event.*; import net.minecraftforge.fml.common.registry.*; @@ -58,7 +59,7 @@ public Item searchForItem(String... names) { public static Item findItem(String name) { String[] parts = BaseStringUtils.split(":", name); - return GameRegistry.findItem(parts[0], parts[1]); + return ForgeRegistries.ITEMS.getValue(new ResourceLocation(parts[0], parts[1])); } } diff --git a/src/base/gcewing/sg/BaseTEChunkManager.java b/src/base/gcewing/sg/BaseTEChunkManager.java index dad1955f..8193bb24 100644 --- a/src/base/gcewing/sg/BaseTEChunkManager.java +++ b/src/base/gcewing/sg/BaseTEChunkManager.java @@ -11,15 +11,11 @@ import net.minecraft.nbt.*; import net.minecraft.tileentity.*; import net.minecraft.world.*; -import net.minecraft.world.chunk.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraftforge.common.*; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Type; -import net.minecraftforge.event.*; -import net.minecraftforge.event.world.*; public class BaseTEChunkManager implements ForgeChunkManager.LoadingCallback { @@ -130,7 +126,7 @@ public void dumpChunkLoadingState(BaseTileEntity te, String label) { System.out.printf("Loaded chunks:"); for (Object item : te.chunkTicket.getChunkList()) { ChunkPos coords = (ChunkPos)item; - System.out.printf(" (%d,%d)", coords.chunkXPos, coords.chunkZPos); + System.out.printf(" (%d,%d)", coords.x, coords.z); } System.out.printf("\n"); } diff --git a/src/base/gcewing/sg/BaseTileEntity.java b/src/base/gcewing/sg/BaseTileEntity.java index 3a339a8f..2237f944 100644 --- a/src/base/gcewing/sg/BaseTileEntity.java +++ b/src/base/gcewing/sg/BaseTileEntity.java @@ -6,27 +6,25 @@ package gcewing.sg; -import java.util.List; //*** -import java.lang.reflect.*; //*** - -import net.minecraft.block.*; +import gcewing.sg.BaseMod.IBlock; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; -import net.minecraft.item.*; -import net.minecraft.network.*; -import net.minecraft.nbt.*; -import net.minecraft.network.play.server.*; -import net.minecraft.server.management.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.text.*; -import net.minecraft.world.*; - -import net.minecraftforge.common.*; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.server.management.PlayerChunkMap; +import net.minecraft.server.management.PlayerChunkMapEntry; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; -import gcewing.sg.BaseMod.IBlock; +import java.lang.reflect.Field; + import static gcewing.sg.BaseReflectionUtils.*; public class BaseTileEntity extends TileEntity @@ -62,10 +60,10 @@ public Trans3 localToGlobalTransformation() { // } public Trans3 localToGlobalTransformation(Vector3 origin) { - IBlockState state = worldObj.getBlockState(pos); + IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (block instanceof IBlock) - return ((IBlock)block).localToGlobalTransformation(worldObj, pos, state, origin); + return ((IBlock)block).localToGlobalTransformation(world, pos, state, origin); else { System.out.printf("BaseTileEntity.localToGlobalTransformation: Wrong block type at %s\n", pos); return new Trans3(origin); @@ -101,7 +99,7 @@ public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { NBTTagCompound nbt = pkt.getNbtCompound(); readFromNBT(nbt); if (nbt.getBoolean("updateChunk")) - worldObj.markBlockRangeForRenderUpdate(pos, pos); + world.markBlockRangeForRenderUpdate(pos, pos); } boolean syncWithClient() { @@ -110,7 +108,7 @@ boolean syncWithClient() { public void markBlockForUpdate() { updateChunk = true; - BaseBlockUtils.markBlockForUpdate(worldObj, pos); + BaseBlockUtils.markBlockForUpdate(world, pos); } protected static Field changedSectionFilter = getFieldDef( @@ -118,11 +116,11 @@ public void markBlockForUpdate() { "changedSectionFilter", "field_187288_h"); public void markForUpdate() { - if (!worldObj.isRemote) { + if (!world.isRemote) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); - PlayerChunkMap pm = ((WorldServer)worldObj).getPlayerChunkMap(); + PlayerChunkMap pm = ((WorldServer)world).getPlayerChunkMap(); PlayerChunkMapEntry entry = pm.getEntry(x >> 4, z >> 4); if (entry != null) { int oldFlags = getIntField(entry, changedSectionFilter); @@ -133,7 +131,15 @@ public void markForUpdate() { } public void playSoundEffect(SoundEvent name, float volume, float pitch) { - worldObj.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, name, SoundCategory.BLOCKS, volume, pitch); + playSoundEffect(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, name, volume, pitch); + } + + public void playSoundEffect(World world, double x, double y, double z, SoundEvent name, float volume, float pitch) { + if (world.isRemote) { + world.playSound(x, y, z, name, SoundCategory.BLOCKS, volume, pitch, false); + } else { + world.playSound(null, x, y, z, name, SoundCategory.BLOCKS, volume, pitch); + } } @Override diff --git a/src/base/gcewing/sg/BaseTileEntityRenderer.java b/src/base/gcewing/sg/BaseTileEntityRenderer.java index cf9d9cc0..cf0f9932 100644 --- a/src/base/gcewing/sg/BaseTileEntityRenderer.java +++ b/src/base/gcewing/sg/BaseTileEntityRenderer.java @@ -8,7 +8,6 @@ import net.minecraft.client.renderer.tileentity.*; import net.minecraft.tileentity.*; -import net.minecraft.util.*; import gcewing.sg. BaseModClient.IRenderTarget; @@ -16,11 +15,12 @@ public abstract class BaseTileEntityRenderer extends TileEntitySpecialRenderer { protected static BaseGLRenderTarget target = new BaseGLRenderTarget(); - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float dt, int destroyStage) { + @Override + public void render(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { BaseTileEntity bte = (BaseTileEntity)te; Trans3 t = bte.localToGlobalTransformation(Vector3.blockCenter(x, y, z)); target.start(true); - render(bte, dt, destroyStage, t, target); + render(bte, partialTicks, destroyStage, t, target); target.finish(); } diff --git a/src/base/gcewing/sg/BaseTileInventory.java b/src/base/gcewing/sg/BaseTileInventory.java index aedb2dca..6d5486c4 100644 --- a/src/base/gcewing/sg/BaseTileInventory.java +++ b/src/base/gcewing/sg/BaseTileInventory.java @@ -10,7 +10,6 @@ import net.minecraft.inventory.*; import net.minecraft.item.*; import net.minecraft.nbt.*; -import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.text.*; @@ -30,7 +29,7 @@ public void readInventoryFromNBT(NBTTagCompound nbt) { for (int i = 0; i < n; i++) { NBTTagCompound item = (NBTTagCompound)list.getCompoundTagAt(i); int slot = item.getInteger("slot"); - ItemStack stack = ItemStack.loadItemStackFromNBT(item); + ItemStack stack = new ItemStack(item); inventory.setInventorySlotContents(slot, stack); } } @@ -98,7 +97,13 @@ public ITextComponent getDisplayName() { public int getSizeInventory() { IInventory inventory = getInventory(); return (inventory != null) ? inventory.getSizeInventory() : 0; - } + } + + @Override + public boolean isEmpty() { + IInventory inventory = getInventory(); + return inventory != null && inventory.isEmpty(); + } /** * Returns the stack in slot i @@ -163,9 +168,9 @@ public int getInventoryStackLimit() { * Do not make give this method the name canInteractWith because it clashes with Container */ @Override - public boolean isUseableByPlayer(EntityPlayer player) { + public boolean isUsableByPlayer(EntityPlayer player) { IInventory inventory = getInventory(); - return (inventory != null) ? inventory.isUseableByPlayer(player) : true; + return (inventory != null) ? inventory.isUsableByPlayer(player) : true; } @Override diff --git a/src/base/gcewing/sg/BaseUtils.java b/src/base/gcewing/sg/BaseUtils.java index d974989b..1fb9a48d 100644 --- a/src/base/gcewing/sg/BaseUtils.java +++ b/src/base/gcewing/sg/BaseUtils.java @@ -6,19 +6,16 @@ package gcewing.sg; -import java.util.*; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.*; -import net.minecraft.nbt.*; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import net.minecraft.world.storage.MapStorage; - +import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.DimensionManager; +import java.util.Collection; + public class BaseUtils { public static EnumFacing[] facings = EnumFacing.values(); @@ -82,7 +79,10 @@ public static MinecraftServer getMinecraftServer() { } public static WorldServer getWorldForDimension(int id) { - return getMinecraftServer().worldServerForDimension(id); + if (!DimensionManager.isDimensionRegistered(id)) { + return null; + } + return getMinecraftServer().getWorld(id); } public static T getWorldData(World world, Class cls, String name) { diff --git a/src/base/gcewing/sg/BaseWorldRenderTarget.java b/src/base/gcewing/sg/BaseWorldRenderTarget.java index c9a5f94d..362e81f6 100644 --- a/src/base/gcewing/sg/BaseWorldRenderTarget.java +++ b/src/base/gcewing/sg/BaseWorldRenderTarget.java @@ -6,25 +6,16 @@ package gcewing.sg; -import java.util.*; -import java.nio.*; import static java.lang.Math.*; import net.minecraft.block.*; import net.minecraft.block.state.*; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.item.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.client.model.*; - -import gcewing.sg.BaseModClient.ITexture; import static gcewing.sg.BaseUtils.*; public class BaseWorldRenderTarget extends BaseRenderTarget { @@ -33,7 +24,7 @@ public class BaseWorldRenderTarget extends BaseRenderTarget { protected BlockPos blockPos; protected IBlockState blockState; protected Block block; - protected VertexBuffer tess; + protected BufferBuilder tess; protected float cmr = 1, cmg = 1, cmb = 1; protected boolean ao; protected boolean axisAlignedNormal; @@ -41,7 +32,7 @@ public class BaseWorldRenderTarget extends BaseRenderTarget { protected float vr, vg, vb, va; // Colour to be applied to next vertex protected int vlm1, vlm2; // Light map values to be applied to next vertex - public BaseWorldRenderTarget(IBlockAccess world, BlockPos pos, VertexBuffer tess, TextureAtlasSprite overrideIcon) { + public BaseWorldRenderTarget(IBlockAccess world, BlockPos pos, BufferBuilder tess, TextureAtlasSprite overrideIcon) { super(pos.getX(), pos.getY(), pos.getZ(), overrideIcon); //System.out.printf("BaseWorldRenderTarget(%s)\n", pos); this.world = world; @@ -53,7 +44,7 @@ public BaseWorldRenderTarget(IBlockAccess world, BlockPos pos, VertexBuffer tess expandTrianglesToQuads = true; } - VertexBuffer getWorldRenderer() { + BufferBuilder getWorldRenderer() { return tess; } @@ -132,7 +123,7 @@ protected void aoLightVertex(Vector3 v) { lv = state.getBlock().getAmbientOcclusionLightValue(state); } else - lv = 1.0f; + lv = 1F; //System.out.printf("BaseWorldRenderTarget.aoLightVertex: (%s,%s,%s) br = 0x%08x lv = %.3f w = %.3f\n", X, Y, Z, br, lv, w); if (br != 0) { double br1 = ((br >> 16) & 0xff) / 240.0; diff --git a/src/base/gcewing/sg/Trans3.java b/src/base/gcewing/sg/Trans3.java index d3a8279f..75b1d19f 100644 --- a/src/base/gcewing/sg/Trans3.java +++ b/src/base/gcewing/sg/Trans3.java @@ -12,7 +12,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.*; import net.minecraft.util.math.*; -import net.minecraftforge.common.util.*; import static gcewing.sg.Vector3.getDirectionVec; @@ -85,7 +84,8 @@ public Trans3 translate(double dx, double dy, double dz) { return new Trans3( offset.add(rotation.mul(dx * scaling, dy * scaling, dz * scaling)), rotation, - scaling); + scaling + ); } public Trans3 rotate(Matrix3 m) { @@ -176,7 +176,7 @@ public Vector3 iv(Vector3 u) { } public Vector3 iv(Vec3d u) { - return iv(u.xCoord, u.yCoord, u.zCoord); + return iv(u.x, u.y, u.z); } public AxisAlignedBB t(AxisAlignedBB box) { diff --git a/src/base/gcewing/sg/Vector3.java b/src/base/gcewing/sg/Vector3.java index a5d1940c..0588822f 100644 --- a/src/base/gcewing/sg/Vector3.java +++ b/src/base/gcewing/sg/Vector3.java @@ -45,7 +45,7 @@ public Vector3(double x, double y, double z) { } public Vector3(Vec3d v) { - this(v.xCoord, v.yCoord, v.zCoord); + this(v.x, v.y, v.z); } public Vector3(Vec3i v) { diff --git a/src/mod/gcewing/sg/DHDBlock.java b/src/mod/gcewing/sg/DHDBlock.java index c6dc086e..3013e791 100644 --- a/src/mod/gcewing/sg/DHDBlock.java +++ b/src/mod/gcewing/sg/DHDBlock.java @@ -6,47 +6,47 @@ package gcewing.sg; -import net.minecraft.block.*; -import net.minecraft.block.material.*; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.creativetab.*; -import net.minecraft.entity.*; -import net.minecraft.entity.player.*; -import net.minecraft.item.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; - import gcewing.sg.BaseMod.ModelSpec; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class DHDBlock extends BaseBlock { protected static String[] textures = { "dhd_top", "dhd_side", - "stargateBlock", + "stargateblock", "dhd_button_dim", }; - protected static ModelSpec model = new ModelSpec("dhd.smeg", new Vector3(0, -0.5, 0), textures); + protected static ModelSpec model = new ModelSpec("block/dhd.smeg", new Vector3(0, -0.5, 0), textures); public DHDBlock() { super(Material.ROCK, DHDTE.class); setHardness(1.5F); setCreativeTab(CreativeTabs.MISC); } - + @Override public String[] getTextureNames() { return textures; } - + @Override public ModelSpec getModelSpec(IBlockState state) { return model; } - + @Override public IOrientationHandler getOrientationHandler() { return BaseOrientation.orient4WaysByState; @@ -56,7 +56,7 @@ public IOrientationHandler getOrientationHandler() { public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.INVISIBLE; } - + @Override public boolean isOpaqueCube(IBlockState state) { return false; @@ -77,7 +77,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity @Override public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player) { - return true; + return SGCraft.canHarvestDHD; } @Override @@ -93,16 +93,16 @@ else if (cte.isLinkedToStargate) { gte.clearLinkToController(); } } - + @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float cx, float cy, float cz) + EnumHand hand, EnumFacing side, float cx, float cy, float cz) { SGGui id = cy > 0.5 ? SGGui.SGController : SGGui.DHDFuel; SGCraft.mod.openGui(player, id, world, pos); return true; } - + public void checkForLink(World world, BlockPos pos) { //System.out.printf("DHDBlock.checkForLink at %s\n", pos); DHDTE te = getTileEntity(world, pos); @@ -111,5 +111,9 @@ public void checkForLink(World world, BlockPos pos) { else System.out.printf("DHDBlock.breakBlock: No tile entity at %d\n", pos); } - + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new DHDTE(DHDTE.cfgMaxEnergyBuffer); + } } diff --git a/src/mod/gcewing/sg/DHDFuelContainer.java b/src/mod/gcewing/sg/DHDFuelContainer.java index 461d9daf..581efc4d 100644 --- a/src/mod/gcewing/sg/DHDFuelContainer.java +++ b/src/mod/gcewing/sg/DHDFuelContainer.java @@ -9,7 +9,6 @@ import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.item.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; @@ -49,6 +48,14 @@ void addFuelSlots() { addSlotToContainer(new FuelSlot(te, b + i, x, y)); } } + + @Override + protected SlotRange transferSlotRange(int srcSlotIndex, ItemStack stack) { + SlotRange range = new SlotRange(); + range.firstSlot = DHDTE.firstFuelSlot; + range.numSlots = DHDTE.numFuelSlots; + return range; + } // @Override // void sendStateTo(ICrafting crafter) { diff --git a/src/mod/gcewing/sg/DHDFuelScreen.java b/src/mod/gcewing/sg/DHDFuelScreen.java index 6790b48c..279442de 100644 --- a/src/mod/gcewing/sg/DHDFuelScreen.java +++ b/src/mod/gcewing/sg/DHDFuelScreen.java @@ -6,61 +6,101 @@ package gcewing.sg; -import org.lwjgl.input.*; import org.lwjgl.opengl.*; -import net.minecraft.client.gui.*; import net.minecraft.entity.player.*; import net.minecraft.util.math.*; import net.minecraft.world.*; +import java.text.DecimalFormat; + public class DHDFuelScreen extends SGScreen { - static String screenTitle = "Stargate Controller"; - static final int guiWidth = 256; - static final int guiHeight = 208; - static final int fuelGaugeWidth = 16; - static final int fuelGaugeHeight = 34; - static final int fuelGaugeX = 214; - static final int fuelGaugeY = 84; - static final int fuelGaugeU = 0; - static final int fuelGaugeV = 208; - - DHDTE te; - + private final String screenTitle = "Stargate Controller"; + final static int guiWidth = 256; + final static int guiHeight = 208; + private final int fuelGaugeWidth = 16; + private final int fuelGaugeHeight = 34; + private final int fuelGaugeX = 214; + private final int fuelGaugeY = 84; + private final int fuelGaugeU = 0; + private final int fuelGaugeV = 208; + private final DecimalFormat dFormat = new DecimalFormat("###,###,###"); + + private DHDTE te; + private SGBaseTE baseTe; + private double energyPerFuelItem; + public static DHDFuelScreen create(EntityPlayer player, World world, BlockPos pos) { DHDTE te = DHDTE.at(world, pos); - if (te != null) + if (te != null) { return new DHDFuelScreen(player, te); - else + } else { return null; + } } public DHDFuelScreen(EntityPlayer player, DHDTE te) { super(new DHDFuelContainer(player, te), guiWidth, guiHeight); this.te = te; + this.baseTe = te.getLinkedStargateTE(); + this.energyPerFuelItem = SGBaseTE.energyPerFuelItem; } - + @Override protected void drawBackgroundLayer() { bindTexture(SGCraft.mod.resourceLocation("textures/gui/dhd_fuel_gui.png"), 256, 256); - drawTexturedRect(0, 0, guiWidth, guiHeight, 0, 0); + + drawTexturedRect(0, 0, this.guiWidth, this.guiHeight, 0, 0); drawFuelGauge(); - int cx = xSize / 2; + int cx = this.xSize / 2; setTextColor(0x004c66); - drawCenteredString(screenTitle, cx, 8); + drawCenteredString(this.screenTitle, cx, 8); + drawCenteredString("_____________________________________________", cx, 15); + + + if (SGCraft.displayGuiPowerDebug) { + if (this.baseTe != null) { + // DHD Buffer Available + drawRightAlignedString("Gate Buffer:", 85, 30); + drawString(dFormat.format(Math.min(Math.max(this.baseTe.energyInBuffer, 0), this.baseTe.maxEnergyBuffer)), 90, 30); + + drawRightAlignedString("Buffer Max:", 85, 40); + drawString(dFormat.format(this.baseTe.maxEnergyBuffer), 90, 40); + } + + // DHD Buffer Available + drawRightAlignedString("DHD Buffer:", 200, 30); + drawString(dFormat.format(Math.min(Math.max(this.te.energyInBuffer, 0), this.te.maxEnergyBuffer)), 205, 30); + + // Buffer Max + drawRightAlignedString("Buffer Max:", 200, 40); + drawString(dFormat.format(this.te.maxEnergyBuffer), 205, 40); + + int naquadahUnits = this.te.getInventory().getStackInSlot(0).getCount() + this.te.getInventory().getStackInSlot(1).getCount() + this.te.getInventory().getStackInSlot(2).getCount() + this.te.getInventory().getStackInSlot(3).getCount(); + + // Naquadah Power Units + drawRightAlignedString("SG Power Units:", 135, 55); + drawString(dFormat.format(naquadahUnits * this.energyPerFuelItem), 140, 55); + + // Naquadah Units + drawRightAlignedString("Naquadah:", 135, 65); + drawString(dFormat.format(naquadahUnits), 140, 65); + + + } + if (this.te.numFuelSlots > 0) drawString("Fuel", 150, 96); } - - void drawFuelGauge() { - int level = (int)(fuelGaugeHeight * te.energyInBuffer / te.maxEnergyBuffer); - if (level > fuelGaugeHeight) - level = fuelGaugeHeight; + + private void drawFuelGauge() { + int level = (int)(this.fuelGaugeHeight * this.te.energyInBuffer / this.te.maxEnergyBuffer); + if (level > this.fuelGaugeHeight) + level = this.fuelGaugeHeight; GL11.glEnable(GL11.GL_BLEND); - drawTexturedRect(fuelGaugeX, fuelGaugeY + fuelGaugeHeight - level, - fuelGaugeWidth, level, fuelGaugeU, fuelGaugeV); + drawTexturedRect(this.fuelGaugeX, this.fuelGaugeY + this.fuelGaugeHeight - level, + this.fuelGaugeWidth, level, this.fuelGaugeU, this.fuelGaugeV); GL11.glDisable(GL11.GL_BLEND); } - -} +} \ No newline at end of file diff --git a/src/mod/gcewing/sg/DHDScreen.java b/src/mod/gcewing/sg/DHDScreen.java index cb572c59..054cc09d 100644 --- a/src/mod/gcewing/sg/DHDScreen.java +++ b/src/mod/gcewing/sg/DHDScreen.java @@ -6,23 +6,34 @@ package gcewing.sg; -import java.io.*; -import org.lwjgl.input.*; -import org.lwjgl.opengl.*; -import static org.lwjgl.opengl.GL11.*; +import static gcewing.sg.BaseBlockUtils.getWorldTileEntity; +import static org.lwjgl.opengl.GL11.GL_ALPHA_TEST; +import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; +import static org.lwjgl.opengl.GL11.GL_ENABLE_BIT; +import static org.lwjgl.opengl.GL11.GL_LINEAR; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_MAG_FILTER; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_MIN_FILTER; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glDisable; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL11.glPopAttrib; +import static org.lwjgl.opengl.GL11.glPushAttrib; +import static org.lwjgl.opengl.GL11.glTexParameteri; -import net.minecraft.client.audio.*; -import net.minecraft.client.gui.*; -import net.minecraft.client.renderer.*; -import net.minecraft.entity.player.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; - -import net.minecraftforge.client.*; - -import static gcewing.sg.BaseBlockUtils.*; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; public class DHDScreen extends SGScreen { @@ -39,7 +50,7 @@ public class DHDScreen extends SGScreen { int closingDelay = 0; int addressLength; DHDTE cte; - + public DHDScreen(EntityPlayer player, World world, BlockPos pos) { this.world = world; this.pos = pos; @@ -48,29 +59,22 @@ public DHDScreen(EntityPlayer player, World world, BlockPos pos) { if (te != null) addressLength = te.getNumChevrons(); } - + SGBaseTE getStargateTE() { - if (cte != null) - return cte.getLinkedStargateTE(); - else - return null; + return cte != null ? cte.getLinkedStargateTE() : null; } - + DHDTE getControllerTE() { TileEntity te = getWorldTileEntity(world, pos); - if (te instanceof DHDTE) - return (DHDTE)te; - else - return null; + return te instanceof DHDTE ? (DHDTE) te : null; } - + String getEnteredAddress() { return cte.enteredAddress; } - + void setEnteredAddress(String address) { cte.enteredAddress = address; - SGChannel.sendEnteredAddressToServer(cte, address); } @Override @@ -79,22 +83,23 @@ public void initGui() { dhdCentreX = width / 2; dhdCentreY = dhdTop + dhdHeight / 2; } - -// @Override -// public void onGuiClosed() { -// } + + // @Override + // public void onGuiClosed() { + // } @Override public void updateScreen() { super.updateScreen(); if (closingDelay > 0) { if (--closingDelay == 0) { - setEnteredAddress(""); + cte.enteredAddress = ""; + SGChannel.sendClearAddressToServer(cte); close(); } } } - + @Override protected void mousePressed(int x, int y, int mouseButton) { //System.out.printf("DHDScreen.mousePressed: %d, %d, %d\n", x, y, mouseButton); @@ -102,15 +107,14 @@ protected void mousePressed(int x, int y, int mouseButton) { int i = findDHDButton(x, y); if (i >= 0) { dhdButtonPressed(i); - return; } } } - + void closeAfterDelay(int ticks) { closingDelay = ticks; } - + int findDHDButton(int mx, int my) { //System.out.printf("DHDScreen.findDHDButton: mx = %d, my = %d, cx = %d, cy = %d\n", // mx, my, dhdCentreX, dhdCentreY); @@ -144,84 +148,89 @@ int findDHDButton(int mx, int my) { System.out.printf("DHDScreen.findDHDButton: i = %d\n", i); return i; } - + void dhdButtonPressed(int i) { //System.out.printf("DHDScreen.dhdButtonPressed: %d\n", i); - buttonSound(); - if (i == 0) - orangeButtonPressed(false); - else if (i >= 37) - backspace(); - else - enterCharacter(SGBaseTE.symbolToChar(i - 1)); + if (i == 0) { + dial(); + } else if (i >= 37) { + erase(); + } else { + chevron(SGBaseTE.symbolToChar(i - 1)); + } } - - void buttonSound() { - //mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - EntityPlayer player = mc.thePlayer; - ISound sound = new PositionedSoundRecord( - new ResourceLocation("ui.button.click"), SoundCategory.BLOCKS, - 1.0F, 1.0F, - false, 0, ISound.AttenuationType.LINEAR, - (float)player.posX, (float)player.posY, (float)player.posZ); - mc.getSoundHandler().playSound(sound); + + void buttonSound(SoundEvent sound) { + EntityPlayer player = mc.player; + ISound s = new PositionedSoundRecord(sound, SoundCategory.BLOCKS, + 1F, 1F, + (float)player.posX, (float)player.posY, (float)player.posZ); + mc.getSoundHandler().playSound(s); } @Override protected void keyTyped(char c, int key) { - if (key == Keyboard.KEY_ESCAPE) - close(); - else if (key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE) - backspace(); - else if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) - orangeButtonPressed(true); - else { - String C = String.valueOf(c).toUpperCase(); - if (SGAddressing.isValidSymbolChar(C)) - enterCharacter(C.charAt(0)); + switch (key) { + case Keyboard.KEY_ESCAPE: + close(); + break; + case Keyboard.KEY_BACK: + case Keyboard.KEY_DELETE: + erase(); + break; + case Keyboard.KEY_RETURN: + case Keyboard.KEY_NUMPADENTER: + dial(); + break; + default: + String C = String.valueOf(c).toUpperCase(); + if (SGAddressing.isValidSymbolChar(C)) + chevron(C.charAt(0)); + break; } } - - void orangeButtonPressed(boolean connectOnly) { + + void dial() { SGBaseTE te = getStargateTE(); if (te != null) { - if (te.state == SGState.Idle) - sendConnectOrDisconnect(te, getEnteredAddress()); - else if (!connectOnly) - sendConnectOrDisconnect(te, ""); + buttonSound(SGBaseTE.dhdDialSound); + sendConnectOrDisconnect(te, te.state == SGState.Idle ? getEnteredAddress() : ""); } } - + void sendConnectOrDisconnect(SGBaseTE te, String address) { SGChannel.sendConnectOrDisconnectToServer(te, address); closeAfterDelay(10); } - - void backspace() { + + void erase() { if (stargateIsIdle()) { - buttonSound(); - String a = getEnteredAddress(); - int n = a.length(); - if (n > 0) - setEnteredAddress(a.substring(0, n - 1)); + buttonSound(SoundEvents.UI_BUTTON_CLICK); + String enteredAddress = getEnteredAddress(); + if (!enteredAddress.isEmpty()) { + cte.unsetSymbol(); + SGChannel.sendUnsetSymbolToServer(cte); + } } } - - void enterCharacter(char c) { + + void chevron(char c) { if (stargateIsIdle()) { - buttonSound(); + buttonSound(SGBaseTE.dhdPressSound); String a = getEnteredAddress(); int n = a.length(); - if (n < addressLength) - setEnteredAddress(a + c); + if (n < addressLength) { + cte.enterSymbol(c); + SGChannel.sendEnterSymbolToServer(cte, c); + } } } - + boolean stargateIsIdle() { SGBaseTE te = getStargateTE(); return (te != null && te.state == SGState.Idle); } - + @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { SGBaseTE te = getStargateTE(); @@ -246,7 +255,7 @@ void drawBackgroundImage() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); drawTexturedRect((width - dhdWidth) / 2, height - dhdHeight, dhdWidth, dhdHeight); } - + void drawOrangeButton() { bindTexture(SGCraft.mod.resourceLocation("textures/gui/dhd_centre.png"), 128, 64); SGBaseTE te = getStargateTE(); @@ -259,25 +268,25 @@ else if (connected) setColor(0.5, 0.25, 0.0); double rx = dhdWidth * 48 / 512.0; double ry = dhdHeight * 48 / 256.0; -// Tessellator.instance.disableColor(); + // Tessellator.instance.disableColor(); drawTexturedRect(dhdCentreX - rx, dhdCentreY - ry - 6, 2 * rx, 1.5 * ry, - 64, 0, 64, 48); + 64, 0, 64, 48); resetColor(); if (connected) { GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); double d = 5; drawTexturedRect(dhdCentreX - rx - d, dhdCentreY - ry - d - 6, 2 * (rx + d), ry + d, - 0, 0, 64, 32); + 0, 0, 64, 32); drawTexturedRect(dhdCentreX - rx - d, dhdCentreY - 6, 2 * (rx + d), 0.5 * ry + d, - 0, 32, 64, 32); + 0, 32, 64, 32); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } } - + void drawEnteredSymbols() { drawAddressSymbols(width / 2, dhdTop - 80, getEnteredAddress()); } - + void drawEnteredString() { String address = SGAddressing.padAddress(getEnteredAddress(), "|", addressLength); drawAddressString(width / 2, dhdTop - 20, address); diff --git a/src/mod/gcewing/sg/DHDTE.java b/src/mod/gcewing/sg/DHDTE.java index ae1c92da..1cf51ea6 100644 --- a/src/mod/gcewing/sg/DHDTE.java +++ b/src/mod/gcewing/sg/DHDTE.java @@ -6,73 +6,106 @@ package gcewing.sg; -import net.minecraft.block.state.IBlockState; -import net.minecraft.inventory.*; -import net.minecraft.item.*; -import net.minecraft.nbt.*; -import net.minecraft.tileentity.*; -import net.minecraft.world.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; - -import static gcewing.sg.BaseBlockUtils.*; -import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.Utils.*; +import static gcewing.sg.BaseBlockUtils.getWorldTileEntity; +import static gcewing.sg.BaseUtils.min; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; public class DHDTE extends BaseTileInventory implements ISGEnergySource { // Debug options public static boolean debugLink = false; - // Configuration options + // Static Configuration options public static int linkRangeX = 5; // either side public static int linkRangeY = 1; // up or down public static int linkRangeZ = 6; // in front - - // Inventory slots + public static AxisAlignedBB bounds; public static final int firstFuelSlot = 0; public static final int numFuelSlots = 4; - public static final int numSlots = numFuelSlots; + private static final int numSlots = numFuelSlots; + + public static double cfgMaxEnergyBuffer = 2500; + - // Persisted fields + // Instanced Options public boolean isLinkedToStargate; public BlockPos linkedPos = new BlockPos(0, 0, 0); public String enteredAddress = ""; - IInventory inventory = new InventoryBasic("DHD", false, numSlots); - - static AxisAlignedBB bounds; - static double maxEnergyBuffer; + public IInventory inventory = new InventoryBasic("DHD", false, numSlots); + public double maxEnergyBuffer = 2500; + public double energyInBuffer = 0; - double energyInBuffer; + // Required + public DHDTE() {} + + // Required to handle instanced variables + public DHDTE(final double maxEnergyBuffer) { + this.maxEnergyBuffer = maxEnergyBuffer; + } public static void configure(BaseConfiguration cfg) { linkRangeX = cfg.getInteger("dhd", "linkRangeX", linkRangeX); linkRangeY = cfg.getInteger("dhd", "linkRangeY", linkRangeY); linkRangeZ = cfg.getInteger("dhd", "linkRangeZ", linkRangeZ); - maxEnergyBuffer = SGBaseTE.energyPerFuelItem; + cfgMaxEnergyBuffer = cfg.getDouble("dhd", "bufferSize", cfgMaxEnergyBuffer); } - + public static DHDTE at(IBlockAccess world, BlockPos pos) { TileEntity te = getWorldTileEntity(world, pos); - if (te instanceof DHDTE) - return (DHDTE)te; - else - return null; + return te instanceof DHDTE ? (DHDTE) te : null; } - + public static DHDTE at(IBlockAccess world, NBTTagCompound nbt) { BlockPos pos = new BlockPos(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z")); return DHDTE.at(world, pos); } - - public void setEnteredAddress(String address) { - enteredAddress = address; + + void enterSymbol(char symbol) { + SGBaseTE gate = getLinkedStargateTE(); + if (gate != null) { + if (enteredAddress.length() < gate.getNumChevrons()) { + enteredAddress += symbol; + /* + if (this.immediateDialDHD) { + boolean last = enteredAddress.length() == gate.getNumChevrons(); + gate.finishDiallingSymbol(symbol, true, false, last); + gate.markChanged(); + } */ + } + } + } + + void unsetSymbol() { + SGBaseTE gate = getLinkedStargateTE(); + if (gate != null) { + if (!enteredAddress.isEmpty()) { + char symbol = enteredAddress.charAt(enteredAddress.length() - 1); + enteredAddress = enteredAddress.substring(0, enteredAddress.length() - 1); + /* + if (this.immediateDialDHD) { + gate.unsetSymbol(symbol); + gate.markChanged(); + } */ + } + } + } + + public void clearAddress() { + enteredAddress = ""; markChanged(); } - + @Override public AxisAlignedBB getRenderBoundingBox() { - return bounds.addCoord(getX() + 0.5, getY(), getZ() + 0.5); + return bounds.expand(getX() + 0.5, getY(), getZ() + 0.5); } @Override @@ -84,48 +117,46 @@ public double getMaxRenderDistanceSquared() { protected IInventory getInventory() { return inventory; } - + public DHDBlock getBlock() { return (DHDBlock)getBlockType(); } - -// public Trans3 localToGlobalTransformation() { -// World world = getWorld(); -// IBlockState state = world.getBlockState(pos); -// return getBlock().localToGlobalTransformation(world, pos, state); -// } - -// public int getRotation() { -// return getBlock().rotationInWorld(getBlockMetadata(), this); -// } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - isLinkedToStargate = nbt.getBoolean("isLinkedToStargate"); - energyInBuffer = nbt.getDouble("energyInBuffer"); + this.isLinkedToStargate = nbt.getBoolean("isLinkedToStargate"); + this.energyInBuffer = nbt.getDouble("energyInBuffer"); int x = nbt.getInteger("linkedX"); int y = nbt.getInteger("linkedY"); int z = nbt.getInteger("linkedZ"); - linkedPos = new BlockPos(x, y, z); - enteredAddress = nbt.getString("enteredAddress"); + this.linkedPos = new BlockPos(x, y, z); + this.enteredAddress = nbt.getString("enteredAddress"); + + // Check if Key doesn't exist or if Admin is trying to update all the DHD's with new values. + if (!nbt.hasKey("bufferSize") || SGCraft.forceDHDCfgUpdate) { + this.maxEnergyBuffer = cfgMaxEnergyBuffer; + } else { + this.maxEnergyBuffer = nbt.getDouble("bufferSize"); + } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setBoolean("isLinkedToStargate", isLinkedToStargate); - nbt.setDouble("energyInBuffer", energyInBuffer); - nbt.setInteger("linkedX", linkedPos.getX()); - nbt.setInteger("linkedY", linkedPos.getY()); - nbt.setInteger("linkedZ", linkedPos.getZ()); - nbt.setString("enteredAddress", enteredAddress); + nbt.setBoolean("isLinkedToStargate", this.isLinkedToStargate); + nbt.setDouble("energyInBuffer", this.energyInBuffer); + nbt.setInteger("linkedX", this.linkedPos.getX()); + nbt.setInteger("linkedY", this.linkedPos.getY()); + nbt.setInteger("linkedZ", this.linkedPos.getZ()); + nbt.setString("enteredAddress", this.enteredAddress); + nbt.setDouble("bufferSize", this.maxEnergyBuffer); return nbt; } SGBaseTE getLinkedStargateTE() { if (isLinkedToStargate) { - TileEntity gte = getWorldTileEntity(worldObj, linkedPos); + TileEntity gte = getWorldTileEntity(world, linkedPos); if (gte instanceof SGBaseTE) return (SGBaseTE)gte; } @@ -135,36 +166,36 @@ SGBaseTE getLinkedStargateTE() { void checkForLink() { if (debugLink) System.out.printf("DHDTE.checkForLink at %s: isLinkedToStargate = %s\n", - pos, isLinkedToStargate); + pos, isLinkedToStargate); if (!isLinkedToStargate) { Trans3 t = localToGlobalTransformation(); for (int i = -linkRangeX; i <= linkRangeX; i++) for (int j = -linkRangeY; j <= linkRangeY; j++) - for (int k = 1; k <= linkRangeZ; k++) { + for (int k = -linkRangeZ; k <= linkRangeZ; k++) { Vector3 p = t.p(i, j, -k); //System.out.printf("DHDTE: Looking for stargate at (%d,%d,%d)\n", // p.floorX(), p.floorY(), p.floorZ()); BlockPos bp = new BlockPos(p.floorX(), p.floorY(), p.floorZ()); if (debugLink) System.out.printf("DHDTE.checkForLink: probing %s\n", bp); - TileEntity te = worldObj.getTileEntity(bp); + TileEntity te = world.getTileEntity(bp); if (te instanceof SGBaseTE) { if (debugLink) System.out.printf("DHDTE.checkForLink: Found stargate at %s\n", - te.getPos()); + te.getPos()); if (linkToStargate((SGBaseTE)te)) return; } } } } - + boolean linkToStargate(SGBaseTE gte) { if (!isLinkedToStargate && !gte.isLinkedToController && gte.isMerged) { if (debugLink) System.out.printf( - "DHDTE.linkToStargate: Linking controller at %s with stargate at %s\n", - pos, gte.getPos()); + "DHDTE.linkToStargate: Linking controller at %s with stargate at %s\n", + pos, gte.getPos()); linkedPos = gte.getPos(); isLinkedToStargate = true; markChanged(); @@ -175,25 +206,25 @@ boolean linkToStargate(SGBaseTE gte) { } return false; } - + public void clearLinkToStargate() { if (debugLink) System.out.printf("DHDTE: Unlinking controller at %s from stargate\n", pos); isLinkedToStargate = false; markChanged(); } - + @Override public double availableEnergy() { double energy = energyInBuffer; for (int i = 0; i < numFuelSlots; i++) { ItemStack stack = fuelStackInSlot(i); if (stack != null) - energy += stack.stackSize * SGBaseTE.energyPerFuelItem; + energy += stack.getCount() * SGBaseTE.energyPerFuelItem; } return energy; } - + @Override public double drawEnergy(double amount) { double energyDrawn = 0; @@ -208,11 +239,11 @@ public double drawEnergy(double amount) { } if (SGBaseTE.debugEnergyUse) System.out.printf("DHDTE.drawEnergy: %s; supplied: %s; buffered: %s\n", - amount, energyDrawn, energyInBuffer); + amount, energyDrawn, energyInBuffer); markChanged(); return energyDrawn; } - + boolean useFuelItem() { for (int i = numFuelSlots - 1; i >= 0; i--) { ItemStack stack = fuelStackInSlot(i); @@ -224,22 +255,18 @@ boolean useFuelItem() { } return false; } - + ItemStack fuelStackInSlot(int i) { ItemStack stack = getStackInSlot(firstFuelSlot + i); - if (isValidFuelItem(stack)) - return stack; - else - return null; + return isValidFuelItem(stack) ? stack : null; } - + public static boolean isValidFuelItem(ItemStack stack) { - return stack != null && stack.getItem() == SGCraft.naquadah && stack.stackSize > 0; + return stack != null && stack.getItem() == SGCraft.naquadah && stack.getCount() > 0; } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return isValidFuelItem(stack); } - } diff --git a/src/mod/gcewing/sg/DHDTERenderer.java b/src/mod/gcewing/sg/DHDTERenderer.java index d118e6e2..5512c848 100644 --- a/src/mod/gcewing/sg/DHDTERenderer.java +++ b/src/mod/gcewing/sg/DHDTERenderer.java @@ -6,15 +6,12 @@ package gcewing.sg; -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL12.*; -import net.minecraft.util.*; - -import net.minecraft.client.renderer.tileentity.*; -import net.minecraft.tileentity.*; - -import gcewing.sg.BaseModClient.*; -import gcewing.sg.BaseTexture.*; +import gcewing.sg.BaseModClient.IModel; +import gcewing.sg.BaseModClient.IRenderTarget; +import gcewing.sg.BaseModClient.ITexture; +import gcewing.sg.BaseModClient.ITiledTexture; +import gcewing.sg.BaseTexture.Image; +import net.minecraft.util.ResourceLocation; class DHDTERenderer extends BaseTileEntityRenderer { @@ -43,7 +40,7 @@ public DHDTERenderer() { button.colored(0.5, 0.25, 0.0), button.colored(1.0, 0.5, 0.0).emissive(), }; - model = BaseModel.fromResource(mod.resourceLocation("models/dhd.smeg")); + model = BaseModel.fromResource(mod.resourceLocation("models/block/dhd.smeg")); DHDTE.bounds = model.getBounds(); } diff --git a/src/mod/gcewing/sg/IrisEntity.java b/src/mod/gcewing/sg/EntityStargateIris.java similarity index 72% rename from src/mod/gcewing/sg/IrisEntity.java rename to src/mod/gcewing/sg/EntityStargateIris.java index 9e6429f9..cb2213f1 100644 --- a/src/mod/gcewing/sg/IrisEntity.java +++ b/src/mod/gcewing/sg/EntityStargateIris.java @@ -6,27 +6,29 @@ package gcewing.sg; -import java.io.*; -import io.netty.buffer.*; -import net.minecraft.entity.*; -import net.minecraft.nbt.*; -import net.minecraft.world.*; -import net.minecraft.tileentity.*; -import net.minecraftforge.common.util.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; - +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; +import io.netty.buffer.ByteBufOutputStream; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; -public class IrisEntity extends Entity implements IEntityAdditionalSpawnData { +import java.io.DataInput; +import java.io.DataOutput; + +public class EntityStargateIris extends Entity implements IEntityAdditionalSpawnData { BlockPos blockPos; - public IrisEntity(World world) { + public EntityStargateIris(World world) { super(world); } - public IrisEntity(SGBaseTE te) { + public EntityStargateIris(SGBaseTE te) { this(te.getWorld()); double radius = 2; double thickness = SGBaseTE.irisThickness; @@ -38,50 +40,38 @@ public IrisEntity(SGBaseTE te) { double hz = thickness; AxisAlignedBB localBox = new AxisAlignedBB( cx - hx, cy - hy, cz - hz, - cx + hx, cy + hy, cz + hz); + cx + hx, cy + hy, cz + hz + ); Trans3 t = te.localToGlobalTransformation(); AxisAlignedBB globalBox = t.t(localBox); - //System.out.printf("IrisEntity.init: local %s\n", localBox); + //System.out.printf("EntityStargateIris.init: local %s\n", localBox); init(te.getPos(), globalBox); } void init(BlockPos pos, AxisAlignedBB box) { - //System.out.printf("IrisEntity.init: %s at %s box %s\n", this, pos, box); + //System.out.printf("EntityStargateIris.init: %s at %s box %s\n", this, pos, box); this.blockPos = pos; setPosition(box.minX, box.minY, box.minZ); setEntityBoundingBox(box); } @Override - protected void entityInit() { - } + protected void entityInit() {} SGBaseTE getBaseTE() { - TileEntity te = worldObj.getTileEntity(blockPos); - if (te instanceof SGBaseTE) - return (SGBaseTE)te; - else - return null; + TileEntity te = world.getTileEntity(blockPos); + return te instanceof SGBaseTE ? (SGBaseTE) te : null; } @Override public boolean canBeCollidedWith() { - boolean result; SGBaseTE te = getBaseTE(); - if (te != null) - result = te.irisIsClosed(); - else - result = false; - //System.out.printf("IrisEntity.canBeCollidedWith: %s\n", result); - return result; + return te != null && te.irisIsClosed(); } @Override public AxisAlignedBB getCollisionBoundingBox() { - if (canBeCollidedWith()) - return super.getEntityBoundingBox(); - else - return null; + return canBeCollidedWith() ? super.getEntityBoundingBox() : null; } @Override @@ -91,7 +81,7 @@ public boolean canBePushed() { @Override public void readEntityFromNBT(NBTTagCompound nbt) { - //System.out.printf("IrisEntity.readEntityFromNBT\n"); + //System.out.printf("EntityStargateIris.readEntityFromNBT\n"); int blockX = nbt.getInteger("blockX"); int blockY = nbt.getInteger("blockY"); int blockZ = nbt.getInteger("blockZ"); @@ -108,7 +98,7 @@ public void readEntityFromNBT(NBTTagCompound nbt) { @Override public void writeEntityToNBT(NBTTagCompound nbt) { - //System.out.printf("IrisEntity.writeEntityToNBT\n"); + //System.out.printf("EntityStargateIris.writeEntityToNBT\n"); nbt.setInteger("blockX", blockPos.getX()); nbt.setInteger("blockY", blockPos.getY()); nbt.setInteger("blockZ", blockPos.getZ()); @@ -130,7 +120,7 @@ protected boolean shouldSetPosAfterLoading() { @Override public void writeSpawnData(ByteBuf buffer) { - //System.out.printf("IrisEntity.writeSpawnData\n"); + //System.out.printf("EntityStargateIris.writeSpawnData\n"); try { DataOutput data = new ByteBufOutputStream(buffer); BaseBlockUtils.writeBlockPos(data, blockPos); @@ -141,15 +131,14 @@ public void writeSpawnData(ByteBuf buffer) { data.writeDouble(box.maxX); data.writeDouble(box.maxY); data.writeDouble(box.maxZ); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @Override public void readSpawnData(ByteBuf buffer) { - //System.out.printf("IrisEntity.readSpawnData\n"); + //System.out.printf("EntityStargateIris.readSpawnData\n"); try { DataInput data = new ByteBufInputStream(buffer); BlockPos pos = BaseBlockUtils.readBlockPos(data); @@ -161,10 +150,8 @@ public void readSpawnData(ByteBuf buffer) { double maxZ = data.readDouble(); AxisAlignedBB box = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); init(pos, box); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - } diff --git a/src/mod/gcewing/sg/FeatureGeneration.java b/src/mod/gcewing/sg/FeatureGeneration.java index aeca4bd5..1ec34327 100644 --- a/src/mod/gcewing/sg/FeatureGeneration.java +++ b/src/mod/gcewing/sg/FeatureGeneration.java @@ -8,18 +8,21 @@ import java.util.*; import java.lang.reflect.Field; -import net.minecraft.util.EnumFacing; + +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.*; -import net.minecraft.world.gen.feature.*; import net.minecraft.world.gen.structure.*; import net.minecraftforge.event.terraingen.*; public class FeatureGeneration { - public static boolean augmentStructures = false; + public static boolean augmentStructures = true; public static boolean debugStructures = false; + public static boolean spawnTokra = true; public static int structureAugmentationChance = 25; + public static int chevronUpgradeChance = 25; static Field structureMap = BaseReflectionUtils.getFieldDef(MapGenStructure.class, "structureMap", "field_75053_d"); @@ -27,12 +30,15 @@ public class FeatureGeneration { public static void configure(BaseConfiguration config) { augmentStructures = config.getBoolean("options", "augmentStructures", augmentStructures); structureAugmentationChance = config.getInteger("options", "structureAugmentationChance", structureAugmentationChance); + chevronUpgradeChance = config.getInteger("options", "chevronUpgradeChance", chevronUpgradeChance); debugStructures = config.getBoolean("debug", "debugStructures", debugStructures); + spawnTokra = config.getBoolean("options", "spawnTokraWithPyramidStargate", spawnTokra); } public static void onInitMapGen(InitMapGenEvent e) { if (debugStructures) System.out.printf("SGCraft: FeatureGeneration.onInitMapGen: %s\n", e.getType()); + if (augmentStructures) { switch (e.getType()) { case SCATTERED_FEATURE: @@ -56,10 +62,15 @@ static MapGenStructure modifyScatteredFeatureGen(MapGenStructure gen) { } -class SGStructureMap extends HashMap { +class SGStructureMap extends Long2ObjectOpenHashMap { + + public SGStructureMap() { + super(1024); + } @Override - public Object put(Object key, Object value) { + @SuppressWarnings("unchecked") + public Object put(final long key, final Object value) { if (FeatureGeneration.debugStructures) System.out.printf("SGCraft: FeatureGeneration: SGStructureMap.put: %s\n", value); if (value instanceof StructureStart) @@ -68,16 +79,23 @@ public Object put(Object key, Object value) { } void augmentStructureStart(StructureStart start) { - System.out.printf("SGCraft: FeatureGeneration: augmentStructureStart: %s\n", start); + if (FeatureGeneration.debugStructures) { + System.out.printf("SGCraft: FeatureGeneration: augmentStructureStart: %s\n", start); + } List oldComponents = start.getComponents(); List newComponents = new ArrayList(); for (Object comp : oldComponents) { - System.out.printf("SGCraft: FeatureGeneration: Found component %s\n", comp); + if (FeatureGeneration.debugStructures) { + System.out.printf("SGCraft: FeatureGeneration: Found component %s\n", comp); + System.out.println("SGCraft: Instance: " + comp.getClass().getCanonicalName() + " -- " + comp.getClass().getSimpleName()); + } if (comp instanceof ComponentScatteredFeaturePieces.DesertPyramid) { StructureBoundingBox box = ((StructureComponent)comp).getBoundingBox(); - if (FeatureGeneration.debugStructures) + if (FeatureGeneration.debugStructures) { + BlockPos boxCenter = new BlockPos(box.minX + (box.maxX - box.minX + 1) / 2, box.minY + (box.maxY - box.minY + 1) / 2, box.minZ + (box.maxZ - box.minZ + 1) / 2); System.out.printf("SGCraft: FeatureGeneration: Augmenting %s at (%s, %s)\n", - comp.getClass().getSimpleName(), box.getCenter().getX(), box.getCenter().getZ()); + comp.getClass().getSimpleName(), boxCenter.getX(), boxCenter.getZ()); + } StructureComponent newComp = new FeatureUnderDesertPyramid((StructureComponent)comp); start.getBoundingBox().expandTo(newComp.getBoundingBox()); newComponents.add(newComp); @@ -85,5 +103,4 @@ void augmentStructureStart(StructureStart start) { } oldComponents.addAll(newComponents); } - } diff --git a/src/mod/gcewing/sg/FeatureUnderDesertPyramid.java b/src/mod/gcewing/sg/FeatureUnderDesertPyramid.java index 4bc562e2..2ca30942 100644 --- a/src/mod/gcewing/sg/FeatureUnderDesertPyramid.java +++ b/src/mod/gcewing/sg/FeatureUnderDesertPyramid.java @@ -6,28 +6,40 @@ package gcewing.sg; -import java.util.*; - -import net.minecraft.block.*; +import net.minecraft.block.BlockColored; +import net.minecraft.block.BlockSandStone; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockStoneSlab; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.*; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.init.Blocks; import net.minecraft.item.EnumDyeColor; -import net.minecraft.nbt.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; -import net.minecraft.world.gen.structure.*; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.template.TemplateManager; +import net.minecraftforge.fml.common.registry.VillagerRegistry; + +import java.util.Random; public class FeatureUnderDesertPyramid extends StructureComponent { StructureComponent base; - - protected void readStructureFromNBT(NBTTagCompound par1NBTTagCompound) { - } - - protected void writeStructureToNBT(NBTTagCompound par1NBTTagCompound) { - } - + boolean generateStructure = false; + boolean generateChevronUpgrade = false; + int pass = 0; + + @Override + protected void readStructureFromNBT(NBTTagCompound compound, TemplateManager templateManager) {} + + @Override + protected void writeStructureToNBT(NBTTagCompound compound) {} + public FeatureUnderDesertPyramid() { //System.out.printf("SGCraft: FeatureUnderDesertPyramid instantiated with no arguments\n"); } @@ -35,21 +47,23 @@ public FeatureUnderDesertPyramid() { public FeatureUnderDesertPyramid(StructureComponent base) { super(0); if (FeatureGeneration.debugStructures) - System.out.printf("SGCraft: Instantiating FeatureUnderDesertPyramid\n"); + System.out.println("SGCraft: Instantiating FeatureUnderDesertPyramid"); this.base = base; + Random rand = new Random(); + generateStructure = rand.nextInt(100) <= FeatureGeneration.structureAugmentationChance; + generateChevronUpgrade = rand.nextInt(100) <= FeatureGeneration.chevronUpgradeChance; StructureBoundingBox baseBox = base.getBoundingBox(); - int cx = baseBox.getCenter().getX(); - int cz = baseBox.getCenter().getZ(); + BlockPos boxCenter = new BlockPos(baseBox.minX + (baseBox.maxX - baseBox.minX + 1) / 2, baseBox.minY + (baseBox.maxY - baseBox.minY + 1) / 2, baseBox.minZ + (baseBox.maxZ - baseBox.minZ + 1) / 2); + int cx = boxCenter.getX(); + int cz = boxCenter.getZ(); int bottom = baseBox.minY - 7; boundingBox = new StructureBoundingBox(cx - 5, bottom, cz - 5, cx + 5, bottom + 7, cz + 8); setCoordBaseMode(EnumFacing.SOUTH); } - + + @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox clip) { - if (rand.nextInt(100) < FeatureGeneration.structureAugmentationChance) - return addAugmentationParts(world, rand, clip); - else - return true; + return generateStructure && addAugmentationParts(world, rand, clip); } protected boolean addAugmentationParts(World world, Random rand, StructureBoundingBox clip) { @@ -65,8 +79,8 @@ protected boolean addAugmentationParts(World world, Random rand, StructureBoundi IBlockState orange = Blocks.STAINED_HARDENED_CLAY.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.ORANGE); IBlockState stairs = Blocks.SANDSTONE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.EAST); IBlockState ladder = Blocks.LADDER.getDefaultState(); - IBlockState dhd = SGCraft.sgControllerBlock.getDefaultState().withProperty(BaseOrientation.Orient4WaysByState.FACING, EnumFacing.EAST); - IBlockState sgBase = SGCraft.sgBaseBlock.getDefaultState().withProperty(BaseOrientation.Orient4WaysByState.FACING, EnumFacing.EAST); + IBlockState dhd = SGCraft.sgControllerBlock.getDefaultState().withProperty(BaseOrientation.Orient4WaysByState.FACING, EnumFacing.NORTH); + IBlockState sgBase = SGCraft.sgBaseBlock.getDefaultState().withProperty(BaseOrientation.Orient4WaysByState.FACING, EnumFacing.NORTH); IBlockState[] sgRings = new IBlockState[2]; sgRings[0] = SGCraft.sgRingBlock.getDefaultState(); sgRings[1] = sgRings[0].withProperty(SGRingBlock.VARIANT, 1); @@ -118,21 +132,36 @@ else if (i == -2 || i == 2 || j == 0 || j == 4) { } int baseX = box.minX + 5, baseY = box.minY + 1, baseZ = box.minZ + 2; SGBaseTE te = (SGBaseTE)world.getTileEntity(new BlockPos(baseX, baseY, baseZ)); - if (te != null) - te.hasChevronUpgrade = true; -// else -// System.out.printf("FeatureUnderDesertPyramid.addComponentParts: No tile entity at (%d,%d,%d)\n", -// baseX, baseY, baseZ); + if (te != null) { + if (generateChevronUpgrade) { + te.hasChevronUpgrade = true; + } + + // Set sandstone base so Stargate doesn't appear to float. + ItemStack sandStoneSlab = new ItemStack(Blocks.STONE_SLAB, 1, BlockStoneSlab.EnumType.SAND.getMetadata()); + te.getInventory().setInventorySlotContents(0, sandStoneSlab.copy()); + te.getInventory().setInventorySlotContents(1, sandStoneSlab.copy()); + te.getInventory().setInventorySlotContents(2, sandStoneSlab.copy()); + te.getInventory().setInventorySlotContents(3, sandStoneSlab.copy()); + te.getInventory().setInventorySlotContents(4, sandStoneSlab.copy()); + } // Controller setBlockState(world, dhd, 5, 1, 7, clip); - return true; - } -// @Override -// protected void setBlockState(World worldIn, IBlockState blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn) { -// System.out.printf("SGCraft: FeatureUnderDesertPyramid.setBlockState: %s at (%s, %s, %s)\n", -// blockstateIn, this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); -// super.setBlockState(worldIn, blockstateIn, x, y, z, boundingboxIn); -// } + int chestX = box.minX + 8, chestY = box.minY + 1, chestZ = box.minZ + 2; + BlockPos chestPos = new BlockPos(chestX, chestY, chestZ); + if (FeatureGeneration.spawnTokra && pass == 0) { // pass = 0 prevents more than 1 entity from spawning. + EntityVillager entityvillager = new EntityVillager(world); + entityvillager.setLocationAndAngles((double)chestX + 0.5D, (double)chestY + 2, (double)chestZ + 0.5D, 0.0F, 0.0F); + entityvillager.setProfession(VillagerRegistry.getId(SGCraft.tokraProfession)); + entityvillager.finalizeMobSpawn(world.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null, false); + world.spawnEntity(entityvillager); + } + + pass++; // Reminder: this entire method is called 4 times during world generation. + + + return true; + } } diff --git a/src/mod/gcewing/sg/ISGBlock.java b/src/mod/gcewing/sg/ISGBlock.java index bde1cf71..2d052dc8 100644 --- a/src/mod/gcewing/sg/ISGBlock.java +++ b/src/mod/gcewing/sg/ISGBlock.java @@ -6,7 +6,6 @@ package gcewing.sg; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; diff --git a/src/mod/gcewing/sg/IrisRenderer.java b/src/mod/gcewing/sg/IrisRenderer.java index 312d1adf..206e6f49 100644 --- a/src/mod/gcewing/sg/IrisRenderer.java +++ b/src/mod/gcewing/sg/IrisRenderer.java @@ -6,20 +6,10 @@ package gcewing.sg; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.entity.*; -import net.minecraft.entity.*; -import net.minecraft.tileentity.*; -import net.minecraft.world.*; -import net.minecraft.util.*; - -public class IrisRenderer extends BaseEntityRenderer { +public class IrisRenderer extends BaseEntityRenderer { @Override - public void renderEntity(IrisEntity entity, double x, double y, double z, float yaw, float dt) { + public void renderEntity(EntityStargateIris entity, double x, double y, double z, float yaw, float dt) { } } diff --git a/src/mod/gcewing/sg/IrisState.java b/src/mod/gcewing/sg/IrisState.java index 33c63833..eb08d2ce 100644 --- a/src/mod/gcewing/sg/IrisState.java +++ b/src/mod/gcewing/sg/IrisState.java @@ -1,23 +1,5 @@ -//------------------------------------------------------------------------------------------------ -// -// SG Craft - Iris states -// -//------------------------------------------------------------------------------------------------ - package gcewing.sg; public enum IrisState { - Open, Closing, Closed, Opening; - - static IrisState[] VALUES = values(); - - public static IrisState valueOf(int i) { - try { - return VALUES[i]; - } - catch (IndexOutOfBoundsException e) { - return Open; - } - } - -}; + Open, Closing, Closed, Opening +} diff --git a/src/mod/gcewing/sg/LoopingSoundSource.java b/src/mod/gcewing/sg/LoopingSoundSource.java new file mode 100644 index 00000000..0e63f43a --- /dev/null +++ b/src/mod/gcewing/sg/LoopingSoundSource.java @@ -0,0 +1,10 @@ +package gcewing.sg; + +import net.minecraft.util.SoundEvent; + +public interface LoopingSoundSource extends SoundSource { + @Override + default boolean isSoundRepeatable(SoundEvent sound) { + return true; + } +} diff --git a/src/mod/gcewing/sg/NaquadahBlock.java b/src/mod/gcewing/sg/NaquadahBlock.java index 157ab5d4..490e45d7 100644 --- a/src/mod/gcewing/sg/NaquadahBlock.java +++ b/src/mod/gcewing/sg/NaquadahBlock.java @@ -15,8 +15,8 @@ public class NaquadahBlock extends Block { public NaquadahBlock() { super(Material.ROCK, MapColor.GREEN); - setHardness(5.0F); - setResistance(10.0F); + setHardness(5F); + setResistance(10F); setSoundType(SoundType.METAL); } diff --git a/src/mod/gcewing/sg/NaquadahOreBlock.java b/src/mod/gcewing/sg/NaquadahOreBlock.java index 16dceec4..c04934a1 100644 --- a/src/mod/gcewing/sg/NaquadahOreBlock.java +++ b/src/mod/gcewing/sg/NaquadahOreBlock.java @@ -12,9 +12,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.*; import net.minecraft.item.*; -import net.minecraft.util.math.*; - -import net.minecraftforge.common.*; public class NaquadahOreBlock extends BlockOre { @@ -22,8 +19,8 @@ public class NaquadahOreBlock extends BlockOre { public NaquadahOreBlock() { super(); - setHardness(5.0F); - setResistance(10.0F); + setHardness(5F); + setResistance(10F); setSoundType(SoundType.STONE); setHarvestLevel("pickaxe", 3); setCreativeTab(CreativeTabs.BUILDING_BLOCKS); diff --git a/src/mod/gcewing/sg/NaquadahOreWorldGen.java b/src/mod/gcewing/sg/NaquadahOreWorldGen.java index b941e0b1..71ae022f 100644 --- a/src/mod/gcewing/sg/NaquadahOreWorldGen.java +++ b/src/mod/gcewing/sg/NaquadahOreWorldGen.java @@ -14,7 +14,7 @@ import net.minecraft.util.math.*; import net.minecraft.world.*; import net.minecraft.world.chunk.*; - +import net.minecraft.world.gen.IChunkGenerator; import net.minecraftforge.fml.common.*; public class NaquadahOreWorldGen implements IWorldGenerator { @@ -55,15 +55,15 @@ public void generate(Random random, int chunkX, int chunkZ, World world, this.world = world; x0 = chunkX * 16; z0 = chunkZ * 16; - chunk = world.getChunkFromChunkCoords(chunkX, chunkZ); + chunk = world.getChunk(chunkX, chunkZ); generateChunk(); } public void regenerate(Chunk chunk) { this.chunk = chunk; world = chunk.getWorld(); - int chunkX = chunk.xPosition; - int chunkZ = chunk.zPosition; + int chunkX = chunk.x; + int chunkZ = chunk.z; long worldSeed = world.getSeed(); random = new Random(worldSeed); long xSeed = random.nextLong() >> 2 + 1L; diff --git a/src/mod/gcewing/sg/PowerBlock.java b/src/mod/gcewing/sg/PowerBlock.java index 111f8e0c..748f99d3 100644 --- a/src/mod/gcewing/sg/PowerBlock.java +++ b/src/mod/gcewing/sg/PowerBlock.java @@ -9,9 +9,7 @@ import java.util.*; import net.minecraft.block.*; -import net.minecraft.block.material.*; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.texture.*; import net.minecraft.entity.*; import net.minecraft.entity.player.*; import net.minecraft.item.*; @@ -19,7 +17,6 @@ import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.util.*; public class PowerBlock extends BaseBlock { @@ -28,21 +25,16 @@ public class PowerBlock extends BaseBlock { public PowerBlock(Class teClass) { super(SGCraft.machineMaterial, teClass); setHardness(1.5F); - setResistance(10.0F); + setResistance(10F); setSoundType(SoundType.METAL); setHarvestLevel("pickaxe", 0); } - + @Override public boolean shouldCheckWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { return true; } -// @Override -// public String getRendererClassName() { -// return "BaseBlockRenderer"; -// } - @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { lastRemovedTE = getTileEntity(world, pos); @@ -51,12 +43,12 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float cx, float cy, float cz) + EnumHand hand, EnumFacing side, float cx, float cy, float cz) { SGCraft.mod.openGui(player, SGGui.PowerUnit, world, pos); return true; } - + @Override public ArrayList getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { ArrayList ret = new ArrayList(); @@ -72,7 +64,7 @@ public ArrayList getDrops(IBlockAccess world, BlockPos pos, IBlockSta ret.add(stack); return ret; } - + @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) @@ -82,5 +74,4 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity if (te != null && nbt != null) te.readContentsFromNBT(nbt); } - } diff --git a/src/mod/gcewing/sg/PowerContainer.java b/src/mod/gcewing/sg/PowerContainer.java index 2c2be042..24c11ea0 100644 --- a/src/mod/gcewing/sg/PowerContainer.java +++ b/src/mod/gcewing/sg/PowerContainer.java @@ -7,9 +7,7 @@ package gcewing.sg; import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; import net.minecraft.tileentity.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; diff --git a/src/mod/gcewing/sg/PowerItem.java b/src/mod/gcewing/sg/PowerItem.java index 96b33781..c73db8ab 100644 --- a/src/mod/gcewing/sg/PowerItem.java +++ b/src/mod/gcewing/sg/PowerItem.java @@ -9,29 +9,29 @@ import java.util.*; import net.minecraft.block.*; -import net.minecraft.entity.player.*; +import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.*; import net.minecraft.nbt.*; -import net.minecraft.util.*; +import net.minecraft.world.World; + +import javax.annotation.Nullable; public class PowerItem extends ItemBlock { String unitName; double maxEnergy; - public PowerItem(Block block, String unitName, double maxEnergy) { + public PowerItem(Block block, String unitName) { super(block); this.unitName = unitName; - this.maxEnergy = maxEnergy; } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { + public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt != null) { double eu = nbt.getDouble("energyBuffer"); - list.add(String.format("%.0f %s / %.0f", eu, unitName, maxEnergy)); + list.add(String.format("%F %s / %F", eu, unitName, maxEnergy)); } } - } diff --git a/src/mod/gcewing/sg/PowerScreen.java b/src/mod/gcewing/sg/PowerScreen.java index 678a9d91..3d95e61b 100644 --- a/src/mod/gcewing/sg/PowerScreen.java +++ b/src/mod/gcewing/sg/PowerScreen.java @@ -6,24 +6,30 @@ package gcewing.sg; -import org.lwjgl.input.*; -import org.lwjgl.opengl.*; -import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL11.GL_BLEND; +import static org.lwjgl.opengl.GL11.GL_CURRENT_BIT; +import static org.lwjgl.opengl.GL11.GL_ENABLE_BIT; +import static org.lwjgl.opengl.GL11.GL_ONE; +import static org.lwjgl.opengl.GL11.GL_ZERO; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL11.glPopAttrib; +import static org.lwjgl.opengl.GL11.glPushAttrib; -import net.minecraft.client.gui.*; -import net.minecraft.entity.player.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.text.DecimalFormat; public class PowerScreen extends BaseGui.Screen { - final static int guiWidth = 128; + final static int guiWidth = 148; final static int guiHeight = 64; - //final static String screenTitle = "IC2 SGPU"; + private final DecimalFormat dFormat = new DecimalFormat("###,###,###"); + + private PowerTE te; - PowerTE te; - public static PowerScreen create(EntityPlayer player, World world, BlockPos pos) { PowerContainer container = PowerContainer.create(player, world, pos); if (container != null) @@ -31,36 +37,41 @@ public static PowerScreen create(EntityPlayer player, World world, BlockPos pos) else return null; } - - public PowerScreen(PowerContainer container) { + + private PowerScreen(PowerContainer container) { super(container, guiWidth, guiHeight); this.te = container.te; } - + @Override public boolean doesGuiPauseGame() { return false; } protected void drawBackgroundLayer() { - bindTexture(SGCraft.mod.resourceLocation("textures/gui/power_gui.png"), 128, 64); + bindTexture(SGCraft.mod.resourceLocation("textures/gui/power_gui.png"), 148, 64); drawTexturedRect(0, 0, guiWidth, guiHeight, 0, 0); - int cx = xSize / 2; + int cx = this.xSize / 2; drawCenteredString(te.getScreenTitle(), cx, 8); - drawRightAlignedString(te.getUnitName(), 72, 28); - drawRightAlignedString(String.format("%.0f", te.energyBuffer), 121, 28); - drawRightAlignedString("Max", 72, 42); - drawRightAlignedString(String.format("%.0f", te.energyMax), 121, 42); - drawPowerGauge(); + drawRightAlignedString(te.getUnitName() + ":", 90, 23); + drawRightAlignedString(this.dFormat.format(Math.min(Math.max(this.te.energyBuffer, 0), this.te.energyMax)), 141, 23); + if (SGCraft.displayGuiPowerDebug) { + drawRightAlignedString("SGPU:", 90, 34); + drawRightAlignedString(this.dFormat.format(Math.min(Math.max(this.te.energyBuffer / this.te.energyPerSGEnergyUnit, 0), this.te.energyMax)), 141, 34); + } + drawRightAlignedString("Max:", 90, 45); + drawRightAlignedString(this.dFormat.format(this.te.energyMax), 141, 45); + drawPowerGauge(); } - - void drawPowerGauge() { + + private void drawPowerGauge() { gSave(); glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); setColor(1, 0, 0); - drawRect(19, 27, 25 * te.energyBuffer / te.energyMax, 10); + drawRect(23, 28, 29 * this.te.energyBuffer / this.te.energyMax, 10); + glBlendFunc(GL_ONE, GL_ZERO); glPopAttrib(); gRestore(); } diff --git a/src/mod/gcewing/sg/PowerTE.java b/src/mod/gcewing/sg/PowerTE.java index d050fb6d..d69415f1 100644 --- a/src/mod/gcewing/sg/PowerTE.java +++ b/src/mod/gcewing/sg/PowerTE.java @@ -7,15 +7,11 @@ package gcewing.sg; import net.minecraft.nbt.*; -import net.minecraft.tileentity.*; -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; // import ic2.api.energy.event.*; [IC2] // import ic2.api.energy.tile.*; import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.Utils.*; public abstract class PowerTE extends BaseTileEntity implements ISGEnergySource { @@ -23,29 +19,35 @@ public abstract class PowerTE extends BaseTileEntity implements ISGEnergySource public double energyBuffer = 0; public double energyMax; - double energyPerSGEnergyUnit; - + public double energyPerSGEnergyUnit; + private int update = 0; + public PowerTE(double energyMax, double energyPerSGEnergyUnit) { this.energyMax = energyMax; this.energyPerSGEnergyUnit = energyPerSGEnergyUnit; } - + public abstract String getScreenTitle(); + public abstract String getUnitName(); - + @Override public void readContentsFromNBT(NBTTagCompound nbt) { super.readContentsFromNBT(nbt); - energyBuffer = nbt.getDouble("energyBuffer"); + if (nbt.hasKey("energyBuffer")) { + energyBuffer = nbt.getDouble("energyBuffer"); + energyMax = nbt.getDouble("energyMax"); + } } - + public void writeContentsToNBT(NBTTagCompound nbt) { super.writeContentsToNBT(nbt); nbt.setDouble("energyBuffer", energyBuffer); + nbt.setDouble("energyMax", energyMax); } - + //------------------------- ISGEnergySource ------------------------- - + @Override public double availableEnergy() { double available = energyBuffer / energyPerSGEnergyUnit; @@ -53,15 +55,22 @@ public double availableEnergy() { System.out.printf("SGCraft: PowerTE: %s SGU available\n", available); return available; } - + + public double totalAvailableEnergy() { + return energyBuffer; + } + public double drawEnergy(double request) { + // 10000 / 20 double available = energyBuffer / energyPerSGEnergyUnit; double supply = min(request, available); energyBuffer -= supply * energyPerSGEnergyUnit; - markChanged(); + if (update++ > 10) { // We dont' need 20 packets per second to the client.... + markChanged(); + update = 0; + } if(debugOutput) System.out.printf("SGCraft: PowerTE: Supplying %s SGU of %s requested\n", supply, request); return supply; } - } diff --git a/src/mod/gcewing/sg/RFIntegration.java b/src/mod/gcewing/sg/RFIntegration.java deleted file mode 100644 index ccddb752..00000000 --- a/src/mod/gcewing/sg/RFIntegration.java +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------------------------ -// -// SG Craft - RF Power Integration Module -// -//------------------------------------------------------------------------------------------------ - -package gcewing.sg.rf; - -import net.minecraft.block.*; -import net.minecraft.init.*; -import net.minecraft.item.*; -import net.minecraftforge.fml.common.registry.GameRegistry; -import static net.minecraftforge.fml.common.Loader.*; -import gcewing.sg.*; - -public class RFIntegration extends BaseSubsystem { - - @Override - public void registerBlocks() { - mod.rfPowerUnit = mod.newBlock("rfPowerUnit", RFPowerBlock.class); //[RF] - } - - @Override - public void registerRecipes() { - if (isModLoaded("ThermalExpansion")) - addThermalExpansionPowerBlockRecipe(); - else - addGenericPowerBlockRecipe(); - } - - protected void addThermalExpansionPowerBlockRecipe() { - Item frame = GameRegistry.findItem("ThermalExpansion", "Frame"); - Item coil = GameRegistry.findItem("ThermalExpansion", "material"); - ItemStack hardenedEnergyFrame = new ItemStack(frame, 1, 4); - ItemStack receptionCoil = new ItemStack(coil, 1, 1); - ItemStack transmissionCoil = new ItemStack(coil, 1, 2); - mod.newRecipe(mod.rfPowerUnit, 1, "ttt", "hrh", "ici", - 't', transmissionCoil, 'h', hardenedEnergyFrame, 'r', receptionCoil, - 'i', "ingotInvar", 'c', "ingotCopper"); - } - - protected void addGenericPowerBlockRecipe() { - mod.newRecipe(mod.rfPowerUnit, 1, "cgc", "gIg", "crc", - 'c', mod.ic2Capacitor, 'g', "ingotGold", - 'I', "blockIron", 'r', Items.REDSTONE); - } - -} diff --git a/src/mod/gcewing/sg/SGAddressing.java b/src/mod/gcewing/sg/SGAddressing.java index 05b771a2..e07ddf3a 100644 --- a/src/mod/gcewing/sg/SGAddressing.java +++ b/src/mod/gcewing/sg/SGAddressing.java @@ -26,12 +26,11 @@ package gcewing.sg; -import net.minecraft.tileentity.*; -import net.minecraft.world.*; -import net.minecraft.world.chunk.*; -import net.minecraft.server.*; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.*; +import javax.annotation.Nullable; public class SGAddressing { @@ -40,9 +39,6 @@ public class SGAddressing { static class AddressingError extends Exception { AddressingError(String s) {super(s);} } - static AddressingError malformedAddressError = new AddressingError("Malformed stargate address"); - static AddressingError coordRangeError = new AddressingError("Coordinates out of stargate range"); - static AddressingError dimensionRangeError = new AddressingError("Dimension not reachable by stargate"); public final static String symbolChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; public final static int numSymbols = symbolChars.length(); @@ -103,7 +99,7 @@ protected static void validateAddress(String s) throws AddressingError { if ((l == numCoordSymbols || l == numCoordSymbols + numDimensionSymbols) && validSymbols(s)) return; - throw malformedAddressError; + throw new AddressingError("malformedAddress"); } public static String normalizeAddress(String address) { @@ -150,12 +146,12 @@ public static String addressForLocation(SGLocation loc) throws AddressingError { int chunkx = loc.pos.getX() >> 4; int chunkz = loc.pos.getZ() >> 4; if (!inCoordRange(chunkx) || !inCoordRange(chunkz)) - throw coordRangeError; + throw new AddressingError("targetOutOfRange"); // if (!inDimensionRange(loc.dimension)) // throw dimensionRangeError; Integer di = SGDimensionMap.indexForDimension(loc.dimension); if (di > maxDimensionIndex) - throw dimensionRangeError; + throw new AddressingError("dimensionTooFar"); long c = interleaveCoords(hash(chunkx - minCoord, pc, mc), hash(chunkz - minCoord, pc, mc)); // int d = hash(loc.dimension - minDimension, pd, md); int dp = permuteDimension(c, di); @@ -212,7 +208,7 @@ public static SGBaseTE findAddressedStargate(String address, World fromWorld) th protected static SGBaseTE getBaseTE(int chunkX, int chunkZ, int dimension) { World toWorld = getWorld(dimension); if (toWorld != null) { - Chunk chunk = toWorld.getChunkFromChunkCoords(chunkX, chunkZ); + Chunk chunk = toWorld.getChunk(chunkX, chunkZ); if (chunk != null) for (Object te : chunk.getTileEntityMap().values()) { if (te instanceof SGBaseTE) @@ -264,10 +260,9 @@ protected static int hash(int i, long f, long m) { System.out.printf("SGAddressing.hash(%s, %s, %s) = %s\n", i, f, m, h); return h; } - + + @Nullable public static WorldServer getWorld(int dimension) { -// MinecraftServer server = BaseUtils.getMinecraftServer(); -// return server.worldServerForDimension(dimension); return BaseUtils.getWorldForDimension(dimension); } diff --git a/src/mod/gcewing/sg/SGBaseBlock.java b/src/mod/gcewing/sg/SGBaseBlock.java index aa99911b..2ce96b3d 100644 --- a/src/mod/gcewing/sg/SGBaseBlock.java +++ b/src/mod/gcewing/sg/SGBaseBlock.java @@ -6,22 +6,16 @@ package gcewing.sg; -import java.util.*; - import net.minecraft.block.*; import net.minecraft.block.material.*; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.texture.*; import net.minecraft.creativetab.*; -import net.minecraft.entity.*; import net.minecraft.entity.player.*; import net.minecraft.init.*; import net.minecraft.item.*; import net.minecraft.world.*; import net.minecraft.util.*; import net.minecraft.util.math.*; -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; import gcewing.sg.BaseMod.*; @@ -40,7 +34,7 @@ public class SGBaseBlock extends SGBlock { {2, 1, 0, 1, 2}, }; - protected static String[] textures = {"stargateBlock", "stargateRing", "stargateBase_front"}; + protected static String[] textures = {"stargateblock", "stargatering", "stargatebase_front"}; protected static ModelSpec model = new ModelSpec("block/sg_base_block.smeg", textures); public static void configure(BaseConfiguration config) { @@ -56,7 +50,7 @@ public SGBaseBlock() { } @Override - public boolean canRenderInLayer(BlockRenderLayer layer) { + public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return true; // So that translucent camouflage blocks render correctly } @@ -97,9 +91,10 @@ public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos @Override public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player) { - return true; + return SGCraft.canHarvestSGBaseBlock; } + @Override public boolean isMerged(IBlockAccess world, BlockPos pos) { SGBaseTE te = getTileEntity(world, pos); return te != null && te.isMerged; @@ -125,7 +120,7 @@ public void onBlockAdded(World world, BlockPos pos, IBlockState state) { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float cx, float cy, float cz) + EnumHand hand, EnumFacing side, float cx, float cy, float cz) { String Side = world.isRemote ? "Client" : "Server"; SGBaseTE te = getTileEntity(world, pos); @@ -149,8 +144,8 @@ public boolean getWeakChanges(IBlockAccess world, BlockPos pos) { } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) { - System.out.printf("SGBaseBlock.neighborChanged: %s\n", pos); + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos from) { + //System.out.printf("SGBaseBlock.neighborChanged: %s\n", pos); neighbourChanged(world, pos); } @@ -216,7 +211,9 @@ int getRingBlockType(World world, BlockPos pos) { @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { unmerge(world, pos); - dropUpgrades(world, pos); + if (SGCraft.canHarvestSGBaseBlock) { + dropUpgrades(world, pos); + } super.breakBlock(world, pos, state); } diff --git a/src/mod/gcewing/sg/SGBaseContainer.java b/src/mod/gcewing/sg/SGBaseContainer.java index 49ce40aa..739104a1 100644 --- a/src/mod/gcewing/sg/SGBaseContainer.java +++ b/src/mod/gcewing/sg/SGBaseContainer.java @@ -8,7 +8,7 @@ import net.minecraft.entity.player.*; import net.minecraft.inventory.*; -import net.minecraft.util.*; +import net.minecraft.item.ItemStack; import net.minecraft.util.math.*; import net.minecraft.world.*; @@ -44,6 +44,14 @@ public SGBaseContainer(EntityPlayer player, SGBaseTE te) { void addCamouflageSlots() { addSlots(te, 0, te.numCamouflageSlots, 48, 104, 1, CamouflageSlot.class); } + + @Override + protected SlotRange transferSlotRange(int srcSlotIndex, ItemStack stack) { + SlotRange range = new SlotRange(); + range.firstSlot = 0; + range.numSlots = SGBaseTE.numCamouflageSlots; + return range; + } // void addFuelSlots() { // int b = SGBaseTE.firstFuelSlot; diff --git a/src/mod/gcewing/sg/SGBaseScreen.java b/src/mod/gcewing/sg/SGBaseScreen.java index ffb3f4ff..171f0e80 100644 --- a/src/mod/gcewing/sg/SGBaseScreen.java +++ b/src/mod/gcewing/sg/SGBaseScreen.java @@ -6,12 +6,7 @@ package gcewing.sg; -import org.lwjgl.input.*; -import org.lwjgl.opengl.*; - -import net.minecraft.client.gui.*; import net.minecraft.entity.player.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; @@ -27,10 +22,10 @@ public class SGBaseScreen extends SGScreen { static final int fuelGaugeU = 0; static final int fuelGaugeV = 208; - SGBaseTE te; - String address; - String formattedAddress; - boolean addressValid; + private SGBaseTE te; + private String address; + private String formattedAddress; + private boolean addressValid; public static SGBaseScreen create(EntityPlayer player, World world, BlockPos pos) { SGBaseTE te = SGBaseTE.at(world, pos); @@ -46,7 +41,9 @@ public SGBaseScreen(EntityPlayer player, SGBaseTE te) { getAddress(); if (addressValid) { //System.out.printf("SGBaseScreen: Copying address %s to clipboard\n", formattedAddress); - setClipboardString(formattedAddress); + if (SGCraft.saveAddressToClipboard) { + setClipboardString(formattedAddress); + } } } @@ -54,23 +51,7 @@ public SGBaseScreen(EntityPlayer player, SGBaseTE te) { public boolean doesGuiPauseGame() { return false; } - -// @Override -// protected void keyTyped(char c, int key) { -// if (key == Keyboard.KEY_ESCAPE) -// close(); -// else if (key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE) { -// int n = te.homeAddress.length(); -// if (n > 0) -// setAddress(te.homeAddress.substring(0, n - 1)); -// } -// else { -// String s = String.valueOf(c).toUpperCase(); -// if (SGBaseTE.isValidSymbolChar(s) && te.homeAddress.length() < 7) -// setAddress(te.homeAddress + s); -// } -// } - + @Override protected void drawBackgroundLayer() { bindTexture(SGCraft.mod.resourceLocation("textures/gui/sg_gui.png"), 256, 256); @@ -89,29 +70,7 @@ protected void drawBackgroundLayer() { if (this.te.numCamouflageSlots > 0) drawCenteredString("Base Camouflage", 92, 92); } - -// void drawFuelGauge() { -// //System.out.printf("SGBaseScreen.drawFuelGauge: energyInBuffer = %s, maxEnergyBuffer = %s\n", -// // te.energyInBuffer, te.maxEnergyBuffer); -// double level = fuelGaugeHeight * te.energyInBuffer / te.maxEnergyBuffer; -// if (level > fuelGaugeHeight) -// level = fuelGaugeHeight; -// //System.out.printf("SGBaseScreen.drawFuelGauge: level = %s\n", level); -// GL11.glEnable(GL11.GL_BLEND); -// drawTexturedRect(fuelGaugeX, fuelGaugeY + fuelGaugeHeight - level, -// fuelGaugeWidth, level, fuelGaugeU, fuelGaugeV); -// GL11.glDisable(GL11.GL_BLEND); -// } - -// String getAddress() { -// try { -// return te.getHomeAddress(); -// } -// catch (SGAddressing.AddressingError e) { -// return e.getMessage(); -// } -// } - + void getAddress() { if (te.homeAddress != null) { address = te.homeAddress; @@ -124,5 +83,4 @@ void getAddress() { addressValid = false; } } - } diff --git a/src/mod/gcewing/sg/SGBaseTE.java b/src/mod/gcewing/sg/SGBaseTE.java index f92e6cdc..3be8c77d 100644 --- a/src/mod/gcewing/sg/SGBaseTE.java +++ b/src/mod/gcewing/sg/SGBaseTE.java @@ -6,47 +6,67 @@ package gcewing.sg; -import java.util.*; -import java.lang.reflect.Method; -import org.apache.logging.log4j.*; -import io.netty.channel.*; - -import net.minecraft.block.*; -import net.minecraft.block.state.*; -import net.minecraft.entity.*; -import net.minecraft.entity.player.*; +import gcewing.sg.oc.OCIntegration; +import gcewing.sg.oc.OCWirelessEndpoint; +import io.netty.channel.ChannelFutureListener; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityFishHook; -import net.minecraft.inventory.*; -import net.minecraft.item.*; -import net.minecraft.nbt.*; -import net.minecraft.network.*; -import net.minecraft.network.play.server.*; -import net.minecraft.potion.*; -import net.minecraft.server.*; -import net.minecraft.server.management.*; -import net.minecraft.tileentity.*; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SPacketEntityEffect; +import net.minecraft.network.play.server.SPacketRespawn; +import net.minecraft.network.play.server.SPacketSetExperience; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.PlayerList; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; -import net.minecraft.util.math.*; -import net.minecraft.util.text.*; -import net.minecraft.world.*; -import net.minecraft.world.chunk.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.DimensionType; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.ChunkProviderServer; - -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; -import net.minecraftforge.common.network.*; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.network.ForgeMessage; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.network.*; +import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; +import net.minecraftforge.fml.common.network.FMLOutboundHandler; +import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.relauncher.Side; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; -import gcewing.sg.SGAddressing.AddressingError; -import gcewing.sg.oc.OCWirelessEndpoint; //[OC] -import static gcewing.sg.BaseBlockUtils.*; -import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.Utils.*; +import static gcewing.sg.BaseBlockUtils.getWorldTileEntity; +import static gcewing.sg.BaseUtils.max; +import static gcewing.sg.BaseUtils.min; -public class SGBaseTE extends BaseTileInventory implements ITickable { +public class SGBaseTE extends BaseTileInventory implements ITickable, LoopingSoundSource { static boolean debugState = false; static boolean debugEnergyUse = false; @@ -54,27 +74,39 @@ public class SGBaseTE extends BaseTileInventory implements ITickable { static boolean debugTransientDamage = false; static boolean debugTeleport = false; - static SoundEvent sound(String name) { - return new SoundEvent(new ResourceLocation(name)); - } - static SoundEvent - abortSound, - openSound, - closeSound, + dialFailSound, + connectSound, + disconnectSound, irisOpenSound, irisCloseSound, irisHitSound, - diallingSound; - + dhdPressSound, + dhdDialSound, + chevronOutgoingSound, + chevronIncomingSound, + lockOutgoingSound, + lockIncomingSound, + gateRollSound, + eventHorizonSound, + teleportSound; + public static void registerSounds(SGCraft mod) { - abortSound = mod.newSound("sg_abort"); - openSound = mod.newSound("sg_open"); - closeSound = mod.newSound("sg_close"); + dialFailSound = mod.newSound("dial_fail"); + connectSound = mod.newSound("gate_open"); + disconnectSound = mod.newSound("gate_close"); irisOpenSound = mod.newSound("iris_open"); irisCloseSound = mod.newSound("iris_close"); irisHitSound = mod.newSound("iris_hit"); - diallingSound = mod.newSound("sg_dial7"); + dhdPressSound = mod.newSound("dhd_press"); + dhdDialSound = mod.newSound("dhd_dial"); + chevronOutgoingSound = mod.newSound("chevron_outgoing"); + chevronIncomingSound = mod.newSound("chevron_incoming"); + lockOutgoingSound = mod.newSound("lock_outgoing"); + lockIncomingSound = mod.newSound("lock_incoming"); + gateRollSound = mod.newSound("gate_roll"); + eventHorizonSound = mod.newSound("event_horizon"); + teleportSound = mod.newSound("teleport"); } public final static String symbolChars = SGAddressing.symbolChars; @@ -84,30 +116,31 @@ public static void registerSounds(SGCraft mod) { public final static double irisThickness = 0.2; //0.1; public final static DamageSource irisDamageSource = new DamageSource("sgcraft:iris"); public final static float irisDamageAmount = 1000000; - - final static int diallingTime = 40; // ticks + public final static double ringRotationSpeed = 2.0; + final static int interDiallingTime = 10; // ticks + final static int syncAwaitTime = 20; // ticks final static int transientDuration = 20; // ticks - final static int disconnectTime = 30; // ticks - + final static int disconnectTime = 40; // ticks + final static double openingTransientIntensity = 1.3; final static double openingTransientRandomness = 0.25; final static double closingTransientRandomness = 0.25; final static double transientDamageRate = 50; - - final static int maxIrisPhase = 60; // 3 seconds - + + final static int maxIrisPhase = 70; // ticks + final static int firstCamouflageSlot = 0; final static int numCamouflageSlots = 5; final static int numInventorySlots = numCamouflageSlots; - + static float defaultChevronAngle = 40f; static float chevronAngles[][] = { - // 0 1 2 <-- Base camouflage level - { 45f, 45f, 40f }, // 7 chevrons - { 36f, 33f, 30f } // 9 chevrons + // 0 1 2 <-- Base camouflage level + { 45f, 45f, 40f }, // 7 chevrons + { 36f, 33f, 30f } // 9 chevrons }; - + // Configuration options static double maxEnergyBuffer = 1000; static double energyPerFuelItem = 96000; @@ -116,25 +149,26 @@ public static void registerSounds(SGCraft mod) { static int gateOpeningsPerFuelItem = 24; static int minutesOpenPerFuelItem = 80; static int secondsToStayOpen = 5 * 60; - static boolean oneWayTravel = false; + static boolean oneWayTravel = true; static boolean closeFromEitherEnd = true; static int chunkLoadingRange = 1; static boolean logStargateEvents = false; static boolean preserveInventory = false; - static float soundVolume = 1.0F; + static float soundVolume = 1F; static boolean variableChevronPositions = true; - + //static boolean immediateDHDGateDial = true; + public static double energyToOpen; static double energyUsePerTick; static int ticksToStayOpen; public static boolean transparency = true; - + static Random random = new Random(); static DamageSource transientDamage = new DamageSource("sgcraft:transient"); - + public boolean isMerged; public SGState state = SGState.Idle; - public double ringAngle, lastRingAngle, targetRingAngle; // degrees + public double startRingAngle, ringAngle, lastRingAngle, targetRingAngle; // degrees public int numEngagedChevrons; public String dialledAddress = ""; public boolean isLinkedToController; @@ -147,24 +181,21 @@ public static void registerSounds(SGCraft mod) { public OCWirelessEndpoint ocWirelessEndpoint; //[OC] SGLocation connectedLocation; - boolean isInitiator; - int timeout; - double energyInBuffer; - double distanceFactor; // all energy use is multiplied by this - boolean redstoneInput; - boolean loaded; - public String homeAddress; - public String addressError; - -// public static final int firstFuelSlot = 0; -// public static final int numFuelSlots = 4; -// public static final int firstUpgradeSlot = 4; -// public static final int numUpgradeSlots = 0; + boolean isInitiator, redstoneInput, loaded; + int timeout, maxTimeout; + double energyInBuffer, distanceFactor; // all energy use is multiplied by this + public String homeAddress, addressError; + private int updated = 0; + + // public static final int firstFuelSlot = 0; + // public static final int numFuelSlots = 4; + // public static final int firstUpgradeSlot = 4; + // public static final int numUpgradeSlots = 0; IInventory inventory = new InventoryBasic("Stargate", false, numInventorySlots); double ehGrid[][][]; - + public static void configure(BaseConfiguration cfg) { energyPerFuelItem = cfg.getDouble("stargate", "energyPerFuelItem", energyPerFuelItem); gateOpeningsPerFuelItem = cfg.getInteger("stargate", "gateOpeningsPerFuelItem", gateOpeningsPerFuelItem); @@ -193,21 +224,23 @@ public static void configure(BaseConfiguration cfg) { preserveInventory = cfg.getBoolean("iris", "preserveInventory", preserveInventory); soundVolume = (float)cfg.getDouble("stargate", "soundVolume", soundVolume); variableChevronPositions = cfg.getBoolean("stargate", "variableChevronPositions", variableChevronPositions); + //immediateDHDGateDial = cfg.getBoolean("stargate", "immediateDHDDial", immediateDHDGateDial); } - + public static SGBaseTE get(IBlockAccess world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); - if (te instanceof SGBaseTE) + if (te instanceof SGBaseTE) { return (SGBaseTE)te; - else if (te instanceof SGRingTE) + } else if (te instanceof SGRingTE) { return ((SGRingTE)te).getBaseTE(); - else + } else { return null; + } } - + @Override public String toString() { - return String.format("SGBaseTE(%s,%s)", pos, worldObj.provider.getDimension()); + return String.format("SGBaseTE(%s,%s)", pos, world.provider.getDimension()); } @Override @@ -224,42 +257,74 @@ public double getMaxRenderDistanceSquared() { @Override public void onAddedToWorld() { if (SGBaseBlock.debugMerge) - System.out.printf("SGBaseTE.onAddedToWorld\n"); + System.out.print("SGBaseTE.onAddedToWorld\n"); updateChunkLoadingStatus(); } - + + @Override + public float getSoundVolume(SoundEvent sound) { + return soundVolume; + } + + @Override + public World getSoundWorld() { + return this.world; + } + + @Override + public BlockPos getSoundPos() { + return this.pos; + } + + @Override + public boolean isSoundActive(SoundEvent sound) { + if (this.isInvalid() || !this.world.isBlockLoaded(this.pos) || this.world.getTileEntity(this.pos) != this) { + return false; + } + if (sound == gateRollSound) { + return state == SGState.Dialing; + } else if (sound == irisOpenSound) { + return irisState == IrisState.Opening; + } else if (sound == irisCloseSound) { + return irisState == IrisState.Closing; + } else if (sound == eventHorizonSound) { + return state == SGState.Connected; + } else { + return false; + } + } + void updateChunkLoadingStatus() { - if (state != SGState.Idle) { + if (state != SGState.Idle || state == SGState.AttemptToDial) { int n = chunkLoadingRange; - if (n >= 0) + if (n >= 0) { SGCraft.chunkManager.setForcedChunkRange(this, -n, -n, n, n); - } - else + } + } else { SGCraft.chunkManager.clearForcedChunkRange(this); + } } public static SGBaseTE at(IBlockAccess world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); - if (te instanceof SGBaseTE) - return (SGBaseTE)te; - else - return null; + return te instanceof SGBaseTE ? (SGBaseTE) te : null; } - + public static SGBaseTE at(SGLocation loc) { if (loc != null) { World world = SGAddressing.getWorld(loc.dimension); - if (world != null) + if (world != null) { return SGBaseTE.at(world, loc.pos); + } } return null; } - + public static SGBaseTE at(IBlockAccess world, NBTTagCompound nbt) { BlockPos pos = new BlockPos(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z")); return SGBaseTE.at(world, pos); } - + void setMerged(boolean state) { if (isMerged != state) { isMerged = state; @@ -270,35 +335,37 @@ void setMerged(boolean state) { Logger log = LogManager.getLogger(); String action = isMerged ? "ADDED" : "REMOVED"; String name = getWorld().getWorldInfo().getWorldName(); - log.info(String.format("STARGATE %s %s %s %s", - action, name, pos, address)); + if (isMerged) { + this.homeAddress = address; + } + log.info(String.format("STARGATE %s %s %s %s", action, name, pos, address)); } } updateIrisEntity(); } } - + String tryToGetHomeAddress() { try { return getHomeAddress(); - } - catch (SGAddressing.AddressingError e) { + } catch (SGAddressing.AddressingError e) { return null; } } - public int dimension() { - if (worldObj != null) - return worldObj.provider.getDimension(); - else - return -999; + @Override + protected void setWorldCreate(World world) { + this.world = world; } - + @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); isMerged = nbt.getBoolean("isMerged"); - state = SGState.valueOf(nbt.getInteger("state")); + SGState oldState = state; + state = SGState.values()[nbt.getInteger("state")]; + ringAngle = nbt.getDouble("ringAngle"); + startRingAngle = nbt.getDouble("startRingAngle"); targetRingAngle = nbt.getDouble("targetRingAngle"); numEngagedChevrons = nbt.getInteger("numEngagedChevrons"); dialledAddress = nbt.getString("dialledAddress"); @@ -308,28 +375,27 @@ public void readFromNBT(NBTTagCompound nbt) { int z = nbt.getInteger("linkedZ"); linkedPos = new BlockPos(x, y, z); hasChevronUpgrade = nbt.getBoolean("hasChevronUpgrade"); - if (nbt.hasKey("connectedLocation")) + if (nbt.hasKey("connectedLocation")) { connectedLocation = new SGLocation(nbt.getCompoundTag("connectedLocation")); + } isInitiator = nbt.getBoolean("isInitiator"); timeout = nbt.getInteger("timeout"); - if (nbt.hasKey("energyInBuffer")) - energyInBuffer = nbt.getDouble("energyInBuffer"); - else - energyInBuffer = nbt.getInteger("fuelBuffer"); + maxTimeout = nbt.getInteger("maxTimeout"); + energyInBuffer = nbt.hasKey("energyInBuffer") ? nbt.getDouble("energyInBuffer") : nbt.getInteger("fuelBuffer"); distanceFactor = nbt.getDouble("distanceFactor"); hasIrisUpgrade = nbt.getBoolean("hasIrisUpgrade"); - irisState = IrisState.valueOf(nbt.getInteger("irisState")); + irisState = IrisState.values()[nbt.getInteger("irisState")]; irisPhase = nbt.getInteger("irisPhase"); redstoneInput = nbt.getBoolean("redstoneInput"); homeAddress = getStringOrNull(nbt, "address"); addressError = nbt.getString("addressError"); + if (oldState != state && state == SGState.Connected && world.isRemote) { + SGCraft.playSound(this, eventHorizonSound); + } } - + protected String getStringOrNull(NBTTagCompound nbt, String name) { - if (nbt.hasKey(name)) - return nbt.getString(name); - else - return null; + return nbt.hasKey(name) ? nbt.getString(name) : null; } @Override @@ -337,6 +403,8 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setBoolean("isMerged", isMerged); nbt.setInteger("state", state.ordinal()); + nbt.setDouble("ringAngle", ringAngle); + nbt.setDouble("startRingAngle", startRingAngle); nbt.setDouble("targetRingAngle", targetRingAngle); nbt.setInteger("numEngagedChevrons", numEngagedChevrons); //nbt.setString("homeAddress", homeAddress); @@ -350,6 +418,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setTag("connectedLocation", connectedLocation.toNBT()); nbt.setBoolean("isInitiator", isInitiator); nbt.setInteger("timeout", timeout); + nbt.setInteger("maxTimeout", maxTimeout); nbt.setDouble("energyInBuffer", energyInBuffer); nbt.setDouble("distanceFactor", distanceFactor); nbt.setBoolean("hasIrisUpgrade", hasIrisUpgrade); @@ -362,19 +431,15 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setString("addressError", addressError); return nbt; } - - public boolean isActive() { - return state != SGState.Idle && state != SGState.Disconnecting; - } - + static boolean isValidSymbolChar(String c) { return SGAddressing.isValidSymbolChar(c); } - + static char symbolToChar(int i) { return SGAddressing.symbolToChar(i); } - + static int charToSymbol(char c) { return SGAddressing.charToSymbol(c); } @@ -382,36 +447,37 @@ static int charToSymbol(char c) { static int charToSymbol(String c) { return SGAddressing.charToSymbol(c); } - + + public boolean isActive() { + return state != SGState.Idle && state != SGState.Disconnecting; + } + public EnumActionResult applyChevronUpgrade(ItemStack stack, EntityPlayer player) { - if (!getWorld().isRemote && !hasChevronUpgrade && stack.stackSize > 0) { + if (!getWorld().isRemote && !hasChevronUpgrade && stack.getCount() > 0) { //System.out.printf("SGBaseTE.applyChevronUpgrade: Installing chevron upgrade\n"); hasChevronUpgrade = true; - stack.stackSize -= 1; + stack.shrink(1); markChanged(); } return EnumActionResult.SUCCESS; } - + public EnumActionResult applyIrisUpgrade(ItemStack stack, EntityPlayer player) { - if (!getWorld().isRemote && !hasIrisUpgrade && stack.stackSize > 0) { + if (!getWorld().isRemote && !hasIrisUpgrade && stack.getCount() > 0) { //System.out.printf("SGBaseTE.applyIrisUpgrade: Installing iris upgrade\n"); hasIrisUpgrade = true; - stack.stackSize -= 1; + stack.shrink(1); markChanged(); updateIrisEntity(); } return EnumActionResult.SUCCESS; } - + public int getNumChevrons() { //if (upgradePresent(SGCraft.sgChevronUpgrade)) - if (hasChevronUpgrade) - return 9; - else - return 7; + return hasChevronUpgrade ? 9 : 7; } - + public boolean chevronIsEngaged(int i) { return i < numEngagedChevrons; } @@ -421,100 +487,95 @@ public float angleBetweenChevrons() { int c9 = getNumChevrons() > 7 ? 1 : 0; int bc = baseCornerCamouflage(); return chevronAngles[c9][bc]; - } - else + } else { return defaultChevronAngle; - } - -// boolean upgradePresent(Item item) { -// for (int i = firstUpgradeSlot; i < firstUpgradeSlot + numUpgradeSlots; i++) -// if (getItemInSlot(i) == item) -// return true; -// return false; -// } - - Item getItemInSlot(int slot) { - ItemStack stack = getStackInSlot(slot); - return stack != null ? stack.getItem() : null; + } } public String getHomeAddress() throws SGAddressing.AddressingError { return SGAddressing.addressForLocation(new SGLocation(this)); } - + public SGBaseBlock getBlock() { return (SGBaseBlock)getBlockType(); } - - public double interpolatedRingAngle(double t) { - return Utils.interpolateAngle(lastRingAngle, ringAngle, t); + + public double interpolatedRingAngle(double partialTicks) { + return isInitiator ? lastRingAngle + (ringAngle - lastRingAngle) * partialTicks : 0; } - + @Override public void update() { - if (worldObj.isRemote) + if (world.isRemote) { clientUpdate(); - else { + } else { serverUpdate(); checkForEntitiesInPortal(); } irisUpdate(); } - + @Override public void invalidate() { super.invalidate(); - if (!worldObj.isRemote && ocWirelessEndpoint != null) //[OC] + if (!world.isRemote && ocWirelessEndpoint != null) { //[OC] ocWirelessEndpoint.remove(); + } } - + String side() { - return worldObj.isRemote ? "Client" : "Server"; + return world.isRemote ? "Client" : "Server"; } - + void enterState(SGState newState, int newTimeout) { if (debugState) - System.out.printf("SGBaseTE: at %s in dimension %s entering state %s with timeout %s\n", - pos, worldObj.provider.getDimension(), newState, newTimeout); + System.out.printf("SGBaseTE: at %s in dimension %s entering state %s with timeout %s\n", + pos, world.provider.getDimension(), newState, newTimeout); SGState oldState = state; state = newState; + startRingAngle = ringAngle; + maxTimeout = newTimeout; timeout = newTimeout; markChanged(); if ((oldState == SGState.Idle) != (newState == SGState.Idle)) { updateChunkLoadingStatus(); - worldObj.notifyNeighborsOfStateChange(pos, getBlockType()); + world.notifyNeighborsOfStateChange(pos, getBlockType(), true); + //Update: may not need observer update here. } String oldDesc = sgStateDescription(oldState); String newDesc = sgStateDescription(newState); if (!oldDesc.equals(newDesc)) postEvent("sgStargateStateChange", newDesc, oldDesc); } - + public boolean isConnected() { - return state == SGState.Transient || state == SGState.Connected || state == SGState.Disconnecting; + return state == SGState.SyncAwait + || state == SGState.Transient + || state == SGState.Connected + || state == SGState.Disconnecting; } - + DHDTE getLinkedControllerTE() { //System.out.printf("SGBaseTE.getLinkedControllerTE: isLinkedToController = %s, linkedPos = %s\n", // isLinkedToController, linkedPos); if (isLinkedToController) { - TileEntity cte = worldObj.getTileEntity(linkedPos); + TileEntity cte = world.getTileEntity(linkedPos); if (cte instanceof DHDTE) return (DHDTE)cte; } return null; } - + void checkForLink() { int rangeXY = max(DHDTE.linkRangeX, DHDTE.linkRangeY); int rangeZ = DHDTE.linkRangeZ; if (SGBaseBlock.debugMerge) System.out.printf("SGBaseTE.checkForLink: in range +/-(%d,%d,%d) of %s\n", - rangeXY, rangeZ, rangeXY, pos); + rangeXY, rangeZ, rangeXY, pos); for (int i = -rangeXY; i <= rangeXY; i++) for (int j = -rangeZ; j <= rangeZ; j++) for (int k = -rangeXY; k <= rangeXY; k++) { - TileEntity te = worldObj.getTileEntity(pos.add(i, j, k)); + TileEntity te = world.getTileEntity(pos.add(i, j, k)); if (te instanceof DHDTE) ((DHDTE)te).checkForLink(); } @@ -528,7 +589,7 @@ public void unlinkFromController() { clearLinkToController(); } } - + public void clearLinkToController() { if (SGBaseBlock.debugMerge) System.out.printf("SGBaseTE: Unlinking stargate at %d from controller\n", pos); @@ -537,76 +598,93 @@ public void clearLinkToController() { } //------------------------------------ Server -------------------------------------------- - + public void connectOrDisconnect(String address, EntityPlayer player) { + boolean immediate = false; if (debugConnect) - System.out.printf("SGBaseTE: %s: connectOrDisconnect('%s') in state %s by %s\n", - side(), address, state, player); - if (address.length() > 0) - connect(address, player); - else - attemptToDisconnect(player); + System.out.printf("SGBaseTE: %s: connectOrDisconnect('%s') in state %s by %s\n", side(), address, state, player); + if (address.length() > 0) { + DHDTE te = getLinkedControllerTE(); + if (te != null) { + if (connect(address, player, immediate) != null) { + numEngagedChevrons = 0; + markChanged(); + } + } + } else { + disconnect(player); + } } - - public String attemptToDisconnect(EntityPlayer player) { + + public String disconnect(EntityPlayer player) { boolean canDisconnect = disconnectionAllowed(); SGBaseTE dte = getConnectedStargateTE(); - boolean validConnection = - (dte != null) && !dte.isInvalid() && (dte.getConnectedStargateTE() == this); + boolean validConnection = dte != null && !dte.isInvalid() && dte.getConnectedStargateTE() == this; if (canDisconnect || !validConnection) { if (state != SGState.Disconnecting) disconnect(); - return null; + return null; + } else { + return operationFailure(player, "incomingConnection"); } - else - return operationFailure(player, "Connection initiated from other end"); } - + public boolean disconnectionAllowed() { return isInitiator || closeFromEitherEnd; } - - String connect(String address, EntityPlayer player) { - SGBaseTE dte; - if (state != SGState.Idle) - return diallingFailure(player, "Stargate is busy"); + + String connect(String address, EntityPlayer player, boolean immediate) { + if (state != SGState.Idle) { + return diallingFailure(player, "selfBusy"); + } String homeAddress = findHomeAddress(); - if (homeAddress.equals("")) - return diallingFailure(player, "Coordinates of dialling stargate are out of range"); - try { - dte = SGAddressing.findAddressedStargate(address, worldObj); + if (homeAddress.equals("")) { + return diallingFailure(player, "selfOutOfRange"); } - catch (SGAddressing.AddressingError e) { + SGBaseTE targetGate; + try { + targetGate = SGAddressing.findAddressedStargate(address, world); + } catch (SGAddressing.AddressingError e) { return diallingFailure(player, e.getMessage()); } - if (dte == null || !dte.isMerged) - return diallingFailure(player, "No stargate at address " + address); - if (getWorld() == dte.getWorld()) { + if (targetGate == null || !targetGate.isMerged) { + return diallingFailure(player, "unknownAddress", address); + } + if (getWorld() == targetGate.getWorld()) { address = SGAddressing.localAddress(address); homeAddress = SGAddressing.localAddress(homeAddress); } - if (address.length() > getNumChevrons()) - return diallingFailure(player, "Not enough chevrons to dial " + address); - if (dte == this) - return diallingFailure(player, "Stargate cannot connect to itself"); - if (debugConnect) + if (address.length() > getNumChevrons()) { + return diallingFailure(player, "selfLackChevrons", address); + } + if (targetGate == this) { + return diallingFailure(player, "diallingItself"); + } + if (debugConnect) { System.out.printf("SGBaseTE.connect: to %s in dimension %d with state %s\n", - dte.getPos(), dte.getWorld().provider.getDimension(), - dte.state); - if (dte.getNumChevrons() < homeAddress.length()) - return diallingFailure(player, "Destination stargate has insufficient chevrons"); - if (dte.state != SGState.Idle) - return diallingFailure(player, "Stargate at address " + address + " is busy"); - distanceFactor = distanceFactorForCoordDifference(this, dte); - if (debugEnergyUse) + targetGate.getPos(), targetGate.getWorld().provider.getDimension(), targetGate.state); + } + if (targetGate.getNumChevrons() < homeAddress.length()) { + return diallingFailure(player, "targetLackChevrons"); + } + if (targetGate.state != SGState.Idle) { + return diallingFailure(player, "targetBusy", address); + } + distanceFactor = distanceFactorForCoordDifference(this, targetGate); + if (debugEnergyUse) { System.out.printf("SGBaseTE: distanceFactor = %s\n", distanceFactor); - if (!energyIsAvailable(energyToOpen * distanceFactor)) - return diallingFailure(player, "Stargate has insufficient energy"); - startDiallingStargate(address, dte, true); - dte.startDiallingStargate(homeAddress, this, false); + } + if (!energyIsAvailable(energyToOpen * distanceFactor)) { + return diallingFailure(player, "insufficientEnergy"); + } + startDiallingStargate(address, targetGate, true, immediate); + + targetGate.enterState(SGState.AttemptToDial, 0); + + targetGate.startDiallingStargate(homeAddress, this, false, immediate); return null; } - + public static double distanceFactorForCoordDifference(TileEntity te1, TileEntity te2) { double dx = te1.getPos().getX() - te2.getPos().getX(); double dz = te1.getPos().getZ() - te2.getPos().getZ(); @@ -621,40 +699,40 @@ public static double distanceFactorForCoordDifference(TileEntity te1, TileEntity f *= interDimensionMultiplier; return f; } - + public void playSGSoundEffect(SoundEvent se, float volume, float pitch) { playSoundEffect(se, volume * soundVolume, pitch); } - - String diallingFailure(EntityPlayer player, String mess) { + + public String diallingFailure(EntityPlayer player, String msg, Object... args) { if (player != null) { if (state == SGState.Idle) - playSGSoundEffect(abortSound, 1.0F, 1.0F); + playSGSoundEffect(dialFailSound, 1F, 1F); } - return operationFailure(player, mess); + return operationFailure(player, msg, args); } - - String operationFailure(EntityPlayer player, String mess) { + + public String operationFailure(EntityPlayer player, String msg, Object... args) { if (player != null) - sendChatMessage(player, mess); - return mess; + sendErrorMsg(player, msg, args); + return msg; } - - static void sendChatMessage(EntityPlayer player, String mess) { - player.addChatMessage(new TextComponentTranslation(mess)); + + public static void sendErrorMsg(EntityPlayer player, String msg, Object... args) { + ITextComponent component = new TextComponentTranslation("message.sgcraft:" + msg, args); + component.getStyle().setColor(TextFormatting.RED); + player.sendMessage(component); } - + String findHomeAddress() { - String homeAddress; try { return getHomeAddress(); - } - catch (SGAddressing.AddressingError e) { - System.out.printf("SGBaseTE.findHomeAddress: %s\n", e); + } catch (SGAddressing.AddressingError e) { + //System.out.printf("SGBaseTE.findHomeAddress: %s\n", e); return ""; } } - + public void disconnect() { if (debugConnect) System.out.printf("SGBaseTE: %s: disconnect()\n", side()); @@ -663,37 +741,49 @@ public void disconnect() { dte.clearConnection(); clearConnection(); } - + public void clearConnection() { if (state != SGState.Idle || connectedLocation != null) { dialledAddress = ""; connectedLocation = null; isInitiator = false; - numEngagedChevrons = 0; markChanged(); if (state == SGState.Connected) { enterState(SGState.Disconnecting, disconnectTime); //sendClientEvent(SGEvent.StartDisconnecting, 0); - playSGSoundEffect(closeSound, 1.0F, 1.0F); - } - else { + playSGSoundEffect(disconnectSound, 1F, 1F); + } else { + numEngagedChevrons = 0; if (state != SGState.Idle && state != SGState.Disconnecting) - playSGSoundEffect(abortSound, 1.0F, 1.0F); + playSGSoundEffect(dialFailSound, 1F, 1F); + else + playSGSoundEffect(chevronOutgoingSound, 1F, 1F); enterState(SGState.Idle, 0); //sendClientEvent(SGEvent.FinishDisconnecting, 0); } } } - - void startDiallingStargate(String address, SGBaseTE dte, boolean initiator) { + + void startDiallingStargate(String address, SGBaseTE dte, boolean initiator, boolean immediate) { //System.out.printf("SGBaseTE.startDiallingStargate %s, initiator = %s\n", // dte, initiator); dialledAddress = address; connectedLocation = new SGLocation(dte); isInitiator = initiator; markDirty(); - startDiallingNextSymbol(); + if (isInitiator && !immediate) { + startDiallingNextSymbol(); + } postEvent(initiator ? "sgDialOut" : "sgDialIn", address); + if (immediate) { + numEngagedChevrons = dialledAddress.length(); + if (!initiator) { + playSGSoundEffect(chevronIncomingSound, 1F, 1F); + } + enterState(SGState.SyncAwait, syncAwaitTime); + } else { + numEngagedChevrons = 0; + } } void serverUpdate() { @@ -702,58 +792,94 @@ void serverUpdate() { try { homeAddress = getHomeAddress(); addressError = ""; - } - catch (SGAddressing.AddressingError e) { + } catch (SGAddressing.AddressingError e) { homeAddress = null; addressError = e.getMessage(); } - if (SGCraft.ocIntegration != null) //[OC] - SGCraft.ocIntegration.onSGBaseTEAdded(this); + if (SGCraft.ocIntegration != null) { //[OC] + ((OCIntegration)SGCraft.ocIntegration).onSGBaseTEAdded(this); + } } if (isMerged) { if (debugState && state != SGState.Connected && timeout > 0) { - int dimension = worldObj.provider.getDimension(); - System.out.printf( - "SGBaseTE.serverUpdate at %d in dimension %d: state %s, timeout %s\n", - pos, dimension, state, timeout); + int dimension = world.provider.getDimension(); + System.out.printf("SGBaseTE.serverUpdate at %s in dimension %d: state %s, timeout %s\n", pos, dimension, state, timeout); } tickEnergyUsage(); if (timeout > 0) { - if (state == SGState.Transient && !irisIsClosed()) - performTransientDamage(); + switch (state) { + case Transient: + if (!irisIsClosed()) { + performTransientDamage(); + } + break; + case Dialing: + double step = (double)(maxTimeout - timeout) / (double)maxTimeout; + ringAngle = startRingAngle + (targetRingAngle - startRingAngle) * step; + break; + + case EstablishingConnection: + if (timeout == 25) { + playSGSoundEffect(connectSound, 1F, 1F); // Play sound before gate actually opens. + } + break; + } --timeout; - } - else switch(state) { - case Idle: - if (undialledDigitsRemaining()) - startDiallingNextSymbol(); - break; - case Dialling: - finishDiallingSymbol(); - break; - case InterDialling: - startDiallingNextSymbol(); - break; - case Transient: - enterState(SGState.Connected, isInitiator ? ticksToStayOpen : 0); - break; - case Connected: - if (isInitiator && ticksToStayOpen > 0) - disconnect(); - break; - case Disconnecting: - enterState(SGState.Idle, 0); - break; + } else { + switch(state) { + case Idle: + if (symbolsRemaining(false) && isInitiator) { + startDiallingNextSymbol(); + } + break; + case Dialing: + if (isInitiator) { + char charTargetSymbol = dialledAddress.charAt(numEngagedChevrons); + char charOwnSymbol = homeAddress.charAt(numEngagedChevrons); + String targetSymbol = Character.toString(charTargetSymbol); + String ownSymbol = Character.toString(charOwnSymbol); + // Note: CC interfaces can't use CHAR! + finishDiallingSymbol(targetSymbol, true, true, !symbolsRemaining(true)); + SGBaseTE targetGate = SGBaseTE.at(connectedLocation); + targetGate.finishDiallingSymbol(ownSymbol, false, true, !targetGate.symbolsRemaining(true)); + } + break; + case InterDialing: + if (isInitiator) { + startDiallingNextSymbol(); + } + break; + case SyncAwait: + attemptToLockStargate(); + break; + case EstablishingConnection: + openStargate(); + break; + case Transient: + enterState(SGState.Connected, isInitiator ? ticksToStayOpen : 0); + break; + case Connected: + if (isInitiator && ticksToStayOpen > 0) { + disconnect(); + } + break; + case Disconnecting: + numEngagedChevrons = 0; + enterState(SGState.Idle, 0); + break; + } } } } - + void tickEnergyUsage() { - if (state == SGState.Connected && isInitiator) - if (!useEnergy(energyUsePerTick * distanceFactor)) + if (state == SGState.Connected && isInitiator) { + if (!useEnergy(energyUsePerTick * distanceFactor)) { disconnect(); + } + } } - + double availableEnergy() { List sources = findEnergySources(); return energyInBuffer + energyAvailableFrom(sources); @@ -765,12 +891,17 @@ boolean energyIsAvailable(double amount) { System.out.printf("SGBaseTE.energyIsAvailable: need %s, have %s\n", amount, energy); return energy >= amount; } - + boolean useEnergy(double amount) { if (debugEnergyUse) System.out.printf("SGBaseTE.useEnergy: %s; buffered: %s\n", amount, energyInBuffer); if (amount <= energyInBuffer) { energyInBuffer -= amount; + if (updated++ > 10) { + // Send energy update to client for diag/gui purposes + markChanged(); + updated = 0; + } return true; } List sources = findEnergySources(); @@ -778,7 +909,7 @@ boolean useEnergy(double amount) { if (debugEnergyUse) System.out.printf("SGBaseTE.useEnergy: %s available\n", energyAvailable); if (amount > energyAvailable) { - System.out.printf("SGBaseTE: Not enough energy available\n"); + System.out.print("SGBaseTE: Not enough energy available\n"); return false; } double desiredEnergy = max(amount, maxEnergyBuffer); @@ -791,7 +922,7 @@ boolean useEnergy(double amount) { System.out.printf("SGBaseTE.useEnergy: %s now on hand, need %s\n", energyOnHand, amount); if (amount - 0.0001 > energyOnHand) { System.out.printf("SGBaseTE: Energy sources only delivered %s of promised %s\n", - energyOnHand - energyInBuffer, energyAvailable); + energyOnHand - energyInBuffer, energyAvailable); return false; } setEnergyInBuffer(energyOnHand - amount); @@ -799,15 +930,15 @@ boolean useEnergy(double amount) { System.out.printf("SGBaseTE.useEnergy: %s left over in buffer\n", energyInBuffer); return true; } - + List findEnergySources() { -// System.out.printf("SGBaseTe.findEnergySources: for %s\n", getPos()); - List result = new ArrayList(); + // System.out.printf("SGBaseTe.findEnergySources: for %s\n", getSoundPos()); + List result = new ArrayList<>(); Trans3 t = localToGlobalTransformation(); for (int i = -2; i <= 2; i++) { BlockPos bp = t.p(i, -1, 0).blockPos(); - TileEntity nte = worldObj.getTileEntity(bp); -// System.out.printf("SGBaseTE.findEnergySources: %s at %s\n", nte, bp); + TileEntity nte = world.getTileEntity(bp); + // System.out.printf("SGBaseTE.findEnergySources: %s at %s\n", nte, bp); if (nte instanceof ISGEnergySource) result.add((ISGEnergySource)nte); } @@ -816,7 +947,7 @@ List findEnergySources() { result.add(te); return result; } - + double energyAvailableFrom(List sources) { double energy = 0; for (ISGEnergySource source : sources) { @@ -827,7 +958,7 @@ List findEnergySources() { } return energy; } - + double drawEnergyFrom(List sources, double amount) { double total = 0; for (ISGEnergySource source : sources) { @@ -840,17 +971,17 @@ List findEnergySources() { } if (total < amount) System.out.printf("SGCraft: Warning: Energy sources did not deliver promised energy " + - "(%s requested, %s delivered)\n", amount, total); + "(%s requested, %s delivered)\n", amount, total); return total; } - + void setEnergyInBuffer(double amount) { if (energyInBuffer != amount) { energyInBuffer = amount; markDirty(); } } - + void performTransientDamage() { Trans3 t = localToGlobalTransformation(); Vector3 p0 = t.p(-1.5, 0.5, 0.5); @@ -859,13 +990,13 @@ void performTransientDamage() { Vector3 q1 = p0.max(p1); AxisAlignedBB box = new AxisAlignedBB(q0.x, q0.y, q0.z, q1.x, q1.y, q1.z); if (debugTransientDamage) { - System.out.printf("SGBaseTE.performTransientDamage: players in world:\n"); - for (Entity ent : (List)worldObj.loadedEntityList) + System.out.print("SGBaseTE.performTransientDamage: players in world:\n"); + for (Entity ent : world.loadedEntityList) if (ent instanceof EntityPlayer) System.out.printf("--- %s\n", ent); System.out.printf("SGBaseTE.performTransientDamage: box = %s\n", box); } - List ents = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box); + List ents = world.getEntitiesWithinAABB(EntityLivingBase.class, box); for (EntityLivingBase ent : ents) { Vector3 ep = new Vector3(ent.posX, ent.posY, ent.posZ); Vector3 gp = t.p(0, 2, 0.5); @@ -877,91 +1008,114 @@ void performTransientDamage() { int damage = (int)Math.ceil(dist * transientDamageRate); if (debugTransientDamage) System.out.printf("SGBaseTE.performTransientDamage: distance = %s, damage = %s\n", - dist, damage); + dist, damage); ent.attackEntityFrom(transientDamage, damage); } } - - boolean undialledDigitsRemaining() { + + boolean symbolsRemaining(boolean before) { int n = numEngagedChevrons; - return n < dialledAddress.length(); + return n < dialledAddress.length() - (before ? 1 : 0); } - + void startDiallingNextSymbol() { if (debugState) - System.out.printf("SGBaseTE.startDiallingNextSymbol: %s of %s\n", - numEngagedChevrons, dialledAddress); + System.out.printf("SGBaseTE.startDiallingNextSymbol: %s of %s\n", numEngagedChevrons, dialledAddress); startDiallingSymbol(dialledAddress.charAt(numEngagedChevrons)); } - + void startDiallingSymbol(char c) { int i = SGAddressing.charToSymbol(c); if (debugState) System.out.printf("SGBaseTE.startDiallingSymbol: %s\n", i); if (i >= 0 && i < numRingSymbols) { - startDiallingToAngle(i * ringSymbolAngle); - playSGSoundEffect(diallingSound, 1.0F, 1.0F); - } - else { + double targetAngle = i * ringSymbolAngle; + double diff = targetAngle - ringAngle; + if (Math.abs(diff) < 180) { + targetAngle -= Math.copySign(360.0, ringAngle); + diff = targetAngle - ringAngle; + } + int delay = (int)Math.abs(diff / ringRotationSpeed); + targetRingAngle = targetAngle; + //System.out.println(homeAddress + " -> Delay: " + delay + " (From angle " + ringAngle + " to angle " + targetAngle + ")"); + enterState(SGState.Dialing, delay); + } else { System.out.printf("SGCraft: Stargate jammed trying to dial symbol %s\n", c); dialledAddress = ""; enterState(SGState.Idle, 0); } } - - void startDiallingToAngle(double a) { - targetRingAngle = Utils.normaliseAngle(a); - enterState(SGState.Dialling, diallingTime); + + void unsetSymbol(char symbol) { + postEvent("sgChevronUnset", numEngagedChevrons, symbol); + --numEngagedChevrons; } - - void finishDiallingSymbol() { + + void finishDiallingSymbol(String symbol, boolean outgoing, boolean changeState, boolean lastOne) { ++numEngagedChevrons; - String symbol = dialledAddress.substring(numEngagedChevrons - 1, numEngagedChevrons); postEvent("sgChevronEngaged", numEngagedChevrons, symbol); - if (undialledDigitsRemaining()) - enterState(SGState.InterDialling, interDiallingTime); - else - finishDiallingAddress(); + if (lastOne) { + if (changeState) { + enterState(SGState.SyncAwait, syncAwaitTime); + } + if (!world.isRemote) { + playSGSoundEffect(outgoing ? lockOutgoingSound : lockIncomingSound, 1F, 1F); + } + } else { + if (changeState) { + enterState(SGState.InterDialing, interDiallingTime); + } + if (!world.isRemote) { + playSGSoundEffect(outgoing ? chevronOutgoingSound : chevronIncomingSound, 1F, 1F); + } + } } - - void finishDiallingAddress() { - //System.out.printf("SGBaseTE: Connecting to '%s'\n", dialledAddress); - if (!isInitiator || useEnergy(energyToOpen * distanceFactor)) { - enterState(SGState.Transient, transientDuration); - playSGSoundEffect(openSound, 1.0F, 1.0F); + + private void attemptToLockStargate() { + if (debugConnect) { + System.out.printf("SGBaseTE: Connecting to '%s'\n", dialledAddress); } - else + if (!isInitiator || useEnergy(energyToOpen * distanceFactor)) { + enterState(SGState.EstablishingConnection, 30); + } else { disconnect(); + } } - + + private void openStargate() { + if (debugConnect) { + System.out.printf("SGBaseTE: Connecting to '%s'\n", dialledAddress); + } + enterState(SGState.Transient, transientDuration); + } + boolean canTravelFromThisEnd() { return isInitiator || !oneWayTravel; } - - static String repr(Entity entity) { + + String repr(Entity entity) { if (entity != null) { String s = String.format("%s#%s", entity.getClass().getSimpleName(), entity.getEntityId()); if (entity.isDead) s += "(dead)"; return s; - } - else + } else { return "null"; + } } - + class TrackedEntity { public Entity entity; public Vector3 lastPos; - + public TrackedEntity(Entity entity) { this.entity = entity; this.lastPos = new Vector3(entity.posX, entity.posY, entity.posZ); } - } - List trackedEntities = new ArrayList(); - + List trackedEntities = new ArrayList<>(); + void checkForEntitiesInPortal() { if (state == SGState.Connected) { for (TrackedEntity trk : trackedEntities) @@ -972,7 +1126,7 @@ void checkForEntitiesInPortal() { Trans3 t = localToGlobalTransformation(); AxisAlignedBB box = t.box(p0, p1); //System.out.printf("SGBaseTE.checkForEntitiesInPortal: %s\n", box); - List ents = (List)worldObj.getEntitiesWithinAABB(Entity.class, box); + List ents = world.getEntitiesWithinAABB(Entity.class, box); for (Entity entity : ents) { if (entity instanceof EntityFishHook) continue; @@ -982,9 +1136,9 @@ void checkForEntitiesInPortal() { trackedEntities.add(new TrackedEntity(entity)); } } - } - else + } else { trackedEntities.clear(); + } } public void entityInPortal(Entity entity, Vector3 prevPos) { @@ -1000,7 +1154,7 @@ public void entityInPortal(Entity entity, Vector3 prevPos) { double z0 = 0.0; if (p0.z >= z0 && p1.z < z0 && p1.z > z0 - 5.0) { //System.out.printf("SGBaseTE.entityInPortal: %s passed through event horizon of stargate at (%d,%d,%d) in %s\n", - // repr(entity), xCoord, yCoord, zCoord, worldObj); + // repr(entity), xCoord, yCoord, zCoord, world); entity.motionX = vx; entity.motionY = vy; entity.motionZ = vz; @@ -1019,7 +1173,7 @@ public void entityInPortal(Entity entity, Vector3 prevPos) { } } } - + Entity teleportEntityAndRiders(Entity entity, Trans3 t1, Trans3 t2, int dimension, boolean destBlocked) { if (debugTeleport) System.out.printf("SGBaseTE.teleportEntityAndRiders: destBlocked = %s\n", destBlocked); @@ -1046,34 +1200,34 @@ Entity teleportEntityAndRiders(Entity entity, Trans3 t1, Trans3 t2, int dimensio } return entity; } - + // Break any leash connections to or from the given entity. That happens anyway // when the entity is teleported, but without this it drops an extra leash item. - protected static void unleashEntity(Entity entity) { + protected void unleashEntity(Entity entity) { if (entity instanceof EntityLiving) ((EntityLiving)entity).clearLeashed(true, false); for (EntityLiving entity2 : entitiesWithinLeashRange(entity)) - if (entity2.getLeashed() && entity2.getLeashedToEntity() == entity) + if (entity2.getLeashed() && entity2.getLeashHolder() == entity) entity2.clearLeashed(true, false); } - - protected static List entitiesWithinLeashRange(Entity entity) { + + protected List entitiesWithinLeashRange(Entity entity) { AxisAlignedBB box = new AxisAlignedBB( - entity.posX - 7.0D, entity.posY - 7.0D, entity.posZ - 7.0D, - entity.posX + 7.0D, entity.posY + 7.0D, entity.posZ + 7.0D); - return entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, box); + entity.posX - 7.0D, entity.posY - 7.0D, entity.posZ - 7.0D, + entity.posX + 7.0D, entity.posY + 7.0D, entity.posZ + 7.0D); + return entity.world.getEntitiesWithinAABB(EntityLiving.class, box); } - static Entity teleportEntity(Entity entity, Trans3 t1, Trans3 t2, int dimension, boolean destBlocked) { + Entity teleportEntity(Entity entity, Trans3 t1, Trans3 t2, int dimension, boolean destBlocked) { Entity newEntity = null; if (debugTeleport) { System.out.printf("SGBaseTE.teleportEntity: %s (in dimension %d) to dimension %d\n", - repr(entity), entity.dimension, dimension); + repr(entity), entity.dimension, dimension); System.out.printf("SGBaseTE.teleportEntity: pos (%.2f, %.2f, %.2f) prev (%.2f, %.2f, %.2f) last (%.2f, %.2f, %.2f) pitch %.2f yaw %.2f\n", - entity.posX, entity.posY, entity.posZ, - entity.prevPosX, entity.prevPosY, entity.prevPosZ, - entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ, - entity.rotationPitch, entity.rotationYaw); + entity.posX, entity.posY, entity.posZ, + entity.prevPosX, entity.prevPosY, entity.prevPosZ, + entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ, + entity.rotationPitch, entity.rotationYaw); } Vector3 p = t1.ip(entity.posX, entity.posY, entity.posZ); // local position Vector3 v = t1.iv(entity.motionX, entity.motionY, entity.motionZ); // local velocity @@ -1087,6 +1241,8 @@ static Entity teleportEntity(Entity entity, Trans3 t1, Trans3 t2, int dimension, if (debugTeleport) System.out.printf("SGBaseTE.teleportEntity: new yaw %.2f\n", a); if (!destBlocked) { + // Play sound from point of origin gate. + playTeleportSound(entity.getEntityWorld(), new Vector3(entity.getPositionVector()), entity); if (entity.dimension == dimension) newEntity = teleportWithinDimension(entity, q, u, a, destBlocked); else { @@ -1102,68 +1258,73 @@ static Entity teleportEntity(Entity entity, Trans3 t1, Trans3 t2, int dimension, } else { terminateEntityByIrisImpact(entity); - playIrisHitSound(worldForDimension(dimension), q, entity); + playIrisHitSound(SGAddressing.getWorld(dimension), q, entity); } + // Play sound at destination gate. + playTeleportSound(entity.getEntityWorld(), new Vector3(entity.getPositionVector()), entity); return newEntity; } - - static void terminateEntityByIrisImpact(Entity entity) { - if (entity instanceof EntityPlayer) + + void terminateEntityByIrisImpact(Entity entity) { + if (entity instanceof EntityPlayer) { terminatePlayerByIrisImpact((EntityPlayer)entity); - else + } else { entity.setDead(); + } } - - static void terminatePlayerByIrisImpact(EntityPlayer player) { + + void terminatePlayerByIrisImpact(EntityPlayer player) { if (player.capabilities.isCreativeMode) - sendChatMessage(player, "Destination blocked by iris"); + sendErrorMsg(player, "irisAtDestination"); else { - if (!(preserveInventory || player.worldObj.getGameRules().getBoolean("keepInventory"))) + if (!(preserveInventory || player.world.getGameRules().getBoolean("keepInventory"))) player.inventory.clear(); player.attackEntityFrom(irisDamageSource, irisDamageAmount); } } - static WorldServer worldForDimension(int dimension) { - return SGAddressing.getWorld(dimension); + void playIrisHitSound(World world, Vector3 pos, Entity entity) { + float volume = (float) min(entity.width * entity.height, 1.0); + float pitch = 2F - volume; + if (debugTeleport) + System.out.printf("SGBaseTE.playIrisHitSound: at (%.3f,%.3f,%.3f) volume %.3f pitch %.3f\n", pos.x, pos.y, pos.z, volume, pitch); + playSoundEffect(world, pos.x, pos.y, pos.z, irisHitSound, volume * soundVolume, pitch); } - static void playIrisHitSound(World world, Vector3 pos, Entity entity) { - double volume = min(entity.width * entity.height, 1.0); - double pitch = 2.0 - volume; + void playTeleportSound(World world, Vector3 pos, Entity entity) { + float volume = (float) min(entity.width * entity.height, 1.0); + float pitch = 2F - volume; if (debugTeleport) - System.out.printf("SGBaseTE.playIrisHitSound: at (%.3f,%.3f,%.3f) volume %.3f pitch %.3f\n", - pos.x, pos.y, pos.z, volume, pitch); - world.playSound(pos.x, pos.y, pos.z, irisHitSound, SoundCategory.NEUTRAL, - (float)volume, (float)pitch, false); + System.out.printf("SGBaseTE.playTeleportSound: at (%.3f,%.3f,%.3f) volume %.3f pitch %.3f\n", pos.x, pos.y, pos.z, volume, pitch); + playSoundEffect(world, pos.x, pos.y, pos.z, teleportSound, volume * soundVolume, pitch); } - - static Entity teleportWithinDimension(Entity entity, Vector3 p, Vector3 v, double a, boolean destBlocked) { + + Entity teleportWithinDimension(Entity entity, Vector3 p, Vector3 v, double a, boolean destBlocked) { if (entity instanceof EntityPlayerMP) return teleportPlayerWithinDimension((EntityPlayerMP)entity, p, v, a); else - return teleportEntityToWorld(entity, p, v, a, (WorldServer)entity.worldObj, destBlocked); + return teleportEntityToWorld(entity, p, v, a, (WorldServer)entity.world, destBlocked); } - - static Entity teleportPlayerWithinDimension(EntityPlayerMP entity, Vector3 p, Vector3 v, double a) { + + Entity teleportPlayerWithinDimension(EntityPlayerMP entity, Vector3 p, Vector3 v, double a) { entity.rotationYaw = (float)a; entity.setPositionAndUpdate(p.x, p.y, p.z); - entity.worldObj.updateEntityWithOptionalForce(entity, false); + entity.world.updateEntityWithOptionalForce(entity, false); return entity; } - static Entity teleportToOtherDimension(Entity entity, Vector3 p, Vector3 v, double a, int dimension, boolean destBlocked) { + Entity teleportToOtherDimension(Entity entity, Vector3 p, Vector3 v, double a, int dimension, boolean destBlocked) { if (entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; Vector3 q = p.add(yawVector(a)); transferPlayerToDimension(player, dimension, q, a); return player; - } - else + } else { return teleportEntityToDimension(entity, p, v, a, dimension, destBlocked); + } } - - static void sendDimensionRegister(EntityPlayerMP player, int dimensionID) { + + void sendDimensionRegister(EntityPlayerMP player, int dimensionID) { DimensionType providerID = DimensionManager.getProviderType(dimensionID); ForgeMessage msg = new ForgeMessage.DimensionRegisterMessage(dimensionID, providerID.toString()); FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER); @@ -1171,15 +1332,16 @@ static void sendDimensionRegister(EntityPlayerMP player, int dimensionID) { channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); channel.writeAndFlush(msg).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } - - static void transferPlayerToDimension(EntityPlayerMP player, int newDimension, Vector3 p, double a) { + + + void transferPlayerToDimension(EntityPlayerMP player, int newDimension, Vector3 p, double a) { //System.out.printf("SGBaseTE.transferPlayerToDimension: %s to dimension %d\n", repr(player), newDimension); MinecraftServer server = BaseUtils.getMinecraftServer(); PlayerList scm = server.getPlayerList(); int oldDimension = player.dimension; player.dimension = newDimension; - WorldServer oldWorld = server.worldServerForDimension(oldDimension); - WorldServer newWorld = server.worldServerForDimension(newDimension); + WorldServer oldWorld = server.getWorld(oldDimension); + WorldServer newWorld = server.getWorld(newDimension); //System.out.printf("SGBaseTE.transferPlayerToDimension: %s with %s\n", newWorld, newWorld.getEntityTracker()); // <<< Fix for MCPC+ // -- Is this still necessary now that we are calling firePlayerChangedDimensionEvent? @@ -1188,42 +1350,39 @@ static void transferPlayerToDimension(EntityPlayerMP player, int newDimension, V // >>> player.closeScreen(); player.connection.sendPacket(new SPacketRespawn(player.dimension, - player.worldObj.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), - player.interactionManager.getGameType())); -// if (SGCraft.mystcraftIntegration != null) //[MYST] -// SGCraft.mystcraftIntegration.sendAgeData(newWorld, player); + player.world.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), + player.interactionManager.getGameType())); + // if (SGCraft.mystcraftIntegration != null) //[MYST] + // SGCraft.mystcraftIntegration.sendAgeData(newWorld, player); oldWorld.removeEntityDangerously(player); // Removes player right now instead of waiting for next tick player.isDead = false; player.setLocationAndAngles(p.x, p.y, p.z, (float)a, player.rotationPitch); - newWorld.spawnEntityInWorld(player); + newWorld.spawnEntity(player); player.setWorld(newWorld); scm.preparePlayer(player, oldWorld); player.connection.setPlayerLocation(p.x, p.y, p.z, (float)a, player.rotationPitch); player.interactionManager.setWorld(newWorld); scm.updateTimeAndWeatherForPlayer(player, newWorld); scm.syncPlayerInventory(player); - Iterator var6 = player.getActivePotionEffects().iterator(); - while (var6.hasNext()) { - PotionEffect effect = (PotionEffect)var6.next(); + for (PotionEffect effect : player.getActivePotionEffects()) { player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), effect)); } player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimension, newDimension); //System.out.printf("SGBaseTE.transferPlayerToDimension: Transferred %s\n", repr(player)); - } - - static Entity teleportEntityToDimension(Entity entity, Vector3 p, Vector3 v, double a, int dimension, boolean destBlocked) { + } + + Entity teleportEntityToDimension(Entity entity, Vector3 p, Vector3 v, double a, int dimension, boolean destBlocked) { //System.out.printf("SGBaseTE.teleportEntityToDimension: %s to dimension %d\n", repr(entity), dimension); MinecraftServer server = BaseUtils.getMinecraftServer(); - WorldServer world = server.worldServerForDimension(dimension); + WorldServer world = server.getWorld(dimension); return teleportEntityToWorld(entity, p, v, a, world, destBlocked); } - - static Entity teleportEntityToWorld(Entity oldEntity, Vector3 p, Vector3 v, double a, WorldServer newWorld, boolean destBlocked) { + + Entity teleportEntityToWorld(Entity oldEntity, Vector3 p, Vector3 v, double a, WorldServer newWorld, boolean destBlocked) { if (debugTeleport) - System.out.printf("SGBaseTE.teleportEntityToWorld: %s to %s, destBlocked = %s\n", - repr(oldEntity), newWorld, destBlocked); - WorldServer oldWorld = (WorldServer)oldEntity.worldObj; + System.out.printf("SGBaseTE.teleportEntityToWorld: %s to %s, destBlocked = %s\n", repr(oldEntity), newWorld, destBlocked); + WorldServer oldWorld = (WorldServer)oldEntity.world; NBTTagCompound nbt = new NBTTagCompound(); oldEntity.writeToNBT(nbt); extractEntityFromWorld(oldWorld, oldEntity); @@ -1240,32 +1399,30 @@ static Entity teleportEntityToWorld(Entity oldEntity, Vector3 p, Vector3 v, doub checkChunk(newWorld, newEntity); //System.out.printf("SGBaseTE.teleportEntityToWorld: Spawning %s in %s\n", repr(newEntity), newWorld); newEntity.forceSpawn = true; // Force spawn packet to be sent as soon as possible - newWorld.spawnEntityInWorld(newEntity); + newWorld.spawnEntity(newEntity); newEntity.setWorld(newWorld); if (debugTeleport) System.out.printf( - "SGBaseTE.teleportEntityToWorld: Spawned %s pos (%.2f, %.2f, %.2f) vel (%.2f, %.2f, %.2f) pitch %.2f (%.2f) yaw %.2f (%.2f)\n", - repr(newEntity), - newEntity.posX, newEntity.posY, newEntity.posZ, - newEntity.motionX, newEntity.motionY, newEntity.motionZ, - newEntity.rotationPitch, newEntity.prevRotationPitch, - newEntity.rotationYaw, newEntity.prevRotationYaw); + "SGBaseTE.teleportEntityToWorld: Spawned %s pos (%.2f, %.2f, %.2f) vel (%.2f, %.2f, %.2f) pitch %.2f (%.2f) yaw %.2f (%.2f)\n", + repr(newEntity), + newEntity.posX, newEntity.posY, newEntity.posZ, + newEntity.motionX, newEntity.motionY, newEntity.motionZ, + newEntity.rotationPitch, newEntity.prevRotationPitch, + newEntity.rotationYaw, newEntity.prevRotationYaw); } oldWorld.resetUpdateEntityTick(); if (oldWorld != newWorld) newWorld.resetUpdateEntityTick(); return newEntity; } - + static Entity instantiateEntityFromNBT(Class cls, NBTTagCompound nbt, WorldServer world) { try { Entity entity = (Entity)cls.getConstructor(World.class).newInstance(world); entity.readFromNBT(nbt); return entity; - } - catch (Exception e) { - System.out.printf("SGCraft: SGBaseTE.instantiateEntityFromNBT: Could not instantiate %s: %s\n", - cls, e); + } catch (Exception e) { + System.out.printf("SGCraft: SGBaseTE.instantiateEntityFromNBT: Could not instantiate %s: %s\n", cls, e); e.printStackTrace(); return null; } @@ -1282,8 +1439,8 @@ static void setVelocity(Entity entity, Vector3 v) { entity.motionY = v.y; entity.motionZ = v.z; } - - static void extractEntityFromWorld(World world, Entity entity) { + + void extractEntityFromWorld(World world, Entity entity) { // Immediately remove entity from world without calling setDead(), which has // undesirable side effects on some entities. if (entity instanceof EntityPlayer) { @@ -1293,50 +1450,44 @@ static void extractEntityFromWorld(World world, Entity entity) { int i = entity.chunkCoordX; int j = entity.chunkCoordZ; if (entity.addedToChunk && ((ChunkProviderServer)world.getChunkProvider()).chunkExists(i, j)) - world.getChunkFromChunkCoords(i, j).removeEntity(entity); + world.getChunk(i, j).removeEntity(entity); world.loadedEntityList.remove(entity); //BaseReflectionUtils.call(world, onEntityRemoved, entity); world.onEntityRemoved(entity); } - - static void checkChunk(World world, Entity entity) { - int cx = MathHelper.floor_double(entity.posX / 16.0D); - int cy = MathHelper.floor_double(entity.posZ / 16.0D); - Chunk chunk = world.getChunkFromChunkCoords(cx, cy); + + void checkChunk(World world, Entity entity) { + int cx = MathHelper.floor(entity.posX / 16.0D); + int cy = MathHelper.floor(entity.posZ / 16.0D); + Chunk chunk = world.getChunk(cx, cy); } - - protected static int yawSign(Entity entity) { - if (entity instanceof EntityArrow) - return -1; - else - return 1; + + protected int yawSign(Entity entity) { + return entity instanceof EntityArrow ? -1 : 1; } - - static Vector3 yawVector(Entity entity) { + + Vector3 yawVector(Entity entity) { return yawVector(yawSign(entity) * entity.rotationYaw); } - - static Vector3 yawVector(double yaw) { + + Vector3 yawVector(double yaw) { double a = Math.toRadians(yaw); Vector3 v = new Vector3(-Math.sin(a), 0, Math.cos(a)); //System.out.printf("SGBaseTE.yawVector: %.2f --> (%.3f, %.3f)\n", yaw, v.x, v.z); return v; } - - static double yawAngle(Vector3 v, Entity entity) { + + double yawAngle(Vector3 v, Entity entity) { double a = Math.atan2(-v.x, v.z); double d = Math.toDegrees(a); //System.out.printf("SGBaseTE.yawAngle: (%.3f, %.3f) --> %.2f\n", v.x, v.z, d); return yawSign(entity) * d; } - + public SGBaseTE getConnectedStargateTE() { - if (isConnected() && connectedLocation != null) - return connectedLocation.getStargateTE(); - else - return null; - } - + return isConnected() && connectedLocation != null ? connectedLocation.getStargateTE() : null; + } + //------------------------------------ Client -------------------------------------------- @Override @@ -1344,29 +1495,49 @@ public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { //System.out.printf("SGBaseTE.onDataPacket: with state %s numEngagedChevrons %s\n", // SGState.valueOf(pkt.customParam1.getInteger("state")), // pkt.customParam1.getInteger("numEngagedChevrons")); + IrisState oldIrisState = irisState; SGState oldState = state; super.onDataPacket(net, pkt); - if (isMerged && state != oldState) { - switch (state) { - case Transient: - initiateOpeningTransient(); - break; - case Disconnecting: - initiateClosingTransient(); - break; + if (isMerged) { + if (state != oldState) { + switch (state) { + case Transient: + initiateOpeningTransient(); + break; + case Disconnecting: + initiateClosingTransient(); + break; + case Dialing: + if (isInitiator) { + if (timeout > 0) { + SGCraft.playSound(this, gateRollSound); + } + } + break; + } + } + if (irisState != oldIrisState) { + switch (irisState) { + case Opening: + SGCraft.playSound(this, irisOpenSound); + break; + case Closing: + SGCraft.playSound(this, irisCloseSound); + break; + } } } } - + void clientUpdate() { lastRingAngle = ringAngle; switch (state) { - case Dialling: - //System.out.printf("SGBaseTe: Relaxing angle %s towards %s at rate %s\n", - // ringAngle, targetRingAngle, diallingRelaxationRate); - //setRingAngle(Utils.relaxAngle(ringAngle, targetRingAngle, diallingRelaxationRate)); - updateRingAngle(); - //System.out.printf("SGBaseTe: Ring angle now %s\n", ringAngle); + case Dialing: + if (timeout > 0) { + double step = (double)(maxTimeout - timeout) / (double)maxTimeout; + ringAngle = startRingAngle + (targetRingAngle - startRingAngle) * step; + --timeout; + } break; case Transient: case Connected: @@ -1377,20 +1548,6 @@ void clientUpdate() { } } - void setRingAngle(double a) { - ringAngle = a; - } - - void updateRingAngle() { - if (timeout > 0) { - double da = Utils.diffAngle(ringAngle, targetRingAngle) / timeout; - setRingAngle(Utils.addAngle(ringAngle, da)); - --timeout; - } - else - setRingAngle(targetRingAngle); - } - public double[][][] getEventHorizonGrid() { if (ehGrid == null) { int m = SGBaseTERenderer.ehGridRadialSize; @@ -1403,7 +1560,7 @@ public double[][][] getEventHorizonGrid() { } return ehGrid; } - + void initiateOpeningTransient() { double v[][] = getEventHorizonGrid()[1]; int n = SGBaseTERenderer.ehGridPolarSize; @@ -1412,8 +1569,9 @@ void initiateOpeningTransient() { v[j][1] = v[j][0] + openingTransientRandomness * random.nextGaussian(); } } - + void initiateClosingTransient() { + //numEngagedChevrons = 0; double v[][] = getEventHorizonGrid()[1]; int m = SGBaseTERenderer.ehGridRadialSize; int n = SGBaseTERenderer.ehGridPolarSize; @@ -1421,7 +1579,7 @@ void initiateClosingTransient() { for (int j = 1; j <= n; j++) v[j][i] += closingTransientRandomness * random.nextGaussian(); } - + void applyRandomImpulse() { double v[][] = getEventHorizonGrid()[1]; int m = SGBaseTERenderer.ehGridRadialSize; @@ -1430,7 +1588,7 @@ void applyRandomImpulse() { int j = random.nextInt(n) + 1; v[j][i] += 0.05 * random.nextGaussian(); } - + void updateEventHorizon() { double grid[][][] = getEventHorizonGrid(); double u[][] = grid[0]; @@ -1446,7 +1604,7 @@ void updateEventHorizon() { double d2u_drsq = u[j][i+1] - 2 * u[j][i] + u[j][i-1]; double d2u_dthsq = u[j+1][i] - 2 * u[j][i] + u[j-1][i]; v[j][i] = d * v[j][i] + (asq * dt) * (d2u_drsq + du_dr / i + d2u_dthsq / (i * i)); - } + } for (int i = 1; i < m; i++) for (int j = 1; j <= n; j++) u[j][i] += v[j][i] * dt; @@ -1464,7 +1622,7 @@ void updateEventHorizon() { //dumpGrid("u", u); //dumpGrid("v", v); } - + void dumpGrid(String label, double g[][]) { System.out.printf("SGBaseTE: %s:\n", label); int m = SGBaseTERenderer.ehGridRadialSize; @@ -1472,10 +1630,10 @@ void dumpGrid(String label, double g[][]) { for (int j = 0; j <= n+1; j++) { for (int i = 0; i <= m; i++) System.out.printf(" %6.3f", g[j][i]); - System.out.printf("\n"); + System.out.print("\n"); } } - + @Override protected IInventory getInventory() { return inventory; @@ -1485,11 +1643,11 @@ public boolean irisIsClosed() { //System.out.printf("SGBaseTE.irisIsClosed: irisPhase = %s\n", irisPhase); return hasIrisUpgrade && irisPhase <= maxIrisPhase / 2; } - - public double getIrisAperture(double t) { - return (lastIrisPhase * (1 - t) + irisPhase * t) / maxIrisPhase; + + public double getIrisAperture(double partialTicks) { + return (lastIrisPhase * (1 - partialTicks) + irisPhase * partialTicks) / maxIrisPhase; } - + void irisUpdate() { lastIrisPhase = irisPhase; switch (irisState) { @@ -1507,85 +1665,70 @@ void irisUpdate() { break; } } - + void enterIrisState(IrisState newState) { if (irisState != newState) { String oldDesc = irisStateDescription(irisState); String newDesc = irisStateDescription(newState); irisState = newState; markChanged(); - if (!worldObj.isRemote) { - switch (newState) { - case Opening: - playSGSoundEffect(irisOpenSound, 1.0F, 1.0F); - break; - case Closing: - playSGSoundEffect(irisCloseSound, 1.0F, 1.0F); - break; - } - } if (!oldDesc.equals(newDesc)) //postEvent("sgIrisStateChange", "oldState", oldDesc, "newState", newDesc); postEvent("sgIrisStateChange", newDesc, oldDesc); } } - + public void openIris() { - if (isMerged && hasIrisUpgrade && irisState != IrisState.Open) + if (isMerged && hasIrisUpgrade && irisState != IrisState.Open) { enterIrisState(IrisState.Opening); + } } - + public void closeIris() { - if (isMerged && hasIrisUpgrade && irisState != IrisState.Closed) + if (isMerged && hasIrisUpgrade && irisState != IrisState.Closed) { enterIrisState(IrisState.Closing); + } } - + public void onNeighborBlockChange() { - if (!worldObj.isRemote) { - boolean newInput = BaseBlockUtils.blockIsGettingExternallyPowered(worldObj, pos); + if (!world.isRemote) { + boolean newInput = BaseBlockUtils.blockIsGettingExternallyPowered(world, pos); if (redstoneInput != newInput) { redstoneInput = newInput; markDirty(); - if (redstoneInput) + if (redstoneInput) { closeIris(); - else + } else { openIris(); + } } } } - + void updateIrisEntity() { - if (!worldObj.isRemote) { - if (isMerged && hasIrisUpgrade) { - if (!hasIrisEntity()) { - IrisEntity ent = new IrisEntity(this); - worldObj.spawnEntityInWorld(ent); - //System.out.printf("SGBaseTE.updateIrisEntity: Spawned %s with bounds %s\n", ent, - // ent.getEntityBoundingBox()); - } + if (isMerged && hasIrisUpgrade) { + if (!hasIrisEntity()) { + EntityStargateIris ent = new EntityStargateIris(this); + world.spawnEntity(ent); } - else { - //System.out.printf("SGBaseTE.updateIrisEntity: Removing iris entities\n"); - for (IrisEntity ent : findIrisEntities()) { - //System.out.printf("SGBaseTE.updateIrisEntity: Removing %s\n", ent); - worldObj.removeEntity(ent); - } + } else { + for (EntityStargateIris ent : findIrisEntities()) { + world.removeEntity(ent); } } } - + boolean hasIrisEntity() { return findIrisEntities().size() != 0; } - - List findIrisEntities() { + + List findIrisEntities() { int x = pos.getX(), y = pos.getY(), z = pos.getZ(); - AxisAlignedBB box = new AxisAlignedBB( - x, y, z, x + 1, y + 2, z + 1); + AxisAlignedBB box = new AxisAlignedBB(x, y, z, x + 1, y + 2, z + 1); //System.out.printf("SGBaseTE.findIrisEntities: in %s\n", box); - return (List)worldObj.getEntitiesWithinAABB(IrisEntity.class, box); + return world.getEntitiesWithinAABB(EntityStargateIris.class, box); } - + ItemStack getCamouflageStack(BlockPos cpos) { //System.out.printf("SGBaseTE.getCamouflageStack: for %s from base at %s\n", cpos, pos); Trans3 t = localToGlobalTransformation(); @@ -1599,11 +1742,11 @@ ItemStack getCamouflageStack(BlockPos cpos) { } return null; } - + boolean isCamouflageSlot(int slot) { return slot >= firstCamouflageSlot && slot < firstCamouflageSlot + numCamouflageSlots; } - + @Override protected void onInventoryChanged(int slot) { //System.out.printf("SGBaseTE.onInventoryChanged: %s\n", slot); @@ -1612,34 +1755,27 @@ protected void onInventoryChanged(int slot) { //System.out.printf("SGBaseTE.onInventoryChanged: Camouflage slot changed\n"); for (int dx = -2; dx <= 2; dx++) for (int dz = -2; dz <= 2; dz++) - BaseBlockUtils.markBlockForUpdate(worldObj, pos.add(dx, 0, dz)); + BaseBlockUtils.markBlockForUpdate(world, pos.add(dx, 0, dz)); } } - - public int numItemsInSlot(int slot) { - ItemStack stack = getStackInSlot(slot); - if (stack != null) - return stack.stackSize; - else - return 0; - } - + protected int baseCornerCamouflage() { return max(baseCamouflageAt(0), baseCamouflageAt(4)); } - + protected int baseCamouflageAt(int i) { ItemStack stack = getStackInSlot(i); if (stack != null) { Item item = stack.getItem(); Block block = Block.getBlockFromItem(stack.getItem()); - if (block != null) { + if (block != Blocks.AIR) { if (block instanceof BlockSlab) return 1; int meta = item.getMetadata(stack); IBlockState state = block.getStateFromMeta(meta); - if (block.isFullCube(state)) + if (state.isFullCube()) { return 2; + } } } return 0; @@ -1647,37 +1783,34 @@ protected int baseCamouflageAt(int i) { static int rdx[] = {1, 0, -1, 0}; static int rdz[] = {0, -1, 0, 1}; - - // Find locations of tile entities that could connect to the stargate ring. - // TODO: Cache this - public Collection adjacentTiles() { - Collection result = new ArrayList(); + + public Collection adjacentTiles() { + Collection result = new ArrayList<>(); Trans3 t = localToGlobalTransformation(); for (int i = -2; i <= 2; i++) { BlockPos bp = t.p(i, -1, 0).blockPos(); - TileEntity te = getWorldTileEntity(worldObj, bp); + TileEntity te = getWorldTileEntity(world, bp); if (te != null) - result.add(new BlockRef(te)); + result.add(te); } return result; } - -//------------------------------------ Computer interface ---------------------------------- + + //------------------------------------ Computer interface ---------------------------------- public void forwardNetworkPacket(Object packet) { SGBaseTE dte = getConnectedStargateTE(); if (dte != null) dte.rebroadcastNetworkPacket(packet); } - + void rebroadcastNetworkPacket(Object packet) { - for (BlockRef ref : adjacentTiles()) { - TileEntity te = ref.getTileEntity(); + for (TileEntity te : adjacentTiles()) { if (te instanceof SGInterfaceTE) ((SGInterfaceTE)te).rebroadcastNetworkPacket(packet); } } - + public String sendMessage(Object[] args) { SGBaseTE dte = getConnectedStargateTE(); if (dte != null) { @@ -1687,12 +1820,12 @@ public String sendMessage(Object[] args) { else return "Stargate not connected"; } - + void postEvent(String name, Object... args) { + //Note: this event expect Strings only, NO CHAR!!!! //System.out.printf("SGBaseTE.postEvent: %s from (%s,%s,%s)\n", name, // xCoord, yCoord, zCoord); - for (BlockRef b : adjacentTiles()) { - TileEntity te = b.getTileEntity(); + for (TileEntity te : adjacentTiles()) { if (te instanceof IComputerInterface) { //System.out.printf("SGBaseTE.postEvent: to TE at (%s,%s,%s)\n", // b.xCoord, b.yCoord, b.zCoord); @@ -1700,55 +1833,41 @@ void postEvent(String name, Object... args) { } } } - + public String sgStateDescription() { return sgStateDescription(state); } - - static String sgStateDescription(SGState state) { + + String sgStateDescription(SGState state) { switch (state) { case Idle: return "Idle"; - case Dialling: - case InterDialling: return "Dialling"; + case Dialing: + case InterDialing: return "Dialing"; + case SyncAwait: case Transient: return "Opening"; case Connected: return "Connected"; case Disconnecting: return "Closing"; default: return "Unknown"; } } - + public String irisStateDescription() { return irisStateDescription(irisState); } - - static String irisStateDescription(IrisState state) { + + String irisStateDescription(IrisState state) { return state.toString(); } - + public static SGBaseTE getBaseTE(SGInterfaceTE ite) { return SGBaseTE.get(ite.getWorld(), ite.getPos().add(0, 1, 0)); } - -} -//------------------------------------------------------------------------------------------------ - -class BlockRef { - - public IBlockAccess worldObj; - BlockPos pos; - - public BlockRef(TileEntity te) { - this(te.getWorld(), te.getPos()); + public double getMaxEnergyBuffer() { + return this.maxEnergyBuffer; } - - public BlockRef(IBlockAccess world, BlockPos pos) { - worldObj = world; - this.pos = pos; - } - - public TileEntity getTileEntity() { - return worldObj.getTileEntity(pos); + + public static double getBaseMaxEnergyBuffer() { + return SGBaseTE.maxEnergyBuffer; } - } diff --git a/src/mod/gcewing/sg/SGBaseTERenderer.java b/src/mod/gcewing/sg/SGBaseTERenderer.java index 86f2d7d8..a02883da 100644 --- a/src/mod/gcewing/sg/SGBaseTERenderer.java +++ b/src/mod/gcewing/sg/SGBaseTERenderer.java @@ -6,15 +6,13 @@ package gcewing.sg; -import static java.lang.Math.*; -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL12.*; - import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.tileentity.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.util.math.*; +import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; + +import static java.lang.Math.min; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL12.GL_RESCALE_NORMAL; class SGBaseTERenderer extends BaseTileEntityRenderer { @@ -37,12 +35,6 @@ class SGBaseTERenderer extends BaseTileEntityRenderer { final static double textureScaleU = 1.0/(textureTilesWide * 16); final static double textureScaleV = 1.0/(textureTilesHigh * 16); - final static int ringFaceTextureIndex = 0x01; //0x14; - final static int ringTextureIndex = 0x00; //0x15; - final static int ringSymbolTextureIndex = 0x20; //0x20; - final static int chevronTextureIndex = 0x03; //0x05; - final static int chevronLitTextureIndex = 0x02; //0x16; - final static double ringSymbolTextureLength = 512.0; //27 * 8; final static double ringSymbolTextureHeight = 16.0; //12; final static double ringSymbolSegmentWidth = ringSymbolTextureLength / numRingSegments; @@ -72,10 +64,9 @@ class SGBaseTERenderer extends BaseTileEntityRenderer { double u0, v0; @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float t, int destroyStage) { - //System.out.printf("SGBaseTERenderer.renderTileEntityAt (%g,%g,%g)\n", x, y, z); - SGBaseTE tesg = (SGBaseTE)te; - if (tesg.isMerged) { + public void render(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + SGBaseTE gate = (SGBaseTE)te; + if (gate.isMerged) { glPushMatrix(); if (SGBaseTE.transparency) { glEnable(GL_BLEND); @@ -86,29 +77,29 @@ public void renderTileEntityAt(TileEntity te, double x, double y, double z, floa glEnable(GL_RESCALE_NORMAL); glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glTranslated(x + 0.5, y + 2.5, z + 0.5); - renderStargate(tesg, t); + renderStargate(gate, partialTicks); glDisable(GL_RESCALE_NORMAL); glPopMatrix(); } } - void renderStargate(SGBaseTE te, float t) { - //glRotatef(90 * te.turn, 0, 1, 0); - BaseGLUtils.glMultMatrix(te.localToGlobalTransformation(Vector3.zero)); + void renderStargate(SGBaseTE gate, float partialTicks) { + BaseGLUtils.glMultMatrix(gate.localToGlobalTransformation(Vector3.zero)); bindTexture(SGCraft.mod.resourceLocation("textures/tileentity/stargate.png")); glNormal3f(0, 1, 0); renderRing(ringMidRadius - ringOverlap, ringOuterRadius, RingType.Outer, ringZOffset); - renderInnerRing(te, t); - renderChevrons(te); - if (te.hasIrisUpgrade) - renderIris(te, t); - if (te.isConnected()) - renderEventHorizon(te); + renderInnerRing(gate, partialTicks); + renderChevrons(gate); + if (gate.hasIrisUpgrade) + renderIris(gate, partialTicks); + if (gate.isConnected() && gate.state != SGState.SyncAwait) { + renderEventHorizon(gate, partialTicks); + } } - void renderInnerRing(SGBaseTE te, float t) { + void renderInnerRing(SGBaseTE te, float partialTicks) { glPushMatrix(); - glRotatef((float)(te.interpolatedRingAngle(t) + SGBaseTE.ringSymbolAngle / 2), 0, 0, 1); + glRotatef((float)(te.interpolatedRingAngle(partialTicks) + SGBaseTE.ringSymbolAngle / 2), 0, 0, 1); renderRing(ringInnerRadius, ringMidRadius, RingType.Inner, 0); glPopMatrix(); } @@ -118,22 +109,22 @@ void renderRing(double r1, double r2, RingType type, double dz) { double u = 0, du = 0, dv = 0; glBegin(GL_QUADS); for (int i = 0; i < numRingSegments; i++) { - selectTile(ringTextureIndex); - // Outer - if (type == RingType.Outer) { - glNormal3d(c[i], s[i], 0); - vertex(r2*c[i], r2*s[i], z, 0, 0); - vertex(r2*c[i], r2*s[i], -z, 0, 16); - vertex(r2*c[i+1], r2*s[i+1], -z, 16, 16); - vertex(r2*c[i+1], r2*s[i+1], z, 16, 0); - } - // Inner - if (type == RingType.Inner) { - glNormal3d(-c[i], -s[i], 0); - vertex(r1*c[i], r1*s[i], -z, 0, 0); - vertex(r1*c[i], r1*s[i], z, 0, 16); - vertex(r1*c[i+1], r1*s[i+1], z, 16, 16); - vertex(r1*c[i+1], r1*s[i+1], -z, 16, 0); + selectTile(TextureIndex.RING); + switch (type) { + case Outer: + glNormal3d(c[i], s[i], 0); + vertex(r2 * c[i], r2 * s[i], z, 0, 0); + vertex(r2 * c[i], r2 * s[i], -z, 0, 16); + vertex(r2 * c[i + 1], r2 * s[i + 1], -z, 16, 16); + vertex(r2 * c[i + 1], r2 * s[i + 1], z, 16, 0); + break; + case Inner: + glNormal3d(-c[i], -s[i], 0); + vertex(r1 * c[i], r1 * s[i], -z, 0, 0); + vertex(r1 * c[i], r1 * s[i], z, 0, 16); + vertex(r1 * c[i + 1], r1 * s[i + 1], z, 16, 16); + vertex(r1 * c[i + 1], r1 * s[i + 1], -z, 16, 0); + break; } // Back glNormal3f(0, 0, -1); @@ -145,13 +136,13 @@ void renderRing(double r1, double r2, RingType type, double dz) { glNormal3f(0, 0, 1); switch (type) { case Outer: - selectTile(ringFaceTextureIndex); + selectTile(TextureIndex.RING_FACE); u = 0; du = 16; dv = 16; break; case Inner: - selectTile(ringSymbolTextureIndex); + selectTile(TextureIndex.RING_SYMBOL); u = ringSymbolTextureLength - (i + 1) * ringSymbolSegmentWidth; du = ringSymbolSegmentWidth; dv = ringSymbolTextureHeight; @@ -199,7 +190,7 @@ void chevron(boolean engaged) { glTranslated(-chevronMotionDistance, 0, 0); glBegin(GL_QUADS); - selectTile(chevronTextureIndex); + selectTile(TextureIndex.CHEVRON); // Face 1 vertex(x2, y2, z1, 0, 2); @@ -257,7 +248,7 @@ void chevron(boolean engaged) { glEnd(); - selectTile(chevronLitTextureIndex); + selectTile(TextureIndex.CHEVRON_LIT); if (!engaged) glColor3d(0.5, 0.5, 0.5); else { @@ -298,12 +289,18 @@ protected static void setLightingDisabled(boolean off) { OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } - void renderEventHorizon(SGBaseTE te) { - bindTexture(SGCraft.mod.resourceLocation("textures/tileentity/eventhorizon.png")); + void renderEventHorizon(SGBaseTE te, float partialTicks) { + if (SGCraft.useHDEventHorizionTexture) { + bindTexture(SGCraft.mod.resourceLocation("textures/tileentity/eventhorizonhd.png")); + } else { + bindTexture(SGCraft.mod.resourceLocation("textures/tileentity/eventhorizon.png")); + } + GL11.glDisable(GL_LIGHTING); + setLightingDisabled(true); glDisable(GL_CULL_FACE); glNormal3d(0, 0, 1); double grid[][] = te.getEventHorizonGrid()[0]; - double rclip = 2.5 * (te.irisIsClosed() ? te.getIrisAperture(0) : 1.0); + double rclip = 2.5 * (te.irisIsClosed() ? te.getIrisAperture(partialTicks) : 1.0); for (int i = 1; i < ehGridRadialSize; i++) { glBegin(GL_QUAD_STRIP); for (int j = 0; j <= ehGridPolarSize; j++) { @@ -320,6 +317,8 @@ void renderEventHorizon(SGBaseTE te) { glEnd(); glDepthMask(true); glEnable(GL_CULL_FACE); + GL11.glEnable(GL_LIGHTING); + setLightingDisabled(false); } void ehVertex(double[][] grid, int i, int j, double rclip) { @@ -381,9 +380,9 @@ void renderIrisBlade(SGBaseTE te, double a, double t) { glPopMatrix(); } - void selectTile(int index) { - u0 = (index % textureTilesWide) * (textureScaleU * 16); - v0 = (index / textureTilesWide) * (textureScaleV * 16); + void selectTile(TextureIndex index) { + u0 = (index.index % textureTilesWide) * (textureScaleU * 16); + v0 = (index.index / textureTilesWide) * (textureScaleV * 16); } void vertex(double x, double y, double z, double u, double v) { @@ -393,6 +392,20 @@ void vertex(double x, double y, double z, double u, double v) { } +enum TextureIndex { + RING_FACE(1), + RING(0), + RING_SYMBOL(32), + CHEVRON(3), + CHEVRON_LIT(2); + + public final int index; + + TextureIndex(int index) { + this.index = index; + } +} + enum RingType { Inner, Outer } diff --git a/src/mod/gcewing/sg/SGBlock.java b/src/mod/gcewing/sg/SGBlock.java index 463f61a0..b2ce09c7 100644 --- a/src/mod/gcewing/sg/SGBlock.java +++ b/src/mod/gcewing/sg/SGBlock.java @@ -20,12 +20,10 @@ public SGBlock(Material material, Class teClass) { } @Override - public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, - boolean willHarvest) - { + public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (player.capabilities.isCreativeMode && isConnected(world, pos)) { if (world.isRemote) - SGBaseTE.sendChatMessage(player, "Disconnect stargate before breaking"); + SGBaseTE.sendErrorMsg(player, "disconnectFirst"); return false; } return super.removedByPlayer(state, world, pos, player, willHarvest); diff --git a/src/mod/gcewing/sg/SGChannel.java b/src/mod/gcewing/sg/SGChannel.java index 12d5d6bb..e9a5b939 100644 --- a/src/mod/gcewing/sg/SGChannel.java +++ b/src/mod/gcewing/sg/SGChannel.java @@ -32,25 +32,60 @@ public static void sendConnectOrDisconnectToServer(SGBaseTE te, String address) public void handleConnectOrDisconnectFromClient(EntityPlayer player, ChannelInput data) { BlockPos pos = readCoords(data); String address = data.readUTF(); - SGBaseTE te = SGBaseTE.at(player.worldObj, pos); - if (te != null) + SGBaseTE te = SGBaseTE.at(player.world, pos); + if (te != null) { te.connectOrDisconnect(address, player); + } } - public static void sendEnteredAddressToServer(DHDTE te, String address) { - ChannelOutput data = channel.openServer("EnteredAddress"); + public static void sendClearAddressToServer(DHDTE te) { + ChannelOutput data = channel.openServer("ClearAddress"); writeCoords(data, te); - data.writeUTF(address); data.close(); } - @ServerMessageHandler("EnteredAddress") - public void handleEnteredAddressFromClient(EntityPlayer player, ChannelInput data) { + @ServerMessageHandler("ClearAddress") + public void handleClearAddressFromClient(EntityPlayer player, ChannelInput data) { BlockPos pos = readCoords(data); - String address = data.readUTF(); - DHDTE te = DHDTE.at(player.worldObj, pos); + DHDTE te = DHDTE.at(player.world, pos); if (te != null) - te.setEnteredAddress(address); + te.clearAddress(); + } + + public static void sendUnsetSymbolToServer(DHDTE te) { + ChannelOutput data = channel.openServer("UnsetSymbol"); + writeCoords(data, te); + data.close(); + } + + @ServerMessageHandler("UnsetSymbol") + public void handleUnsetSymbolFromClient(EntityPlayer player, ChannelInput data) { + BlockPos pos = readCoords(data); + if (player.world.isBlockLoaded(pos)) { + DHDTE te = DHDTE.at(player.world, pos); + if (te != null) { + te.unsetSymbol(); + } + } + } + + public static void sendEnterSymbolToServer(DHDTE te, char symbol) { + ChannelOutput data = channel.openServer("EnterSymbol"); + writeCoords(data, te); + data.writeChar(symbol); + data.close(); + } + + @ServerMessageHandler("EnterSymbol") + public void handleEnterSymbolFromClient(EntityPlayer player, ChannelInput data) { + BlockPos pos = readCoords(data); + char symbol = data.readChar(); + if (player.world.isBlockLoaded(pos)) { + DHDTE te = DHDTE.at(player.world, pos); + if (te != null) { + te.enterSymbol(symbol); + } + } } public static void writeCoords(ChannelOutput data, TileEntity te) { @@ -60,5 +95,4 @@ public static void writeCoords(ChannelOutput data, TileEntity te) { public BlockPos readCoords(ChannelInput data) { return BaseBlockUtils.readBlockPos(data); } - } diff --git a/src/mod/gcewing/sg/SGChevronUpgradeItem.java b/src/mod/gcewing/sg/SGChevronUpgradeItem.java index 10260afa..2c7cdc16 100644 --- a/src/mod/gcewing/sg/SGChevronUpgradeItem.java +++ b/src/mod/gcewing/sg/SGChevronUpgradeItem.java @@ -16,15 +16,14 @@ public class SGChevronUpgradeItem extends Item { @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, - BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { - System.out.printf("SGChevronUpgradeItem.onItemUse: at %s\n", pos); + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, + float hitX, float hitY, float hitZ) { + Block block = world.getBlockState(pos).getBlock(); if (block instanceof ISGBlock) { SGBaseTE te = ((ISGBlock)block).getBaseTE(world, pos); if (te != null) - return te.applyChevronUpgrade(stack, player); + return te.applyChevronUpgrade(player.getHeldItem(hand), player); } return EnumActionResult.FAIL; } diff --git a/src/mod/gcewing/sg/SGChunkData.java b/src/mod/gcewing/sg/SGChunkData.java index f875434c..e044a990 100644 --- a/src/mod/gcewing/sg/SGChunkData.java +++ b/src/mod/gcewing/sg/SGChunkData.java @@ -6,16 +6,12 @@ package gcewing.sg; -import java.util.*; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.event.world.ChunkDataEvent; -import net.minecraft.nbt.*; -import net.minecraft.util.math.*; -import net.minecraft.world.*; -import net.minecraft.world.chunk.*; - -import net.minecraftforge.common.*; -import net.minecraftforge.event.*; -import net.minecraftforge.event.world.*; +import java.util.HashMap; public class SGChunkData { @@ -32,7 +28,7 @@ public static SGChunkData forChunk(Chunk chunk) { public static SGChunkData forChunk(Chunk chunk, NBTTagCompound nbt) { //System.out.printf("SGChunkData.forChunk: (%d, %d): %s\n", // chunk.xPosition, chunk.zPosition, chunk); - ChunkPos coords = new ChunkPos(chunk.xPosition, chunk.zPosition); + ChunkPos coords = new ChunkPos(chunk.x, chunk.z); SGChunkData data = map.get(coords); if (data == null) { //System.out.printf("SGChunkData.forChunk: Creating new chunk data\n"); @@ -63,7 +59,7 @@ public static void onChunkLoad(ChunkDataEvent.Load e) { // chunk.xPosition, chunk.zPosition); if (!data.oresGenerated && SGCraft.addOresToExistingWorlds) { if (debug) - System.out.printf("SGChunkData.onChunkLoad: Adding ores to chunk (%d, %d)\n", chunk.xPosition, chunk.zPosition); + System.out.printf("SGChunkData.onChunkLoad: Adding ores to chunk (%d, %d)\n", chunk.x, chunk.z); SGCraft.naquadahOreGenerator.regenerate(chunk); } } diff --git a/src/mod/gcewing/sg/SGCraft.java b/src/mod/gcewing/sg/SGCraft.java index 8a40434d..a961726b 100644 --- a/src/mod/gcewing/sg/SGCraft.java +++ b/src/mod/gcewing/sg/SGCraft.java @@ -6,37 +6,46 @@ package gcewing.sg; -import java.util.*; - -import net.minecraft.block.*; -import net.minecraft.block.material.*; +import gcewing.sg.oc.OCIntegration; +import gcewing.sg.rf.RFIntegration; +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SoundHandler; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.*; -import net.minecraft.item.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraft.world.*; -import net.minecraft.world.chunk.*; -import net.minecraft.world.gen.structure.*; - -import net.minecraftforge.common.*; -import net.minecraftforge.event.*; -import net.minecraftforge.event.world.*; -import net.minecraftforge.event.terraingen.*; - -import net.minecraftforge.fml.common.*; -import net.minecraftforge.fml.common.event.*; -import net.minecraftforge.fml.common.gameevent.*; -import net.minecraftforge.fml.common.eventhandler.*; -import net.minecraftforge.fml.common.registry.*; -import static net.minecraftforge.fml.common.registry.VillagerRegistry.*; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.InitMapGenEvent; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Mod; +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.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import static net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; +import static net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; // import dan200.computercraft.api.*; //[CC] -// import gcewing.sg.cc.*; //[CC] -import gcewing.sg.oc.*; //[OC] @Mod(modid = Info.modID, name = Info.modName, version = Info.versionNumber, - acceptableRemoteVersions = Info.versionBounds) + acceptableRemoteVersions = Info.versionBounds, dependencies = "after:opencomputers;after:ic2;after:computercraft") public class SGCraft extends BaseMod { @@ -64,36 +73,64 @@ public class SGCraft extends BaseMod { public static NaquadahOreWorldGen naquadahOreGenerator; // public static int tokraVillagerID; - public static boolean rfAvailable; - public static BaseSubsystem ic2Integration; //[IC2] -// public static IIntegration ccIntegration; //[CC] + public static IIntegration ccIntegration; //[CC] public static OCIntegration ocIntegration; //[OC] + public static RFIntegration rfIntegration; //[RF] // public static MystcraftIntegration mystcraftIntegration; //[MYST] + // Villager Profession for Generators + public static VillagerProfession tokraProfession; + + // Block Harvests + public static boolean canHarvestDHD = false; + public static boolean canHarvestSGBaseBlock = false; + public static boolean canHarvestSGRingBlock = false; + + // IC2 Options + public static int Ic2SafeInput = 2048; + public static int Ic2MaxEnergyBuffer = 1000000; + public static double Ic2euPerSGEnergyUnit = 20.0; + public static int Ic2PowerTETier = 3; + + // Redstone Flux Options + public static int RfMaxEnergyBuffer = 4000000; + public static double RfPerSGEnergyUnit = 80.0; + + //Client Options + public static boolean useHDEventHorizionTexture = true; + public static boolean saveAddressToClipboard = false; + public static boolean displayGuiPowerDebug = true; + + //World data fixes + public static boolean forceDHDCfgUpdate = false; + public static boolean forceIC2CfgUpdate = false; + public static boolean forceRFCfgUpdate = false; + public SGCraft() { mod = this; creativeTab = new CreativeTabs("sgcraft:sgcraft") { - public Item getTabIconItem() { - return Item.getItemFromBlock(sgBaseBlock); + @Override + public ItemStack createIcon() { + return new ItemStack(Item.getItemFromBlock(sgBaseBlock)); } }; } @Mod.EventHandler + @Override public void preInit(FMLPreInitializationEvent e) { FMLCommonHandler.instance().bus().register(this); - rfAvailable = classAvailable("cofh.api.energy.IEnergyConnection"); - if (rfAvailable) - loadSubsystem("gcewing.sg.rf.RFIntegration"); //[RF] - ic2Integration = integrateWithMod("IC2", "gcewing.sg.ic2.IC2Integration"); //[IC2] -// ccIntegration = (CCIntegration)integrateWithMod("ComputerCraft", "gcewing.sg.cc.CCIntegration"); //[CC] - ocIntegration = (OCIntegration)integrateWithMod("OpenComputers", "gcewing.sg.oc.OCIntegration"); //[OC] + rfIntegration = (RFIntegration) integrateWithMod("redstoneflux", "gcewing.sg.rf.RFIntegration"); //[RF] + ic2Integration = integrateWithMod("ic2", "gcewing.sg.ic2.IC2Integration"); //[IC2] + ccIntegration = (IIntegration) integrateWithMod("computercraft", "gcewing.sg.cc.CCIntegration"); //[CC] + ocIntegration = (OCIntegration)integrateWithMod("opencomputers", "gcewing.sg.oc.OCIntegration"); //[OC] // mystcraftIntegration = (MystcraftIntegration)integrateWithMod("Mystcraft", "gcewing.sg.MystcraftIntegration"); //[MYST] super.preInit(e); } @Mod.EventHandler + @Override public void init(FMLInitializationEvent e) { super.init(e); System.out.printf("SGCraft.init\n"); @@ -103,6 +140,7 @@ public void init(FMLInitializationEvent e) { } @Mod.EventHandler + @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } @@ -112,13 +150,18 @@ protected SGCraftClient initClient() { return new SGCraftClient(this); } + @Override void configure() { DHDTE.configure(config); NaquadahOreWorldGen.configure(config); SGBaseBlock.configure(config); SGBaseTE.configure(config); FeatureGeneration.configure(config); + // Server-Side Options addOresToExistingWorlds = config.getBoolean("options", "addOresToExistingWorlds", false); + // Client-Side Options + useHDEventHorizionTexture = config.getBoolean("client", "useHDEventHorizonTexture", useHDEventHorizionTexture); + saveAddressToClipboard = config.getBoolean("client", "saveAddressToClipboard", saveAddressToClipboard); } @Override @@ -134,6 +177,7 @@ protected void registerBlocks() { //sgPortalBlock = newBlock("stargatePortal", SGPortalBlock.class); naquadahBlock = newBlock("naquadahBlock", NaquadahBlock.class); naquadahOre = newBlock("naquadahOre", NaquadahOreBlock.class); + this.setOptions(); } @Override @@ -145,10 +189,26 @@ protected void registerItems() { sgChevronUpgrade = addItem(new SGChevronUpgradeItem(), "sgChevronUpgrade"); sgIrisUpgrade = addItem(new SGIrisUpgradeItem(), "sgIrisUpgrade"); sgIrisBlade = newItem("sgIrisBlade"); - if (isModLoaded("IC2") || (rfAvailable && !isModLoaded("ThermalExpansion"))) { + if (isModLoaded("ic2") || !isModLoaded("thermalexpansion")) { ic2Capacitor = newItem("ic2Capacitor"); } } + + @SideOnly(Side.CLIENT) + public static void playSound(SoundSource source, SoundEvent sound) { + playSound(source, sound, SoundCategory.AMBIENT); + } + + @SideOnly(Side.CLIENT) + public static void playSound(SoundSource source, SoundEvent sound, SoundCategory category) { + SoundHandler soundHandler = getSoundHandler(); + soundHandler.playSound(new Sound(source, sound, category)); + } + + @SideOnly(Side.CLIENT) + private static SoundHandler getSoundHandler() { + return Minecraft.getMinecraft().getSoundHandler(); + } public static boolean isValidStargateUpgrade(Item item) { return item == sgChevronUpgrade || item == sgIrisUpgrade; @@ -160,7 +220,7 @@ protected void registerOres() { addOre("naquadah", naquadah); addOre("ingotNaquadahAlloy", naquadahIngot); } - + @Override protected void registerRecipes() { ItemStack chiselledSandstone = new ItemStack(Blocks.SANDSTONE, 1, 1); @@ -168,42 +228,67 @@ protected void registerRecipes() { ItemStack sgChevronBlock = new ItemStack(sgRingBlock, 1, 1); ItemStack blueDye = new ItemStack(Items.DYE, 1, 4); ItemStack orangeDye = new ItemStack(Items.DYE, 1, 14); - if (config.getBoolean("options", "allowCraftingNaquadah", false)) - newShapelessRecipe(naquadah, 1, Items.COAL, Items.SLIME_BALL, Items.BLAZE_POWDER); - newRecipe(sgRingBlock, 1, "CCC", "NNN", "SSS", - 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone); - newRecipe(sgChevronBlock, "CgC", "NpN", "SrS", - 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone, - 'g', Items.GLOWSTONE_DUST, 'r', Items.REDSTONE, 'p', Items.ENDER_PEARL); - newRecipe(sgBaseBlock, 1, "CrC", "NeN", "ScS", - 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone, - 'r', Items.REDSTONE, 'e', Items.ENDER_EYE, 'c', sgCoreCrystal); - newRecipe(sgControllerBlock, 1, "bbb", "OpO", "OcO", - 'b', Blocks.STONE_BUTTON, 'O', Blocks.OBSIDIAN, 'p', Items.ENDER_PEARL, - 'r', Items.REDSTONE, 'c', sgControllerCrystal); - newShapelessRecipe(naquadahIngot, 1, "naquadah", Items.IRON_INGOT); - newRecipe(naquadahBlock, 1, "NNN", "NNN", "NNN", 'N', "ingotNaquadahAlloy"); - newRecipe(sgChevronUpgrade, 1, "g g", "pNp", "r r", - 'N', "ingotNaquadahAlloy", - 'g', Items.GLOWSTONE_DUST, 'r', Items.REDSTONE, 'p', Items.ENDER_PEARL); - newRecipe(naquadahIngot, 9, "B", 'B', naquadahBlock); - newRecipe(sgIrisBlade, 1, " ii", "ic ", "i ", - 'i', Items.IRON_INGOT, 'c', new ItemStack(Items.COAL, 1, 1)); - newRecipe(sgIrisUpgrade, 1, "bbb", "brb", "bbb", - 'b', sgIrisBlade, 'r', Items.REDSTONE); - if (config.getBoolean("options", "allowCraftingCrystals", false)) { - newRecipe(sgCoreCrystal, 1, "bbr", "rdb", "brb", - 'b', blueDye, 'r', Items.REDSTONE, 'd', Items.DIAMOND); - newRecipe(sgControllerCrystal, 1, "roo", "odr", "oor", - 'o', orangeDye, 'r', Items.REDSTONE, 'd', Items.DIAMOND); + + if (config.getBoolean("recipes", "naquadah", false)) { + newShapelessRecipe("naquada", naquadah, 1, Ingredient.fromItems(Items.COAL, Items.SLIME_BALL, Items.BLAZE_POWDER)); + } + + if (config.getBoolean("recipes", "naquadahIngot", true)) { + newShapelessRecipe("naquadahingot", naquadahIngot, 1, Ingredient.fromItem(Items.IRON_INGOT), Ingredient.fromItem(naquadah)); + } + + if (config.getBoolean("recipes", "naquadahIngotFromBlock", true)) { + newRecipe("naquadahingot_from_block", naquadahIngot, 9, "B", 'B', naquadahBlock); + } + + if (config.getBoolean("recipes", "naquadahBlock", true)) { + newRecipe("naquadahblock", naquadahBlock, 1, "NNN", "NNN", "NNN", 'N', "ingotNaquadahAlloy"); + } + + if (config.getBoolean("recipes", "sgRingBlock", true)) { + newRecipe("sgringblock", sgRingBlock, 1, "CCC", "NNN", "SSS", 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone); + } + + if (config.getBoolean("recipes", "sgChevronBlock", true)) { + newRecipe("sgcheveronblock", sgChevronBlock, "CgC", "NpN", "SrS", 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone, 'g', Items.GLOWSTONE_DUST, 'r', Items.REDSTONE, 'p', Items.ENDER_PEARL); + } + + if (config.getBoolean("recipes", "sgBaseBlock", true)) { + newRecipe("sgbaseblock", sgBaseBlock, 1, "CrC", "NeN", "ScS", 'S', smoothSandstone, 'N', "ingotNaquadahAlloy", 'C', chiselledSandstone, 'r', Items.REDSTONE, 'e', Items.ENDER_EYE, 'c', sgCoreCrystal); } - if (rfAvailable && !isModLoaded("IC2")) + + if (config.getBoolean("recipes", "sgControllerBlock", true)) { + newRecipe("sgcontrollerblock", sgControllerBlock, 1, "bbb", "OpO", "OcO", 'b', Blocks.STONE_BUTTON, 'O', Blocks.OBSIDIAN, 'p', Items.ENDER_PEARL, 'c', sgControllerCrystal); + } + + if (config.getBoolean("recipes", "sgChevronUpgradeItem", true)) { + newRecipe("sgchevronupgrade", sgChevronUpgrade, 1, "g g", "pNp", "r r", 'N', "ingotNaquadahAlloy", 'g', Items.GLOWSTONE_DUST, 'r', Items.REDSTONE, 'p', Items.ENDER_PEARL); + } + + if (config.getBoolean("recipes", "sgIrisBladeItem", true)) { + newRecipe("sgirisblade", sgIrisBlade, 1, " ii", "ic ", "i ", 'i', Items.IRON_INGOT, 'c', new ItemStack(Items.COAL, 1, 1)); + } + + if (config.getBoolean("recipes", "sgIrisUpgradeItem", true)) { + newRecipe("sgirisupgrade", sgIrisUpgrade, 1, "bbb", "brb", "bbb", 'b', sgIrisBlade, 'r', Items.REDSTONE); + } + + if (config.getBoolean("recipes", "sgCoreCrystalItem", false)) { + newRecipe("sgcorecrystal", sgCoreCrystal, 1, "bbr", "rdb", "brb", 'b', blueDye, 'r', Items.REDSTONE, 'd', Items.DIAMOND); + } + + if (config.getBoolean("recipes", "sgControllerCrystalItem", false)) { + newRecipe("sgcontrollercrystal", sgControllerCrystal, 1, "roo", "odr", "oor", 'o', orangeDye, 'r', Items.REDSTONE, 'd', Items.DIAMOND); + } + + if (!isModLoaded("ic2")) addGenericCapacitorRecipe(); } - + protected void addGenericCapacitorRecipe() { - newRecipe(ic2Capacitor, 1, "iii", "ppp", "iii", - 'i', "ingotIron", 'p', "paper"); + if (config.getBoolean("recipes", "genericCapacitorItem", true)) { + newRecipe("ic2capacitor", ic2Capacitor, 1, "iii", "ppp", "iii", 'i', "ingotIron", 'p', "paper"); + } } @Override @@ -220,21 +305,21 @@ protected void registerWorldGenerators() { naquadahOreGenerator = new NaquadahOreWorldGen(); GameRegistry.registerWorldGenerator(naquadahOreGenerator, 0); } - MapGenStructureIO.registerStructureComponent(FeatureUnderDesertPyramid.class, - "SGCraft:FeatureUnderDesertPyramid"); + MapGenStructureIO.registerStructureComponent(FeatureUnderDesertPyramid.class, "SGCraft:FeatureUnderDesertPyramid"); } @Override //[VILL] protected void registerVillagers() { - VillagerProfession tokraProfession = new VillagerProfession("sgcraft:tokra", "sgcraft:textures/skins/tokra.png"); + tokraProfession = new VillagerProfession("sgcraft:tokra", "sgcraft:textures/skins/tokra.png","sgcraft:textures/skins/tokra.png"); + // Update: Needs new skin for Zombie mode? VillagerCareer tokraCareer = new VillagerCareer(tokraProfession, "sgcraft:tokra"); tokraCareer.addTrade(1, new SGTradeHandler()); - VillagerRegistry.instance().register(tokraProfession); + ForgeRegistries.VILLAGER_PROFESSIONS.register(tokraProfession); } @Override protected void registerEntities() { - addEntity(IrisEntity.class, "Stargate Iris", SGEntity.Iris, 1000000, false); + addEntity(EntityStargateIris.class, "stargate_iris", SGEntity.Iris, 1000000, false); } @Override @@ -284,4 +369,25 @@ public void onChunkUnload(ChunkEvent.Unload e) { } } + private void setOptions() { + // Block Harvests + canHarvestDHD = config.getBoolean("block-harvest", "dhdBlock", canHarvestDHD); + canHarvestSGBaseBlock = config.getBoolean("block-harvest", "sgBaseBlock", canHarvestSGBaseBlock); + canHarvestSGRingBlock = config.getBoolean("block-harvest", "sgRingBlock", canHarvestSGRingBlock); + + // IC2 + Ic2SafeInput = config.getInteger("ic2", "safeInputRate", Ic2SafeInput); + Ic2MaxEnergyBuffer = config.getInteger("ic2", "energyBufferSize", Ic2MaxEnergyBuffer); + Ic2euPerSGEnergyUnit = config.getDouble("ic2", "euPerSGEnergyUnit", Ic2euPerSGEnergyUnit); + Ic2PowerTETier = config.getInteger("ic2", "PowerTETier", Ic2PowerTETier); + + // Redstone Flux + RfMaxEnergyBuffer = config.getInteger("rf", "energyBufferSize", RfMaxEnergyBuffer); + RfPerSGEnergyUnit = config.getDouble("rf", "rfPerSGEnergyUnit", RfPerSGEnergyUnit); + + // World Update / Fixes + forceDHDCfgUpdate = config.getBoolean("dhd", "force-update", forceDHDCfgUpdate); + forceIC2CfgUpdate = config.getBoolean("ic2", "force-update", forceIC2CfgUpdate); + forceRFCfgUpdate = config.getBoolean("rf", "force-update", forceRFCfgUpdate); + } } diff --git a/src/mod/gcewing/sg/SGCraftClient.java b/src/mod/gcewing/sg/SGCraftClient.java index ab5e9360..3ca2de4d 100644 --- a/src/mod/gcewing/sg/SGCraftClient.java +++ b/src/mod/gcewing/sg/SGCraftClient.java @@ -6,10 +6,6 @@ package gcewing.sg; -import net.minecraft.client.gui.*; -import net.minecraft.entity.player.*; -import net.minecraft.world.*; - // import gcewing.sg.ic2.*; //[IC2] public class SGCraftClient extends BaseModClient { @@ -37,7 +33,7 @@ protected void registerTileEntityRenderers() { @Override protected void registerEntityRenderers() { - addEntityRenderer(IrisEntity.class, IrisRenderer.class); + addEntityRenderer(EntityStargateIris.class, IrisRenderer.class); } } diff --git a/src/mod/gcewing/sg/SGDimensionMap.java b/src/mod/gcewing/sg/SGDimensionMap.java index cd397170..0f904630 100644 --- a/src/mod/gcewing/sg/SGDimensionMap.java +++ b/src/mod/gcewing/sg/SGDimensionMap.java @@ -27,7 +27,7 @@ public SGDimensionMap(String name) { public static SGDimensionMap get() { World world = BaseUtils.getWorldForDimension(0); - return BaseUtils.getWorldData(world, SGDimensionMap.class, "sgcraft:dimension_map"); + return BaseUtils.getWorldData(world, SGDimensionMap.class, "sgcraft-dimension_map"); } public static Integer dimensionForIndex(int index) { diff --git a/src/mod/gcewing/sg/SGGui.java b/src/mod/gcewing/sg/SGGui.java index aba68e88..9dfc9a02 100644 --- a/src/mod/gcewing/sg/SGGui.java +++ b/src/mod/gcewing/sg/SGGui.java @@ -7,5 +7,5 @@ package gcewing.sg; public enum SGGui { - SGBase, SGController, DHDFuel, /*IC2*/PowerUnit, OCInterface; + SGBase, SGController, DHDFuel, /*IC2*/PowerUnit, OCInterface } diff --git a/src/mod/gcewing/sg/SGInterfaceBlock.java b/src/mod/gcewing/sg/SGInterfaceBlock.java index 3b3a4fee..ab1ade5a 100644 --- a/src/mod/gcewing/sg/SGInterfaceBlock.java +++ b/src/mod/gcewing/sg/SGInterfaceBlock.java @@ -12,7 +12,6 @@ import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.util.*; public class SGInterfaceBlock extends BaseBlock { diff --git a/src/mod/gcewing/sg/SGInterfaceTE.java b/src/mod/gcewing/sg/SGInterfaceTE.java index 4b9bddc9..2e05ef85 100644 --- a/src/mod/gcewing/sg/SGInterfaceTE.java +++ b/src/mod/gcewing/sg/SGInterfaceTE.java @@ -6,7 +6,6 @@ package gcewing.sg; -import net.minecraft.tileentity.*; import gcewing.sg.SGAddressing.AddressingError; public class SGInterfaceTE extends BaseTileEntity { @@ -21,10 +20,8 @@ public static Object[] prependArgs(Object... args) { int preLength = args.length - 1; Object[] post = (Object[])args[preLength]; Object[] xargs = new Object[preLength + post.length]; - for (int i = 0; i < preLength; i++) - xargs[i] = args[i]; - for (int i = 0; i < post.length; i++) - xargs[preLength + i] = post[i]; + System.arraycopy(args, 0, xargs, 0, preLength); + System.arraycopy(post, 0, xargs, preLength, post.length); return xargs; } @@ -46,7 +43,7 @@ public SGBaseTE requireBaseTE() { SGBaseTE te = getBaseTE(); if (te != null && te.isMerged) return te; - throw new IllegalArgumentException("No stargate connected to interface"); + throw new IllegalArgumentException("missingStargate"); } public SGBaseTE requireIrisTE() { @@ -54,18 +51,11 @@ public SGBaseTE requireIrisTE() { if (te != null && te.hasIrisUpgrade) return te; else - throw new IllegalArgumentException("No iris fitted to stargate"); + throw new IllegalArgumentException("missingIris"); } String directionDescription(SGBaseTE te) { - if (te.isConnected()) { - if (te.isInitiator) - return "Outgoing"; - else - return "Incoming"; - } - else - return ""; + return te.isConnected() ? te.isInitiator ? "Outgoing" : "Incoming" : ""; } public CIStargateState ciStargateState() { @@ -78,10 +68,7 @@ public CIStargateState ciStargateState() { public double ciEnergyAvailable() { SGBaseTE te = getBaseTE(); - if (te != null) - return te.availableEnergy(); - else - return 0; + return te != null ? te.availableEnergy() : 0; } public double ciEnergyToDial(String address) { @@ -90,12 +77,11 @@ public double ciEnergyToDial(String address) { address = SGAddressing.normalizeAddress(address); SGBaseTE dte = SGAddressing.findAddressedStargate(address, te.getWorld()); if (dte == null) - throw new IllegalArgumentException("No stargate at address " + address); + throw new IllegalArgumentException("unknownAddress"); double distanceFactor = SGBaseTE.distanceFactorForCoordDifference(te, dte); return SGBaseTE.energyToOpen * distanceFactor; - } - catch (AddressingError e) { - System.out.printf("SGBaseTE.ciEnergyToDial: caught %s\n", e); + } catch (AddressingError e) { + //System.out.printf("SGBaseTE.ciEnergyToDial: caught %s\n", e); throw new IllegalArgumentException(e.getMessage()); } } @@ -103,12 +89,8 @@ public double ciEnergyToDial(String address) { public String ciLocalAddress() { SGBaseTE te = getBaseTE(); try { - if (te != null) - return te.getHomeAddress(); - else - return ""; - } - catch (AddressingError e) { + return te != null ? te.getHomeAddress() : ""; + } catch (AddressingError e) { throw new IllegalArgumentException(e.getMessage()); } } @@ -116,12 +98,8 @@ public String ciLocalAddress() { public String ciRemoteAddress() { SGBaseTE te = requireBaseTE(); try { - if (te.connectedLocation != null) - return SGAddressing.addressForLocation(te.connectedLocation); - else - return ""; - } - catch (AddressingError e) { + return te.connectedLocation != null ? SGAddressing.addressForLocation(te.connectedLocation) : ""; + } catch (AddressingError e) { throw new IllegalArgumentException(e.getMessage()); } } @@ -135,25 +113,22 @@ public void ciDial(String address) { // throw new IllegalArgumentException(e.getMessage()); // } address = SGAddressing.normalizeAddress(address); - System.out.printf("SGBaseTE.ciDial: dialling symbols %s\n", address); - String error = te.connect(address, null); + //System.out.printf("SGBaseTE.ciDial: dialling symbols %s\n", address); + String error = te.connect(address, null, false); if (error != null) throw new IllegalArgumentException(error); } public void ciDisconnect() { SGBaseTE te = requireBaseTE(); - String error = te.attemptToDisconnect(null); + String error = te.disconnect(null); if (error != null) throw new IllegalArgumentException(error); } public String ciIrisState() { SGBaseTE te = getBaseTE(); - if (te != null && te.hasIrisUpgrade) - return te.irisStateDescription(); - else - return "Offline"; + return te != null && te.hasIrisUpgrade ? te.irisStateDescription() : "Offline"; } public void ciOpenIris() { diff --git a/src/mod/gcewing/sg/SGIrisUpgradeItem.java b/src/mod/gcewing/sg/SGIrisUpgradeItem.java index 8830a03b..77e7f672 100644 --- a/src/mod/gcewing/sg/SGIrisUpgradeItem.java +++ b/src/mod/gcewing/sg/SGIrisUpgradeItem.java @@ -16,7 +16,7 @@ public class SGIrisUpgradeItem extends Item { @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { //System.out.printf("SGIrisUpgradeItem.onItemUse: at %s\n", pos); @@ -24,7 +24,7 @@ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World wo if (block instanceof ISGBlock) { SGBaseTE te = ((ISGBlock)block).getBaseTE(world, pos); if (te != null) - return te.applyIrisUpgrade(stack, player); + return te.applyIrisUpgrade(player.getHeldItem(hand), player); } return EnumActionResult.FAIL; } diff --git a/src/mod/gcewing/sg/SGLocation.java b/src/mod/gcewing/sg/SGLocation.java index a18ba10a..04e7d81d 100644 --- a/src/mod/gcewing/sg/SGLocation.java +++ b/src/mod/gcewing/sg/SGLocation.java @@ -8,12 +8,9 @@ import net.minecraft.nbt.*; import net.minecraft.tileentity.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.*; - public class SGLocation { public int dimension; @@ -54,10 +51,6 @@ SGBaseTE getStargateTE() { return null; } TileEntity te = world.getTileEntity(pos); - if (te instanceof SGBaseTE) - return (SGBaseTE)te; - else - return null; + return te instanceof SGBaseTE ? (SGBaseTE) te : null; } - } diff --git a/src/mod/gcewing/sg/SGRingBlock.java b/src/mod/gcewing/sg/SGRingBlock.java index dc28fd9e..fbd5e4e8 100644 --- a/src/mod/gcewing/sg/SGRingBlock.java +++ b/src/mod/gcewing/sg/SGRingBlock.java @@ -6,26 +6,16 @@ package gcewing.sg; -import java.util.*; - import net.minecraft.block.*; import net.minecraft.block.material.*; import net.minecraft.block.properties.*; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.*; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.entity.*; import net.minecraft.entity.player.*; import net.minecraft.item.*; -import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; -import net.minecraftforge.fml.common.registry.*; -import net.minecraftforge.fml.relauncher.*; - import gcewing.sg.BaseMod.ModelSpec; public class SGRingBlock extends SGBlock { @@ -34,10 +24,10 @@ public class SGRingBlock extends SGBlock { public static IProperty VARIANT = PropertyInteger.create("variant", 0, 1); - static String[] textures = {"stargateBlock", "stargateRing", "stargateChevron"}; + static String[] textures = {"stargateblock", "stargatering", "stargatechevron"}; static ModelSpec models[] = { - new ModelSpec("block/sg_ring_block.smeg", "stargateBlock", "stargateRing"), - new ModelSpec("block/sg_ring_block.smeg", "stargateBlock", "stargateChevron") + new ModelSpec("block/sg_ring_block.smeg", "stargateblock", "stargatering"), + new ModelSpec("block/sg_ring_block.smeg", "stargateblock", "stargatechevron") }; static String[] subBlockTitles = { @@ -77,7 +67,7 @@ protected String getRendererClassName() { } @Override - public boolean canRenderInLayer(BlockRenderLayer layer) { + public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return true; // So that translucent camouflage blocks render correctly } @@ -98,7 +88,7 @@ public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos @Override public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player) { - return true; + return SGCraft.canHarvestSGRingBlock; } @Override @@ -108,7 +98,7 @@ public int damageDropped(IBlockState state) { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float cx, float cy, float cz) + EnumHand hand, EnumFacing side, float cx, float cy, float cz) { //System.out.printf("SGRingBlock.onBlockActivated at (%d, %d, %d)\n", x, y, z); SGRingTE te = getTileEntity(world, pos); @@ -117,7 +107,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En IBlockState baseState = world.getBlockState(te.basePos); Block block = baseState.getBlock(); if (block instanceof SGBaseBlock) - block.onBlockActivated(world, te.basePos, baseState, player, hand, heldItem, side, + block.onBlockActivated(world, te.basePos, baseState, player, hand, side, cx, cy, cz); return true; } @@ -134,11 +124,15 @@ public SGBaseTE getBaseTE(IBlockAccess world, BlockPos pos) { } @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < numSubBlocks; i++) - list.add(new ItemStack(item, 1, i)); + public void getSubBlocks(CreativeTabs tab, NonNullList list) { + for (int i = 0; i < numSubBlocks; i++) { + ItemStack item = new ItemStack(this,1,i); + list.add(item); + } + // Update: may be incorrect, needs testing. } - + + @Override public boolean isMerged(IBlockAccess world, BlockPos pos) { SGRingTE te = getTileEntity(world, pos); return te != null && te.isMerged; diff --git a/src/mod/gcewing/sg/SGRingBlockRenderer.java b/src/mod/gcewing/sg/SGRingBlockRenderer.java index ba178898..a957025a 100644 --- a/src/mod/gcewing/sg/SGRingBlockRenderer.java +++ b/src/mod/gcewing/sg/SGRingBlockRenderer.java @@ -6,16 +6,11 @@ package gcewing.sg; -import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.*; import net.minecraft.item.*; import net.minecraft.world.*; -import net.minecraft.world.biome.*; -import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.math.*; -import net.minecraftforge.common.util.*; import gcewing.sg.BaseModClient.*; @@ -39,7 +34,7 @@ public void renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, IRe Item item = stack.getItem(); if (item instanceof ItemBlock) { IBlockState camoState = BaseBlockUtils.getBlockStateFromItemStack(stack); - if (camoState.getBlock().canRenderInLayer(layer)) { + if (camoState.getBlock().canRenderInLayer(camoState,layer)) { //System.out.printf("SGRingBlockRenderer: Rendering camouflage block %s at %s in layer %s\n", // camoState, pos, layer); BaseRenderingManager.renderAlternateBlock(SGCraft.mod.client, world, pos, camoState, target); diff --git a/src/mod/gcewing/sg/SGRingItem.java b/src/mod/gcewing/sg/SGRingItem.java index f80bd41e..a004f8dd 100644 --- a/src/mod/gcewing/sg/SGRingItem.java +++ b/src/mod/gcewing/sg/SGRingItem.java @@ -8,7 +8,6 @@ import net.minecraft.block.*; import net.minecraft.item.*; -import net.minecraft.util.*; public class SGRingItem extends ItemBlock { @@ -23,8 +22,8 @@ public int getMetadata(int i) { } @Override - public String getUnlocalizedName(ItemStack stack) { - return String.format("%s.%s", super.getUnlocalizedName(stack), stack.getItemDamage()); + public String getTranslationKey(ItemStack stack) { + return String.format("%s.%s", super.getTranslationKey(stack), stack.getItemDamage()); } } diff --git a/src/mod/gcewing/sg/SGRingTE.java b/src/mod/gcewing/sg/SGRingTE.java index 8cd06ef1..e4bbbef6 100644 --- a/src/mod/gcewing/sg/SGRingTE.java +++ b/src/mod/gcewing/sg/SGRingTE.java @@ -39,7 +39,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { public SGBaseTE getBaseTE() { if (isMerged) { - TileEntity bte = worldObj.getTileEntity(basePos); + TileEntity bte = world.getTileEntity(basePos); if (bte instanceof SGBaseTE) return (SGBaseTE)bte; } diff --git a/src/mod/gcewing/sg/SGScreen.java b/src/mod/gcewing/sg/SGScreen.java index 34e767ed..3ea89173 100644 --- a/src/mod/gcewing/sg/SGScreen.java +++ b/src/mod/gcewing/sg/SGScreen.java @@ -6,19 +6,11 @@ package gcewing.sg; -import org.lwjgl.input.*; -import org.lwjgl.opengl.*; import static org.lwjgl.opengl.GL11.*; import net.minecraft.client.*; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.*; -import net.minecraft.client.renderer.*; -import net.minecraft.entity.player.*; import net.minecraft.inventory.*; -import net.minecraftforge.client.*; - //------------------------------------------------------------------------------------------------ public class SGScreen extends BaseGui.Screen { @@ -35,10 +27,10 @@ public class SGScreen extends BaseGui.Screen { final static int cellSize = 24; double uscale, vscale; - float red = 1.0F, green = 1.0F, blue = 1.0F; + float red = 1F, green = 1F, blue = 1F; public SGScreen() { - super(new BaseContainer(0, 0)); + super(new BaseContainer(Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); } public SGScreen(Container container, int width, int height) { @@ -66,7 +58,7 @@ void drawAddressSymbols(int x, int y, String address) { } void drawAddressString(int x, int y, String address) { - drawCenteredString(this.fontRendererObj, address, x, y, 0xffffff); + drawCenteredString(this.fontRenderer, address, x, y, 0xffffff); } // void drawAddressString(int x, int y, String address, String caret) { diff --git a/src/mod/gcewing/sg/SGState.java b/src/mod/gcewing/sg/SGState.java index ba02b514..3250a648 100644 --- a/src/mod/gcewing/sg/SGState.java +++ b/src/mod/gcewing/sg/SGState.java @@ -1,23 +1,5 @@ -//------------------------------------------------------------------------------------------------ -// -// SG Craft - Stargate state -// -//------------------------------------------------------------------------------------------------ - package gcewing.sg; public enum SGState { - Idle, Dialling, Transient, Connected, Disconnecting, InterDialling; - - static SGState[] VALUES = values(); - - public static SGState valueOf(int i) { - try { - return VALUES[i]; - } - catch (IndexOutOfBoundsException e) { - return Idle; - } - } - + Idle, Dialing, SyncAwait, Transient, Connected, Disconnecting, InterDialing, EstablishingConnection, AttemptToDial; } diff --git a/src/mod/gcewing/sg/SGTradeHandler.java b/src/mod/gcewing/sg/SGTradeHandler.java index 2dfb2fd7..32776c32 100644 --- a/src/mod/gcewing/sg/SGTradeHandler.java +++ b/src/mod/gcewing/sg/SGTradeHandler.java @@ -11,17 +11,19 @@ // import net.minecraft.block.*; // import net.minecraft.entity.*; // import net.minecraft.entity.passive.*; +import net.minecraft.entity.IMerchant; import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.init.*; import net.minecraft.item.*; import net.minecraft.village.*; // import net.minecraftforge.fml.common.registry.*; -import net.minecraftforge.fml.common.registry.VillagerRegistry.*; + public class SGTradeHandler implements ITradeList { - public void modifyMerchantRecipeList(MerchantRecipeList recipes, Random random) { + @Override + public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipes, Random random) { recipes.add(new MerchantRecipe( new ItemStack(Items.EMERALD, 8), @@ -33,5 +35,4 @@ public void modifyMerchantRecipeList(MerchantRecipeList recipes, Random random) new ItemStack(Items.DIAMOND, 1), new ItemStack(SGCraft.sgControllerCrystal))); } - } diff --git a/src/mod/gcewing/sg/Sound.java b/src/mod/gcewing/sg/Sound.java new file mode 100644 index 00000000..3b6b0c23 --- /dev/null +++ b/src/mod/gcewing/sg/Sound.java @@ -0,0 +1,75 @@ +package gcewing.sg; + +import net.minecraft.client.audio.ITickableSound; +import net.minecraft.client.audio.PositionedSound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class Sound extends PositionedSound implements ITickableSound { + private final SoundSource source; + + public Sound(SoundSource source, SoundEvent sound, SoundCategory category) { + super(sound, category); + this.source = source; + } + + public Sound(SoundSource source, ResourceLocation sound, SoundCategory category) { + super(sound, category); + this.source = source; + } + + @Override + public boolean canRepeat() { + return this.source.isSoundRepeatable(this.getEvent()); + } + + public World getWorld() { + return this.source.getSoundWorld(); + } + + public BlockPos getPos() { + return this.source.getSoundPos(); + } + + @Override + public boolean isDonePlaying() { + return !getWorld().isBlockLoaded(getPos()) || !this.source.isSoundActive(this.getEvent()); + } + + @Override + public void update() { + this.source.updateSound(this.getEvent()); + } + + @Override + public float getXPosF() { + return (float) getPos().getX(); + } + + @Override + public float getYPosF() { + return (float) getPos().getY(); + } + + @Override + public float getZPosF() { + return (float) getPos().getZ(); + } + + @Override + public float getPitch() { + return this.source.getSoundPitch(this.getEvent()) * this.sound.getPitch(); + } + + @Override + public float getVolume() { + return this.source.getSoundVolume(this.getEvent()) * this.sound.getVolume(); + } + + public SoundEvent getEvent() { + return SoundEvent.REGISTRY.getObject(this.positionedSoundLocation); + } +} diff --git a/src/mod/gcewing/sg/SoundSource.java b/src/mod/gcewing/sg/SoundSource.java new file mode 100644 index 00000000..e56d7f8d --- /dev/null +++ b/src/mod/gcewing/sg/SoundSource.java @@ -0,0 +1,30 @@ +package gcewing.sg; + +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface SoundSource { + World getSoundWorld(); + + BlockPos getSoundPos(); + + boolean isSoundActive(SoundEvent sound); + + default boolean isSoundRepeatable(SoundEvent sound) { + return false; + } + + default float getSoundPitch(SoundEvent sound) { + return 1F; + } + + default float getSoundVolume(SoundEvent sound) { + return 1F; + } + + @SideOnly(Side.CLIENT) + default void updateSound(SoundEvent sound) {} +} diff --git a/src/mod/gcewing/sg/Utils.java b/src/mod/gcewing/sg/Utils.java deleted file mode 100644 index ee5c1a0b..00000000 --- a/src/mod/gcewing/sg/Utils.java +++ /dev/null @@ -1,40 +0,0 @@ -//------------------------------------------------------------------------------------------------ -// -// SG Craft - Stargate base tile entity renderer -// -//------------------------------------------------------------------------------------------------ - -package gcewing.sg; - -public class Utils { - - public static double normaliseAngle(double a) { - a %= 360.0; - if (a < 0.0) - a += 360.0; - return a; - } - - public static double addAngle(double a, double b) { - return normaliseAngle(a + b); - } - - public static double diffAngle(double a, double b) { - // Shortest angular distance from a to b, in range -180 to 180 - double d = (a > b) ? (a - b) : (b - a); - if (d > 180.0) - d -= 360.0; - if (a > b) - d = -d; - return d; - } - - public static double relaxAngle(double a, double target, double rate) { - return addAngle(a, rate * diffAngle(a, target)); - } - - public static double interpolateAngle(double a, double b, double t) { - return addAngle(a, t * diffAngle(a, b)); - } - -} diff --git a/src/mod.gcewing.sg-disabled/cc/CCIntegration.java b/src/mod/gcewing/sg/cc/CCIntegration.java similarity index 68% rename from src/mod.gcewing.sg-disabled/cc/CCIntegration.java rename to src/mod/gcewing/sg/cc/CCIntegration.java index 251645b0..cd5129a6 100644 --- a/src/mod.gcewing.sg-disabled/cc/CCIntegration.java +++ b/src/mod/gcewing/sg/cc/CCIntegration.java @@ -8,36 +8,26 @@ import net.minecraft.block.*; import net.minecraft.init.*; -import net.minecraft.item.*; import dan200.computercraft.api.*; import gcewing.sg.*; public class CCIntegration extends BaseSubsystem implements IIntegration { public static Block ccInterface; - -// @Override -// public void init(SGCraft mod) { -// System.out.printf("CCIntegration.init\n"); -// this.mod = mod; -// ComputerCraftAPI.registerPeripheralProvider(new CCPeripheralProvider()); -// CCMethodQueue.init(); -// } - + @Override public void registerBlocks() { System.out.printf("CCIntegration.registerBlocks\n"); ccInterface = SGCraft.mod.newBlock("ccInterface", CCInterfaceBlock.class); } - -// @Override -// public void registerItems() { -// } - + @Override public void registerRecipes() { - SGCraft.mod.newRecipe(ccInterface, 1, "SnS", "SrS", "SSS", - 'S', Blocks.stone, 'n', "ingotNaquadahAlloy", 'r', Items.redstone); + if (ccInterface != null) { + if (mod.config.getBoolean("recipes", "ccInterfaceBlock", true)) { + SGCraft.mod.newRecipe("cc_interface", ccInterface, 1, "SnS", "SrS", "SSS", 'S', Blocks.STONE, 'n', "ingotNaquadahAlloy", 'r', Items.REDSTONE); + } + } } @Override diff --git a/src/mod.gcewing.sg-disabled/cc/CCInterfaceBlock.java b/src/mod/gcewing/sg/cc/CCInterfaceBlock.java similarity index 85% rename from src/mod.gcewing.sg-disabled/cc/CCInterfaceBlock.java rename to src/mod/gcewing/sg/cc/CCInterfaceBlock.java index 9fc58126..75a676f4 100644 --- a/src/mod.gcewing.sg-disabled/cc/CCInterfaceBlock.java +++ b/src/mod/gcewing/sg/cc/CCInterfaceBlock.java @@ -6,10 +6,6 @@ package gcewing.sg.cc; -import net.minecraft.tileentity.*; -import net.minecraft.world.*; -import net.minecraftforge.common.util.*; - import gcewing.sg.*; public class CCInterfaceBlock extends SGInterfaceBlock { diff --git a/src/mod.gcewing.sg-disabled/cc/CCInterfaceTE.java b/src/mod/gcewing/sg/cc/CCInterfaceTE.java similarity index 76% rename from src/mod.gcewing.sg-disabled/cc/CCInterfaceTE.java rename to src/mod/gcewing/sg/cc/CCInterfaceTE.java index 46478a7e..a9c36f93 100644 --- a/src/mod.gcewing.sg-disabled/cc/CCInterfaceTE.java +++ b/src/mod/gcewing/sg/cc/CCInterfaceTE.java @@ -6,13 +6,13 @@ package gcewing.sg.cc; -import java.util.*; -import net.minecraft.world.*; -import net.minecraft.tileentity.*; -import dan200.computercraft.api.lua.*; -import dan200.computercraft.api.peripheral.*; +import dan200.computercraft.api.peripheral.IComputerAccess; +import gcewing.sg.IComputerInterface; +import gcewing.sg.SGInterfaceTE; +import net.minecraft.tileentity.TileEntity; -import gcewing.sg.*; +import java.util.HashSet; +import java.util.Set; public class CCInterfaceTE extends SGInterfaceTE implements IComputerInterface { diff --git a/src/mod.gcewing.sg-disabled/cc/CCMethod.java b/src/mod/gcewing/sg/cc/CCMethod.java similarity index 100% rename from src/mod.gcewing.sg-disabled/cc/CCMethod.java rename to src/mod/gcewing/sg/cc/CCMethod.java diff --git a/src/mod.gcewing.sg-disabled/cc/CCMethodQueue.java b/src/mod/gcewing/sg/cc/CCMethodQueue.java similarity index 100% rename from src/mod.gcewing.sg-disabled/cc/CCMethodQueue.java rename to src/mod/gcewing/sg/cc/CCMethodQueue.java diff --git a/src/mod.gcewing.sg-disabled/cc/CCPeripheralProvider.java b/src/mod/gcewing/sg/cc/CCPeripheralProvider.java similarity index 77% rename from src/mod.gcewing.sg-disabled/cc/CCPeripheralProvider.java rename to src/mod/gcewing/sg/cc/CCPeripheralProvider.java index 7b15f902..915e9246 100644 --- a/src/mod.gcewing.sg-disabled/cc/CCPeripheralProvider.java +++ b/src/mod/gcewing/sg/cc/CCPeripheralProvider.java @@ -6,23 +6,18 @@ package gcewing.sg.cc; -import net.minecraft.block.*; import net.minecraft.tileentity.*; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.*; import net.minecraft.util.*; import dan200.computercraft.api.peripheral.*; -import gcewing.sg.*; - public class CCPeripheralProvider implements IPeripheralProvider { @Override public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side) { TileEntity te = world.getTileEntity(pos); - if (te instanceof CCInterfaceTE) - return new CCSGPeripheral((CCInterfaceTE)te); - else - return null; + return te instanceof CCInterfaceTE ? new CCSGPeripheral(te) : null; } } diff --git a/src/mod.gcewing.sg-disabled/cc/CCSGPeripheral.java b/src/mod/gcewing/sg/cc/CCSGPeripheral.java similarity index 95% rename from src/mod.gcewing.sg-disabled/cc/CCSGPeripheral.java rename to src/mod/gcewing/sg/cc/CCSGPeripheral.java index b6d7625e..be1716ea 100644 --- a/src/mod.gcewing.sg-disabled/cc/CCSGPeripheral.java +++ b/src/mod/gcewing/sg/cc/CCSGPeripheral.java @@ -6,12 +6,9 @@ package gcewing.sg.cc; -import com.google.common.base.Joiner; - import net.minecraft.tileentity.*; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.*; -import net.minecraft.util.*; -import net.minecraftforge.common.util.*; import dan200.computercraft.api.lua.*; import dan200.computercraft.api.peripheral.*; @@ -184,16 +181,14 @@ Object[] call(IComputerAccess cpu, ILuaContext ctx, Object target, Object[] args if (result == null) result = success; return result; + } else { + throw new IllegalArgumentException("diagnosticsFailed"); } - else - throw new IllegalArgumentException("Stargate interface failed internal diagnostics"); - } - catch (Exception e) { + } catch (Exception e) { return new Object[] {null, e.getMessage()}; } } abstract Object[] call(SGInterfaceTE te, Object[] args); - } diff --git a/src/mod/gcewing/sg/ic2/IC2Integration.java b/src/mod/gcewing/sg/ic2/IC2Integration.java index 892f865f..f7466412 100644 --- a/src/mod/gcewing/sg/ic2/IC2Integration.java +++ b/src/mod/gcewing/sg/ic2/IC2Integration.java @@ -6,12 +6,11 @@ package gcewing.sg.ic2; -import net.minecraft.block.*; -import net.minecraft.init.*; -import net.minecraft.item.*; -import gcewing.sg.*; - -import ic2.api.item.*; //[IC2] + import gcewing.sg.BaseSubsystem; + import gcewing.sg.SGCraft; + import gcewing.sg.SGCraftClient; + import ic2.api.item.IC2Items; + import net.minecraft.item.ItemStack; public class IC2Integration extends BaseSubsystem { @@ -25,12 +24,12 @@ public static ItemStack getIC2Item(String name, String variant) { throw new RuntimeException(String.format("IC2 item %s.%s not found", name, variant)); return stack; } - + @Override public void registerBlocks() { mod.ic2PowerUnit = mod.newBlock("ic2PowerUnit", IC2PowerBlock.class, IC2PowerItem.class); } - + @Override public void registerRecipes() { ItemStack rubber = getIC2Item("crafting", "rubber"); @@ -38,10 +37,14 @@ public void registerRecipes() { ItemStack machine = getIC2Item("resource", "machine"); ItemStack wire = getIC2Item("cable", "type:copper,insulation:0"); ItemStack circuit = getIC2Item("crafting", "circuit"); - mod.newRecipe(mod.ic2Capacitor, 1, "ppp", "rrr", "ppp", - 'p', copperPlate, 'r', rubber); - mod.newRecipe(mod.ic2PowerUnit, 1, "cwc", "wMw", "cec", - 'c', mod.ic2Capacitor, 'w', wire, 'M', machine, 'e', circuit); + if (rubber != null && copperPlate != null && machine != null && wire != null && circuit != null && mod.ic2Capacitor != null && mod.ic2PowerUnit != null) { + if (mod.config.getBoolean("recipes", "ic2CapacitorItem", true)) { + mod.newRecipe("ic2Capacitor", mod.ic2Capacitor, 1, "ppp", "rrr", "ppp", 'p', copperPlate, 'r', rubber); + } + + if (mod.config.getBoolean("recipes", "ic2PowerUnitBlock", true)) { + mod.newRecipe("ic2Powerunit", mod.ic2PowerUnit, 1, "cwc", "wMw", "cec", 'c', mod.ic2Capacitor, 'w', wire, 'M', machine, 'e', circuit); + } + } } - } diff --git a/src/mod/gcewing/sg/ic2/IC2PowerItem.java b/src/mod/gcewing/sg/ic2/IC2PowerItem.java index 15c45493..80489b82 100644 --- a/src/mod/gcewing/sg/ic2/IC2PowerItem.java +++ b/src/mod/gcewing/sg/ic2/IC2PowerItem.java @@ -6,20 +6,16 @@ package gcewing.sg.ic2; -import java.util.*; +import gcewing.sg.PowerItem; +import net.minecraft.block.Block; -import net.minecraft.block.*; //import net.minecraft.entity.player.*; -import net.minecraft.item.*; //import net.minecraft.nbt.*; //import net.minecraft.util.*; -import gcewing.sg.*; - public class IC2PowerItem extends PowerItem { public IC2PowerItem(Block block) { - super(block, "EU", IC2PowerTE.maxEnergyBuffer); + super(block, "EU"); } - } diff --git a/src/mod/gcewing/sg/ic2/IC2PowerTE.java b/src/mod/gcewing/sg/ic2/IC2PowerTE.java index b7aca7fa..45ed04b0 100644 --- a/src/mod/gcewing/sg/ic2/IC2PowerTE.java +++ b/src/mod/gcewing/sg/ic2/IC2PowerTE.java @@ -6,104 +6,145 @@ package gcewing.sg.ic2; -import net.minecraft.nbt.*; -import net.minecraft.tileentity.*; -import net.minecraft.util.*; -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; +import static gcewing.sg.BaseUtils.min; -import ic2.api.energy.event.*; -import ic2.api.energy.tile.*; - -import gcewing.sg.*; -import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.Utils.*; +import gcewing.sg.PowerTE; +import gcewing.sg.SGCraft; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyEmitter; +import ic2.api.energy.tile.IEnergySink; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.MinecraftForge; public class IC2PowerTE extends PowerTE implements IEnergySink, ITickable { - boolean debugLoad = false; - boolean debugInput = false; + private boolean debugLoad = false; + private boolean debugInput = false; - final static int maxSafeInput = 2048; - final static int maxEnergyBuffer = 1000000; - final static double euPerSGEnergyUnit = 20.0; + // The below is intended to set the classes first variables to config values. + private int maxSafeInput = SGCraft.Ic2SafeInput; + private int powerTier = SGCraft.Ic2PowerTETier; + private int update = 0; + private boolean loaded = false; - boolean loaded = false; - public IC2PowerTE() { - super(maxEnergyBuffer, euPerSGEnergyUnit); + super(SGCraft.Ic2MaxEnergyBuffer, SGCraft.Ic2euPerSGEnergyUnit); + } + + @Override + public void readContentsFromNBT(NBTTagCompound nbttagcompound) { + super.readContentsFromNBT(nbttagcompound); + // Check if Key doesn't exist or if Admin is trying to update all the DHD's with new values. + if (!nbttagcompound.hasKey("input") || SGCraft.forceIC2CfgUpdate) { + maxSafeInput = SGCraft.Ic2SafeInput; + powerTier = SGCraft.Ic2PowerTETier; + energyMax = SGCraft.Ic2MaxEnergyBuffer; + energyPerSGEnergyUnit = SGCraft.Ic2euPerSGEnergyUnit; + } else { + maxSafeInput = nbttagcompound.getInteger("input"); + powerTier = nbttagcompound.getInteger("tier"); + } } - + + @Override + public void writeContentsToNBT(NBTTagCompound nbttagcompound) { + super.writeContentsToNBT(nbttagcompound); + nbttagcompound.setInteger("input", maxSafeInput); + nbttagcompound.setInteger("tier", powerTier); + } + + @Override public String getScreenTitle() { return "IC2 SGPU"; } - + + @Override + public void update() { + if (!world.isRemote && !loaded) { + if(debugLoad) { + System.out.printf("SGCraft: IC2PowerTE: Adding to energy network\n"); + } + loaded = true; + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + } + } + @Override public String getUnitName() { return "EU"; } - + @Override public void invalidate() { unload(); super.invalidate(); } - + @Override public void onChunkUnload() { unload(); super.onChunkUnload(); } - - @Override - public void update() { - if (!worldObj.isRemote && !loaded) { - if(debugLoad) - System.out.printf("SGCraft: IC2PowerTE: Adding to energy network\n"); - loaded = true; - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - } - } - + + public static IC2PowerTE at(IBlockAccess world, BlockPos pos) { + TileEntity te = world.getTileEntity(pos); + return te instanceof IC2PowerTE ? (IC2PowerTE) te : null; + } + void unload() { - if (!worldObj.isRemote && loaded) { - if(debugLoad) + if (!world.isRemote && loaded) { + if(debugLoad) { System.out.printf("SGCraft: IC2PowerTE: Removing from energy network\n"); + } MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); loaded = false; } } - + //------------------------- IEnergyAcceptor ------------------------- - + @Override public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { return true; } - + //------------------------- IEnergySink ------------------------- - + @Override public double getDemandedEnergy() { - double eu = min(maxEnergyBuffer - energyBuffer, maxSafeInput); - if(debugInput) + double eu = min(energyMax - energyBuffer, maxSafeInput); + if(debugInput) { System.out.printf("SGCraft: IC2PowerTE: Demanding %s EU\n", eu); + } return eu; } - + @Override public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) { energyBuffer += amount; - markChanged(); - if(debugInput) + if (update++ > 10) { // We dont' need 20 packets per second to the client.... + markChanged(); + update = 0; + } + if(debugInput) { System.out.printf("SGCraft: IC2PowerTE: Injected %s EU giving %s\n", amount, energyBuffer); + } return 0; } - + @Override public int getSinkTier() { - return 3; + return powerTier; //HV + } + + @Override public double totalAvailableEnergy() { + return energyBuffer; } - } diff --git a/src/mod/gcewing/sg/oc/OCIntegration.java b/src/mod/gcewing/sg/oc/OCIntegration.java index fe11835d..39b87bff 100644 --- a/src/mod/gcewing/sg/oc/OCIntegration.java +++ b/src/mod/gcewing/sg/oc/OCIntegration.java @@ -6,57 +6,63 @@ package gcewing.sg.oc; -import net.minecraft.block.*; -import net.minecraft.init.*; -import net.minecraft.item.*; +import gcewing.sg.BaseConfiguration; +import gcewing.sg.IntegrationBase; +import gcewing.sg.SGBaseTE; +import gcewing.sg.SGGui; +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + //import li.cil.oc.api.*; -import gcewing.sg.*; public class OCIntegration extends IntegrationBase { public static Block ocInterface; public static ItemStack networkCard; - + static ItemStack ocItem(String name) { return li.cil.oc.api.Items.get(name).createItemStack(1); } - + @Override public void configure(BaseConfiguration config) { OCWirelessEndpoint.configure(config); } - + @Override public void registerBlocks() { System.out.printf("OCIntegration.registerBlocks\n"); ocInterface = mod.newBlock("ocInterface", OCInterfaceBlock.class); } - + @Override public void registerItems() { - networkCard = ocItem("lanCard"); + networkCard = ocItem("lancard"); } - + @Override public void registerRecipes() { ItemStack cable = ocItem("cable"); ItemStack microchip1 = ocItem("chip1"); - ItemStack pcb = ocItem("printedCircuitBoard"); - mod.newRecipe(ocInterface, 1, "ini", "cmc", "ibi", - 'i', Items.IRON_INGOT, 'n', "ingotNaquadahAlloy", - 'c', cable, 'm', microchip1, 'b', pcb); + ItemStack pcb = ocItem("printedcircuitboard"); + if (cable != null && microchip1 != null && pcb != null) { + if (mod.config.getBoolean("recipes", "ocInterfaceBlock", true)) { + mod.newRecipe("ocInterface", ocInterface, 1, "ini", "cmc", "ibi", 'i', Items.IRON_INGOT, 'n', "ingotNaquadahAlloy", 'c', cable, 'm', microchip1, 'b', pcb); + } + } } - + @Override public void registerContainers() { mod.addContainer(SGGui.OCInterface, OCInterfaceContainer.class); } - + @Override public void registerScreens() { mod.client.addScreen(SGGui.OCInterface, OCInterfaceScreen.class); } - + public void onSGBaseTEAdded(SGBaseTE te) { te.ocWirelessEndpoint = new OCWirelessEndpoint(te); } diff --git a/src/mod/gcewing/sg/oc/OCInterfaceBlock.java b/src/mod/gcewing/sg/oc/OCInterfaceBlock.java index 2868299e..f3ff0a89 100644 --- a/src/mod/gcewing/sg/oc/OCInterfaceBlock.java +++ b/src/mod/gcewing/sg/oc/OCInterfaceBlock.java @@ -8,14 +8,10 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.*; -import net.minecraft.item.*; -import net.minecraft.tileentity.*; import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.world.*; -import net.minecraftforge.common.util.*; - import gcewing.sg.*; public class OCInterfaceBlock extends SGInterfaceBlock { @@ -28,7 +24,7 @@ public OCInterfaceBlock() { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float hx, float hy, float hz) + EnumHand hand, EnumFacing side, float hx, float hy, float hz) { if (!world.isRemote) SGCraft.mod.openGui(player, SGGui.OCInterface, world, pos); diff --git a/src/mod/gcewing/sg/oc/OCInterfaceContainer.java b/src/mod/gcewing/sg/oc/OCInterfaceContainer.java index 0361ee1e..33a2816b 100644 --- a/src/mod/gcewing/sg/oc/OCInterfaceContainer.java +++ b/src/mod/gcewing/sg/oc/OCInterfaceContainer.java @@ -10,7 +10,6 @@ import net.minecraft.item.*; import net.minecraft.inventory.*; import net.minecraft.world.*; -import net.minecraft.util.*; import net.minecraft.util.math.*; import gcewing.sg.*; @@ -28,8 +27,16 @@ public class OCInterfaceContainer extends BaseContainer { public OCInterfaceContainer(EntityPlayer player, World world, BlockPos pos) { super(guiWidth, guiHeight); te = (OCInterfaceTE)getWorldTileEntity(world, pos); - addPlayerSlots(player); addSlots(te, slotsLeft, slotsTop, 1, UpgradeSlot.class); + addPlayerSlots(player); + } + + @Override + protected SlotRange transferSlotRange(int srcSlotIndex, ItemStack stack) { + SlotRange range = new SlotRange(); + range.firstSlot = 0; + range.numSlots = 1; + return range; } public static class UpgradeSlot extends Slot { diff --git a/src/mod/gcewing/sg/oc/OCInterfaceTE.java b/src/mod/gcewing/sg/oc/OCInterfaceTE.java index b4ee2a10..c66ad1f0 100644 --- a/src/mod/gcewing/sg/oc/OCInterfaceTE.java +++ b/src/mod/gcewing/sg/oc/OCInterfaceTE.java @@ -6,28 +6,22 @@ package gcewing.sg.oc; -import java.util.*; -import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; -import net.minecraft.item.*; -import net.minecraft.nbt.*; -import net.minecraft.world.*; -import net.minecraft.util.*; -import net.minecraft.util.text.*; -import net.minecraft.tileentity.*; - +import gcewing.sg.IComputerInterface; +import gcewing.sg.SGBaseTE; +import gcewing.sg.SGInterfaceTE; import li.cil.oc.api.Network; -import li.cil.oc.api.machine.Value; import li.cil.oc.api.machine.Arguments; -import li.cil.oc.api.machine.Context; import li.cil.oc.api.machine.Callback; -import li.cil.oc.api.network.Environment; -import li.cil.oc.api.network.Message; -import li.cil.oc.api.network.Node; -import li.cil.oc.api.network.Packet; -import li.cil.oc.api.network.Visibility; - -import gcewing.sg.*; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ITickable; +import net.minecraft.util.text.ITextComponent; public class OCInterfaceTE extends SGInterfaceTE implements IComputerInterface, Environment, IInventory, ITickable @@ -76,7 +70,7 @@ public void rebroadcastNetworkPacket(Object packet) { if (packet instanceof Packet && hasNetworkCard()) { if (node != null) { if (debugNetworking) - System.out.printf("OCInterfaceTE.rebroadcastNetworkPacket\n"); + System.out.print("OCInterfaceTE.rebroadcastNetworkPacket\n"); node.sendToReachable("network.message", packet); } } @@ -188,7 +182,7 @@ public Object[] sendMessage(Context ctx, Arguments args) { * // If you do not need energy remove this call. * .withConnector() * // This call marks the tile entity as a component. This means you - * // can mark methods in it using the {@link li.cil.oc.api.network.Callback} + * // can mark methods in it using the {@link li.cil.oc.api.machine.Callback} * // annotation, making them callable from user code. The first * // parameter is the name by which the component will be known in * // the computer, in this case it could be accessed as @@ -247,7 +241,7 @@ public void onMessage(final Message msg) { System.out.printf("OCInterfaceTE.onMessage from %s: %s", msg.source(), msg.name()); for (Object obj : msg.data()) System.out.printf(" %s", obj); - System.out.printf("\n"); + System.out.print("\n"); } forwardNetworkPacket((Packet)msg.data()[0]); } @@ -323,6 +317,7 @@ public NBTTagCompound writeToNBT(final NBTTagCompound nbt) { // -------------------------- IComputerInterface -------------------------- + @Override public void postEvent(TileEntity source, String name, Object... args) { //System.out.printf("OCInterfaceTE.postEvent: %s to %s\n", name, node); if (node != null) @@ -343,7 +338,13 @@ public void postEvent(TileEntity source, String name, Object... args) { public int getSizeInventory() { IInventory inventory = getInventory(); return (inventory != null) ? inventory.getSizeInventory() : 0; - } + } + + @Override + public boolean isEmpty() { + IInventory inventory = getInventory(); + return inventory == null || inventory.isEmpty(); + } /** * Returns the stack in slot i @@ -412,9 +413,9 @@ public int getInventoryStackLimit() { * Do not make give this method the name canInteractWith because it clashes with Container */ @Override - public boolean isUseableByPlayer(EntityPlayer player) { + public boolean isUsableByPlayer(EntityPlayer player) { IInventory inventory = getInventory(); - return (inventory != null) ? inventory.isUseableByPlayer(player) : true; + return (inventory == null) || inventory.isUsableByPlayer(player); } @Override diff --git a/src/mod/gcewing/sg/rf/RFIntegration.java b/src/mod/gcewing/sg/rf/RFIntegration.java new file mode 100644 index 00000000..9fe2611b --- /dev/null +++ b/src/mod/gcewing/sg/rf/RFIntegration.java @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------------------------ +// +// SG Craft - RF Power Integration Module +// +//------------------------------------------------------------------------------------------------ + +package gcewing.sg.rf; + +import static net.minecraftforge.fml.common.Loader.isModLoaded; + +import gcewing.sg.BaseSubsystem; +import gcewing.sg.SGCraft; +import gcewing.sg.SGCraftClient; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + +public class RFIntegration extends BaseSubsystem { + + @Override + public void registerBlocks() { + mod.rfPowerUnit = mod.newBlock("rfPowerUnit", RFPowerBlock.class); //[RF] + } + + @Override + public void registerRecipes() { + if (isModLoaded("thermalexpansion")) + addThermalExpansionPowerBlockRecipe(); + else + addGenericPowerBlockRecipe(); + } + + protected void addThermalExpansionPowerBlockRecipe() { + Item frame = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thermalexpansion", "frame")); + Item coil = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thermalfoundation", "material")); + if (frame != null && coil != null) { + ItemStack hardenedEnergyFrame = new ItemStack(frame, 1, 129); + ItemStack receptionCoil = new ItemStack(coil, 1, 513); + ItemStack transmissionCoil = new ItemStack(coil, 1, 514); + if (hardenedEnergyFrame != null && receptionCoil != null && transmissionCoil != null) { + if (mod.config.getBoolean("recipes", "teRFPowerUnitBlock", true)) { + mod.newRecipe("rfPowerUnit", mod.rfPowerUnit, 1, "ttt", "hrh", "ici", 't', transmissionCoil, 'h', hardenedEnergyFrame, 'r', receptionCoil, 'i', "ingotInvar", 'c', "ingotCopper"); + } + } + } + } + + protected void addGenericPowerBlockRecipe() { + if (isModLoaded("ic2") && mod.ic2Capacitor != null) { + if (mod.config.getBoolean("recipes", "genericRFPowerUnitBlock", true)) { + mod.newRecipe("rfPowerUnit", mod.rfPowerUnit, 1, "cgc", "gIg", "crc", 'c', mod.ic2Capacitor, 'g', "ingotGold", 'I', "blockIron", 'r', Items.REDSTONE); + } + } + } +} diff --git a/src/mod/gcewing/sg/rf/RFPowerItem.java b/src/mod/gcewing/sg/rf/RFPowerItem.java index 602fd4f8..50c167c7 100644 --- a/src/mod/gcewing/sg/rf/RFPowerItem.java +++ b/src/mod/gcewing/sg/rf/RFPowerItem.java @@ -6,17 +6,14 @@ package gcewing.sg.rf; -import java.util.*; - import net.minecraft.block.*; -import net.minecraft.item.*; import gcewing.sg.*; public class RFPowerItem extends PowerItem { public RFPowerItem(Block block) { - super(block, "RF", RFPowerTE.maxEnergyBuffer); + super(block, "RF"); } } diff --git a/src/mod/gcewing/sg/rf/RFPowerTE.java b/src/mod/gcewing/sg/rf/RFPowerTE.java index 78e389cf..defdf38d 100644 --- a/src/mod/gcewing/sg/rf/RFPowerTE.java +++ b/src/mod/gcewing/sg/rf/RFPowerTE.java @@ -6,81 +6,121 @@ package gcewing.sg.rf; -import net.minecraft.nbt.*; +import gcewing.sg.PowerTE; +import gcewing.sg.SGCraft; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; -import net.minecraft.tileentity.*; -import net.minecraftforge.common.*; -import net.minecraftforge.common.util.*; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.energy.EnergyStorage; +import net.minecraftforge.energy.IEnergyStorage; -import cofh.api.energy.*; +import javax.annotation.Nullable; -import gcewing.sg.*; -import static gcewing.sg.BaseUtils.*; -import static gcewing.sg.Utils.*; +public class RFPowerTE extends PowerTE implements IEnergyStorage { -public class RFPowerTE extends PowerTE implements IEnergyProvider, IEnergyReceiver { + // Addon for Redstone Flux - boolean debugInput = false; - - final static int maxEnergyBuffer = 4000000; - final static double rfPerSGEnergyUnit = 80.0; + private EnergyStorage storage = new EnergyStorage(SGCraft.RfMaxEnergyBuffer); + private int update = 0; public RFPowerTE() { - super(maxEnergyBuffer, rfPerSGEnergyUnit); + super(SGCraft.RfMaxEnergyBuffer, SGCraft.RfPerSGEnergyUnit); } - + @Override public String getScreenTitle() { return "RF SGPU"; } - + @Override public String getUnitName() { return "RF"; } - - protected void addEnergy(int e) { - this.energyBuffer += e; - markChanged(); - } - //------------------------- IEnergyConnection ------------------------- + @Override + public void readContentsFromNBT(NBTTagCompound nbttagcompound) { + super.readContentsFromNBT(nbttagcompound); + + if (nbttagcompound.hasKey("capacity")) { + int capacity = nbttagcompound.getInteger("capacity"); + int energy = nbttagcompound.getInteger("energy"); + storage = new EnergyStorage(capacity, capacity, capacity, energy); + } + + // Check if Admin is trying to update all the DHD's with new values. + if (SGCraft.forceRFCfgUpdate) { + // Todo: this isn't going to work because RF usages a Storage container. + energyMax = SGCraft.RfMaxEnergyBuffer; + energyPerSGEnergyUnit = SGCraft.RfPerSGEnergyUnit; + } + } @Override - public boolean canConnectEnergy(EnumFacing dir) { - return true; + public void writeContentsToNBT(NBTTagCompound nbttagcompound) { + super.writeContentsToNBT(nbttagcompound); + nbttagcompound.setInteger("capacity", storage.getMaxEnergyStored()); + nbttagcompound.setInteger("energy", storage.getEnergyStored()); } - //------------------------- IEnergyHandler ------------------------- + @Override + public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + return capability.equals(CapabilityEnergy.ENERGY) || super.hasCapability(capability, facing); + } + @Nullable @Override - public int getEnergyStored(EnumFacing dir) { - return (int)energyBuffer; + public T getCapability(Capability capability, @Nullable EnumFacing facing) { + if (hasCapability(capability, facing)) + return CapabilityEnergy.ENERGY.cast(this); + return super.getCapability(capability, facing); } - + + //------------------------ IEnergyStorage --------------------------- + @Override - public int getMaxEnergyStored(EnumFacing dir) { - return (int)energyMax; + public int receiveEnergy(int maxReceive, boolean simulate) { + int result = storage.receiveEnergy(maxReceive, simulate); + energyBuffer = storage.getEnergyStored(); + if (update++ > 10) { // We dont' need 20 packets per second to the client.... + markChanged(); + update = 0; + } + return result; } - //------------------------- IEnergyReceiver ------------------------- - @Override - public int receiveEnergy(EnumFacing dir, int energy, boolean query) { - int e = (int)min(this.energyMax - this.energyBuffer, energy); - if (!query) - addEnergy(e); - return e; + public int extractEnergy(int maxExtract, boolean simulate) { + int result = storage.extractEnergy(maxExtract, simulate); + energyBuffer = storage.getEnergyStored(); + if (update++ > 10) { // We dont' need 20 packets per second to the client.... + markChanged(); + update = 0; + } + return result; } - - //------------------------- IEnergyProvider ------------------------- - + @Override - public int extractEnergy(EnumFacing dir, int energy, boolean query) { - int e = (int)Math.min(this.energyBuffer, energy); - if (!query) - addEnergy(-e); - return e; + public int getEnergyStored() { + return storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored() { + return storage.getMaxEnergyStored(); + } + + @Override + public boolean canExtract() { + return storage.canExtract(); + } + + @Override + public boolean canReceive() { + return storage.canReceive(); + } + + @Override public double totalAvailableEnergy() { + return energyBuffer; } - -} +} \ No newline at end of file diff --git a/src/resources/assets/sgcraft/blockstates/naquadahBlock.json b/src/resources/assets/sgcraft/blockstates/naquadahBlock.json deleted file mode 100644 index 713e5b4d..00000000 --- a/src/resources/assets/sgcraft/blockstates/naquadahBlock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "sgcraft:naquadahBlock" } - } -} diff --git a/src/resources/assets/sgcraft/blockstates/naquadahOre.json b/src/resources/assets/sgcraft/blockstates/naquadahOre.json deleted file mode 100644 index c21234a3..00000000 --- a/src/resources/assets/sgcraft/blockstates/naquadahOre.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "sgcraft:naquadahOre" } - } -} diff --git a/src/resources/assets/sgcraft/blockstates/naquadahblock.json b/src/resources/assets/sgcraft/blockstates/naquadahblock.json new file mode 100644 index 00000000..e31fe3c9 --- /dev/null +++ b/src/resources/assets/sgcraft/blockstates/naquadahblock.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "sgcraft:naquadahblock" } + } +} diff --git a/src/resources/assets/sgcraft/blockstates/naquadahore.json b/src/resources/assets/sgcraft/blockstates/naquadahore.json new file mode 100644 index 00000000..75ecfb37 --- /dev/null +++ b/src/resources/assets/sgcraft/blockstates/naquadahore.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "sgcraft:naquadahore" } + } +} diff --git a/src/resources/assets/sgcraft/lang/en_US.lang b/src/resources/assets/sgcraft/lang/en_US.lang index ef9a6eaa..6097b037 100644 --- a/src/resources/assets/sgcraft/lang/en_US.lang +++ b/src/resources/assets/sgcraft/lang/en_US.lang @@ -21,3 +21,18 @@ death.attack.sgcraft:transient=%1$s was torn apart by an event horizon death.attack.sgcraft:iris=%1$s got splattered against a stargate iris entity.Villager.sgcraft:tokra=Tok'ra Merchant itemGroup.sgcraft:sgcraft=SG Craft + +message.sgcraft:disconnectFirst=Disconnect stargate before breaking +message.sgcraft:irisAtDestination=Destination blocked by iris +message.sgcraft:incomingConnection=Connection initiated from other end +message.sgcraft:selfBusy=Stargate is busy +message.sgcraft:targetBusy=Stargate at address %s is busy +message.sgcraft:selfOutOfRange=Coordinates of dialling stargate are out of range +message.sgcraft:targetOutOfRange=Coordinates out of stargate range +message.sgcraft:unknownAddress=Unable to find stargate at address %s +message.sgcraft:selfLackChevrons=Stargate has insufficient chevrons to dial %s +message.sgcraft:targetLackChevrons=Destination stargate has insufficient chevrons +message.sgcraft:diallingItself=Stargate cannot connect to itself +message.sgcraft:insufficientEnergy=Stargate has insufficient energy +message.sgcraft:malformedAddress=Malformed stargate address +message.sgcraft:dimensionTooFar=Dimension not reachable by stargate \ No newline at end of file diff --git a/src/resources/assets/sgcraft/lang/ru_RU.lang b/src/resources/assets/sgcraft/lang/ru_RU.lang new file mode 100644 index 00000000..dd657708 --- /dev/null +++ b/src/resources/assets/sgcraft/lang/ru_RU.lang @@ -0,0 +1,38 @@ +tile.sgcraft:stargateRing.0.name=Сегмент кольца +tile.sgcraft:stargateRing.1.name=Сегмент с шевроном +tile.sgcraft:stargateRing.name=Stargate Ring Segment +tile.sgcraft:stargateBase.name=Основание Врат +tile.sgcraft:stargateController.name=Наборное устройство +tile.sgcraft:naquadahBlock.name=Блок сплава из наквадаха +tile.sgcraft:naquadahOre.name=Руда наквадаха +tile.sgcraft:ic2PowerUnit.name=IC2 Энергоблок +tile.sgcraft:rfPowerUnit.name=RF Энергоблок +tile.sgcraft:ccInterface.name=Интерфейс ComputerCraft +tile.sgcraft:ocInterface.name=Интерфейс OpenComputers +item.sgcraft:naquadah.name=Наквадах +item.sgcraft:naquadahIngot.name=Слиток сплава из наквадаха +item.sgcraft:sgCoreCrystal.name=Управляющий кристалл +item.sgcraft:sgControllerCrystal.name=Наборный кристалл +item.sgcraft:sgChevronUpgrade.name=Дополнительные шевроны +item.sgcraft:sgIrisUpgrade.name=Диафрагма +item.sgcraft:sgIrisBlade.name=Лезвие диафрагмы +item.sgcraft:ic2Capacitor.name=Конденсатор огромной ёмкости +death.attack.sgcraft:transient=%1$s был разорван на части горизонтом событий +death.attack.sgcraft:iris=%1$s был размазан о диафрагму +entity.Villager.sgcraft:tokra=Торговец Ток'ра +itemGroup.sgcraft:sgcraft=SG Craft + +message.sgcraft:disconnectFirst=Сперва отключите врата, а затем - разрушайте +message.sgcraft:irisAtDestination=Место прибытия защищено диафрагмой +message.sgcraft:incomingConnection=Соединение инициализировано с другой стороны +message.sgcraft:selfBusy=Врата активны +message.sgcraft:targetBusy=Врата по адресу %s активны +message.sgcraft:selfOutOfRange=Координаты набиращих Врат за пределами досигаемости +message.sgcraft:targetOutOfRange=Координаты Врат за пределами досигаемости +message.sgcraft:unknownAddress=Врата по адресу %s не найдены +message.sgcraft:selfLackChevrons=У набирающих Врат недостаточно шевронов для соединения с %s +message.sgcraft:targetLackChevrons=У конечных Врат недостаточно шевронов +message.sgcraft:diallingItself=Врата не могут подключиться к самим себе +message.sgcraft:insufficientEnergy=Вратам не хватает энергии +message.sgcraft:malformedAddress=Неверный адрес Врат +message.sgcraft:dimensionTooFar=Конечное измерение недостижимо для Врат diff --git a/src/resources/assets/sgcraft/lang/zh_CN.lang b/src/resources/assets/sgcraft/lang/zh_CN.lang new file mode 100644 index 00000000..4c0c442c --- /dev/null +++ b/src/resources/assets/sgcraft/lang/zh_CN.lang @@ -0,0 +1,38 @@ +tile.sgcraft:stargateRing.0.name=星门环方块 +tile.sgcraft:stargateRing.1.name=星门人字块 +tile.sgcraft:stargateRing.name=星门环片段 +tile.sgcraft:stargateBase.name=星门底座 +tile.sgcraft:stargateController.name=星门控制器 +tile.sgcraft:naquadahBlock.name=硅岩合金方块 +tile.sgcraft:naquadahOre.name=硅岩矿 +tile.sgcraft:ic2PowerUnit.name=工业时代2能量单元 +tile.sgcraft:rfPowerUnit.name=红石通量能量单元 +tile.sgcraft:ccInterface.name=电脑星门界面 +tile.sgcraft:ocInterface.name=开放式电脑星门界面 +item.sgcraft:naquadah.name=硅岩 +item.sgcraft:naquadahIngot.name=硅岩合金锭 +item.sgcraft:sgCoreCrystal.name=星门核心水晶 +item.sgcraft:sgControllerCrystal.name=星门控制器水晶 +item.sgcraft:sgChevronUpgrade.name=星门人字升级 +item.sgcraft:sgIrisUpgrade.name=星门虹彩升级 +item.sgcraft:sgIrisBlade.name=星门虹彩剑 +item.sgcraft:ic2Capacitor.name=荒谬大的电容 +death.attack.sgcraft:transient=%1$s 被事件视界撕裂了 +death.attack.sgcraft:iris=%1$s 被星门虹彩击杀了 +entity.Villager.sgcraft:tokra=托克拉商人 +itemGroup.sgcraft:sgcraft=星际之门 + +message.sgcraft:disconnectFirst=在破坏前请断开星门连接 +message.sgcraft:irisAtDestination=目标地点被虹彩所阻挡 +message.sgcraft:incomingConnection=另一端已开始拨号 +message.sgcraft:selfBusy=星门正忙 +message.sgcraft:targetBusy=位于 %s 的星门正忙 +message.sgcraft:selfOutOfRange=传送星门的坐标位于范围外 +message.sgcraft:targetOutOfRange=坐标位于星门范围外 +message.sgcraft:unknownAddress=无法在 %s 处找到星门 +message.sgcraft:selfLackChevrons=星门人字不足以传送至 %s +message.sgcraft:targetLackChevrons=目标星门人字不足 +message.sgcraft:diallingItself=星门无法向自己拨号 +message.sgcraft:insufficientEnergy=星门人字不足 +message.sgcraft:malformedAddress=错误星门地址 +message.sgcraft:dimensionTooFar=星门无法到达目标维度 \ No newline at end of file diff --git a/src/resources/assets/sgcraft/models/dhd.smeg b/src/resources/assets/sgcraft/models/block/dhd.smeg similarity index 100% rename from src/resources/assets/sgcraft/models/dhd.smeg rename to src/resources/assets/sgcraft/models/block/dhd.smeg diff --git a/src/resources/assets/sgcraft/models/block/naquadahBlock.json b/src/resources/assets/sgcraft/models/block/naquadahblock.json similarity index 94% rename from src/resources/assets/sgcraft/models/block/naquadahBlock.json rename to src/resources/assets/sgcraft/models/block/naquadahblock.json index b41a6bee..65513382 100644 --- a/src/resources/assets/sgcraft/models/block/naquadahBlock.json +++ b/src/resources/assets/sgcraft/models/block/naquadahblock.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "sgcraft:blocks/naquadahBlock" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "sgcraft:blocks/naquadahBlock" + } +} diff --git a/src/resources/assets/sgcraft/models/block/naquadahOre.json b/src/resources/assets/sgcraft/models/block/naquadahore.json similarity index 94% rename from src/resources/assets/sgcraft/models/block/naquadahOre.json rename to src/resources/assets/sgcraft/models/block/naquadahore.json index 1d44a77d..9d9cb86d 100644 --- a/src/resources/assets/sgcraft/models/block/naquadahOre.json +++ b/src/resources/assets/sgcraft/models/block/naquadahore.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "sgcraft:blocks/naquadahOre" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "sgcraft:blocks/naquadahOre" + } +} diff --git a/src/resources/assets/sgcraft/models/item/ic2Capacitor.json b/src/resources/assets/sgcraft/models/item/ic2Capacitor.json deleted file mode 100644 index ace294e9..00000000 --- a/src/resources/assets/sgcraft/models/item/ic2Capacitor.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/ic2Capacitor" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/ic2capacitor.json b/src/resources/assets/sgcraft/models/item/ic2capacitor.json new file mode 100644 index 00000000..7ca0b092 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/ic2capacitor.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/ic2Capacitor" + } +} diff --git a/src/resources/assets/sgcraft/models/item/naquadah.json b/src/resources/assets/sgcraft/models/item/naquadah.json index b29cbd89..b359013f 100644 --- a/src/resources/assets/sgcraft/models/item/naquadah.json +++ b/src/resources/assets/sgcraft/models/item/naquadah.json @@ -1,18 +1,6 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "sgcraft:items/naquadah" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } } } diff --git a/src/resources/assets/sgcraft/models/item/naquadahIngot.json b/src/resources/assets/sgcraft/models/item/naquadahIngot.json deleted file mode 100644 index 045e6074..00000000 --- a/src/resources/assets/sgcraft/models/item/naquadahIngot.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/naquadahIngot" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/naquadahBlock.json b/src/resources/assets/sgcraft/models/item/naquadahblock.json similarity index 96% rename from src/resources/assets/sgcraft/models/item/naquadahBlock.json rename to src/resources/assets/sgcraft/models/item/naquadahblock.json index efe74be4..e0c56046 100644 --- a/src/resources/assets/sgcraft/models/item/naquadahBlock.json +++ b/src/resources/assets/sgcraft/models/item/naquadahblock.json @@ -1,10 +1,10 @@ -{ - "parent": "sgcraft:block/naquadahBlock", - "display": { - "thirdperson": { - "rotation": [ 10, -45, 170 ], - "translation": [ 0, 1.5, -2.75 ], - "scale": [ 0.375, 0.375, 0.375 ] - } - } -} +{ + "parent": "sgcraft:block/naquadahBlock", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} diff --git a/src/resources/assets/sgcraft/models/item/naquadahingot.json b/src/resources/assets/sgcraft/models/item/naquadahingot.json new file mode 100644 index 00000000..8a69084f --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/naquadahingot.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/naquadahIngot" + } +} diff --git a/src/resources/assets/sgcraft/models/item/naquadahOre.json b/src/resources/assets/sgcraft/models/item/naquadahore.json similarity index 95% rename from src/resources/assets/sgcraft/models/item/naquadahOre.json rename to src/resources/assets/sgcraft/models/item/naquadahore.json index 5e81723d..f154b176 100644 --- a/src/resources/assets/sgcraft/models/item/naquadahOre.json +++ b/src/resources/assets/sgcraft/models/item/naquadahore.json @@ -1,10 +1,10 @@ -{ - "parent": "sgcraft:block/naquadahOre", - "display": { - "thirdperson": { - "rotation": [ 10, -45, 170 ], - "translation": [ 0, 1.5, -2.75 ], - "scale": [ 0.375, 0.375, 0.375 ] - } - } -} +{ + "parent": "sgcraft:block/naquadahOre", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} diff --git a/src/resources/assets/sgcraft/models/item/sgChevronUpgrade.json b/src/resources/assets/sgcraft/models/item/sgChevronUpgrade.json deleted file mode 100644 index c231409b..00000000 --- a/src/resources/assets/sgcraft/models/item/sgChevronUpgrade.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/sgChevronUpgrade" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/sgControllerCrystal.json b/src/resources/assets/sgcraft/models/item/sgControllerCrystal.json deleted file mode 100644 index 9153a243..00000000 --- a/src/resources/assets/sgcraft/models/item/sgControllerCrystal.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/sgControllerCrystal" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/sgCoreCrystal.json b/src/resources/assets/sgcraft/models/item/sgCoreCrystal.json deleted file mode 100644 index 55c3357d..00000000 --- a/src/resources/assets/sgcraft/models/item/sgCoreCrystal.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/sgCoreCrystal" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/sgIrisBlade.json b/src/resources/assets/sgcraft/models/item/sgIrisBlade.json deleted file mode 100644 index c0877005..00000000 --- a/src/resources/assets/sgcraft/models/item/sgIrisBlade.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/sgIrisBlade" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/sgIrisUpgrade.json b/src/resources/assets/sgcraft/models/item/sgIrisUpgrade.json deleted file mode 100644 index c3fbfeab..00000000 --- a/src/resources/assets/sgcraft/models/item/sgIrisUpgrade.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "sgcraft:items/sgIrisUpgrade" - }, - "display": { - "thirdperson": { - "rotation": [ 0, 90, -35 ], - "translation": [ 0, 1.25, -3.5 ], - "scale": [ 0.85, 0.85, 0.85 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } - } -} diff --git a/src/resources/assets/sgcraft/models/item/sgchevronupgrade.json b/src/resources/assets/sgcraft/models/item/sgchevronupgrade.json new file mode 100644 index 00000000..fc198e63 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/sgchevronupgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/sgChevronUpgrade" + } +} diff --git a/src/resources/assets/sgcraft/models/item/sgcontrollercrystal.json b/src/resources/assets/sgcraft/models/item/sgcontrollercrystal.json new file mode 100644 index 00000000..c70adfe5 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/sgcontrollercrystal.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/sgControllerCrystal" + } +} diff --git a/src/resources/assets/sgcraft/models/item/sgcorecrystal.json b/src/resources/assets/sgcraft/models/item/sgcorecrystal.json new file mode 100644 index 00000000..33165e0e --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/sgcorecrystal.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/sgCoreCrystal" + } +} diff --git a/src/resources/assets/sgcraft/models/item/sgirisblade.json b/src/resources/assets/sgcraft/models/item/sgirisblade.json new file mode 100644 index 00000000..d5c29572 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/sgirisblade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/sgIrisBlade" + } +} diff --git a/src/resources/assets/sgcraft/models/item/sgirisupgrade.json b/src/resources/assets/sgcraft/models/item/sgirisupgrade.json new file mode 100644 index 00000000..fb8dfb90 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/sgirisupgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/sgIrisUpgrade" + } +} diff --git a/src/resources/assets/sgcraft/sounds.json b/src/resources/assets/sgcraft/sounds.json index c8ea8d69..2f89e57d 100644 --- a/src/resources/assets/sgcraft/sounds.json +++ b/src/resources/assets/sgcraft/sounds.json @@ -1,10 +1,62 @@ { - "sg_abort": {"category": "ambient", "sounds": ["sgcraft:sg_abort"]}, - "sg_close": {"category": "ambient", "sounds": ["sgcraft:sg_close"]}, - "sg_dial7": {"category": "ambient", "sounds": ["sgcraft:sg_dial7"]}, - "sg_dial9": {"category": "ambient", "sounds": ["sgcraft:sg_dial9"]}, - "sg_open": {"category": "ambient", "sounds": ["sgcraft:sg_open"]}, + "dial_fail": {"category": "ambient", "sounds": ["sgcraft:dial_fail"]}, + "chevron_outgoing": { + "category": "ambient", + "sounds": [ + "sgcraft:chev_usual1", + "sgcraft:chev_usual2", + "sgcraft:chev_usual3", + "sgcraft:chev_usual4", + "sgcraft:chev_usual5", + "sgcraft:chev_usual6", + "sgcraft:chev_usual7" + ] + }, + "chevron_incoming": { + "category": "ambient", + "sounds": [ + "sgcraft:chev_incoming1", + "sgcraft:chev_incoming2", + "sgcraft:chev_incoming3", + "sgcraft:chev_incoming4", + "sgcraft:chev_incoming5", + "sgcraft:chev_incoming6", + "sgcraft:chev_incoming7" + ] + }, + "gate_open": {"category": "ambient", "sounds": ["sgcraft:gate_open_long"]}, + "gate_close": {"category": "ambient", "sounds": ["sgcraft:gate_close"]}, "iris_open": {"category": "ambient", "sounds": ["sgcraft:iris_open"]}, "iris_close": {"category": "ambient", "sounds": ["sgcraft:iris_close"]}, - "iris_hit": {"category": "ambient", "sounds": ["sgcraft:iris_hit"]} + "iris_hit": {"category": "ambient", "sounds": ["sgcraft:iris_hit"]}, + "dhd_press": { + "category": "ambient", + "sounds": [ + "sgcraft:dhd_usual1", + "sgcraft:dhd_usual2", + "sgcraft:dhd_usual3", + "sgcraft:dhd_usual4", + "sgcraft:dhd_usual5", + "sgcraft:dhd_usual6", + "sgcraft:dhd_usual7" + ] + }, + "dhd_dial": {"category": "ambient", "sounds": ["sgcraft:dhd_usual_dial"]}, + "gate_roll": {"category": "ambient", "sounds": ["sgcraft:gate_roll"]}, + "lock_outgoing": {"category": "ambient", "sounds": ["sgcraft:lock_outgoing"]}, + "lock_incoming": {"category": "ambient", "sounds": ["sgcraft:lock_incoming"]}, + "event_horizon": {"category": "ambient", "sounds": ["sgcraft:event_horizon"]}, + "teleport": { + "category": "ambient", + "sounds": [ + "sgcraft:teleport1", + "sgcraft:teleport2", + "sgcraft:teleport3", + "sgcraft:teleport4", + "sgcraft:teleport5", + "sgcraft:teleport6", + "sgcraft:teleport7", + "sgcraft:teleport8" + ] + } } diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming1.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming1.ogg new file mode 100644 index 00000000..751c4707 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming1.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming2.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming2.ogg new file mode 100644 index 00000000..3179a638 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming2.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming3.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming3.ogg new file mode 100644 index 00000000..432b7a05 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming3.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming4.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming4.ogg new file mode 100644 index 00000000..20dc9c16 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming4.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming5.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming5.ogg new file mode 100644 index 00000000..aa56d0e3 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming5.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming6.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming6.ogg new file mode 100644 index 00000000..50c63553 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming6.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_incoming7.ogg b/src/resources/assets/sgcraft/sounds/chev_incoming7.ogg new file mode 100644 index 00000000..2ae6728f Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_incoming7.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual1.ogg b/src/resources/assets/sgcraft/sounds/chev_usual1.ogg new file mode 100644 index 00000000..335398c4 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual1.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual2.ogg b/src/resources/assets/sgcraft/sounds/chev_usual2.ogg new file mode 100644 index 00000000..c2c33f12 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual2.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual3.ogg b/src/resources/assets/sgcraft/sounds/chev_usual3.ogg new file mode 100644 index 00000000..5aaa9c8f Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual3.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual4.ogg b/src/resources/assets/sgcraft/sounds/chev_usual4.ogg new file mode 100644 index 00000000..8a413492 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual4.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual5.ogg b/src/resources/assets/sgcraft/sounds/chev_usual5.ogg new file mode 100644 index 00000000..4acc3999 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual5.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual6.ogg b/src/resources/assets/sgcraft/sounds/chev_usual6.ogg new file mode 100644 index 00000000..e768a857 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual6.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/chev_usual7.ogg b/src/resources/assets/sgcraft/sounds/chev_usual7.ogg new file mode 100644 index 00000000..953e036e Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/chev_usual7.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual1.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual1.ogg new file mode 100644 index 00000000..922485d8 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual1.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual2.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual2.ogg new file mode 100644 index 00000000..e587799f Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual2.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual3.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual3.ogg new file mode 100644 index 00000000..486ce73e Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual3.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual4.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual4.ogg new file mode 100644 index 00000000..1291ddb4 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual4.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual5.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual5.ogg new file mode 100644 index 00000000..281e901e Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual5.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual6.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual6.ogg new file mode 100644 index 00000000..6f43a155 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual6.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual7.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual7.ogg new file mode 100644 index 00000000..5d04d5f0 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual7.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dhd_usual_dial.ogg b/src/resources/assets/sgcraft/sounds/dhd_usual_dial.ogg new file mode 100644 index 00000000..ba9a6aa2 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dhd_usual_dial.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/dial_fail.ogg b/src/resources/assets/sgcraft/sounds/dial_fail.ogg new file mode 100644 index 00000000..65ac4ce1 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/dial_fail.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/event_horizon.ogg b/src/resources/assets/sgcraft/sounds/event_horizon.ogg new file mode 100644 index 00000000..1533a368 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/event_horizon.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/gate_close.ogg b/src/resources/assets/sgcraft/sounds/gate_close.ogg new file mode 100644 index 00000000..07ecea8f Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/gate_close.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/gate_open.ogg b/src/resources/assets/sgcraft/sounds/gate_open.ogg new file mode 100644 index 00000000..e0258242 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/gate_open.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/gate_open_long.ogg b/src/resources/assets/sgcraft/sounds/gate_open_long.ogg new file mode 100644 index 00000000..44383926 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/gate_open_long.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/gate_roll.ogg b/src/resources/assets/sgcraft/sounds/gate_roll.ogg new file mode 100644 index 00000000..88266e51 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/gate_roll.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/lock_incoming.ogg b/src/resources/assets/sgcraft/sounds/lock_incoming.ogg new file mode 100644 index 00000000..19f60390 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/lock_incoming.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/lock_outgoing.ogg b/src/resources/assets/sgcraft/sounds/lock_outgoing.ogg new file mode 100644 index 00000000..19f60390 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/lock_outgoing.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/sg_abort.ogg b/src/resources/assets/sgcraft/sounds/sg_abort.ogg deleted file mode 100644 index 8676534d..00000000 Binary files a/src/resources/assets/sgcraft/sounds/sg_abort.ogg and /dev/null differ diff --git a/src/resources/assets/sgcraft/sounds/sg_close.ogg b/src/resources/assets/sgcraft/sounds/sg_close.ogg deleted file mode 100644 index eb9b2cc7..00000000 Binary files a/src/resources/assets/sgcraft/sounds/sg_close.ogg and /dev/null differ diff --git a/src/resources/assets/sgcraft/sounds/sg_dial7.ogg b/src/resources/assets/sgcraft/sounds/sg_dial7.ogg deleted file mode 100644 index d28c74ac..00000000 Binary files a/src/resources/assets/sgcraft/sounds/sg_dial7.ogg and /dev/null differ diff --git a/src/resources/assets/sgcraft/sounds/sg_dial9.ogg b/src/resources/assets/sgcraft/sounds/sg_dial9.ogg deleted file mode 100644 index fd442be8..00000000 Binary files a/src/resources/assets/sgcraft/sounds/sg_dial9.ogg and /dev/null differ diff --git a/src/resources/assets/sgcraft/sounds/sg_open.ogg b/src/resources/assets/sgcraft/sounds/sg_open.ogg deleted file mode 100644 index 21d20fc9..00000000 Binary files a/src/resources/assets/sgcraft/sounds/sg_open.ogg and /dev/null differ diff --git a/src/resources/assets/sgcraft/sounds/teleport1.ogg b/src/resources/assets/sgcraft/sounds/teleport1.ogg new file mode 100644 index 00000000..d1affd09 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport1.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport2.ogg b/src/resources/assets/sgcraft/sounds/teleport2.ogg new file mode 100644 index 00000000..bdcee91a Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport2.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport3.ogg b/src/resources/assets/sgcraft/sounds/teleport3.ogg new file mode 100644 index 00000000..fff2f7c4 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport3.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport4.ogg b/src/resources/assets/sgcraft/sounds/teleport4.ogg new file mode 100644 index 00000000..7fd5a3da Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport4.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport5.ogg b/src/resources/assets/sgcraft/sounds/teleport5.ogg new file mode 100644 index 00000000..40efe0f4 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport5.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport6.ogg b/src/resources/assets/sgcraft/sounds/teleport6.ogg new file mode 100644 index 00000000..6199e874 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport6.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport7.ogg b/src/resources/assets/sgcraft/sounds/teleport7.ogg new file mode 100644 index 00000000..1a97ef54 Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport7.ogg differ diff --git a/src/resources/assets/sgcraft/sounds/teleport8.ogg b/src/resources/assets/sgcraft/sounds/teleport8.ogg new file mode 100644 index 00000000..8809edcc Binary files /dev/null and b/src/resources/assets/sgcraft/sounds/teleport8.ogg differ diff --git a/src/resources/assets/sgcraft/textures/blocks/ccInterface-bottom.png b/src/resources/assets/sgcraft/textures/blocks/ccinterface-bottom.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ccInterface-bottom.png rename to src/resources/assets/sgcraft/textures/blocks/ccinterface-bottom.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ccInterface-front.png b/src/resources/assets/sgcraft/textures/blocks/ccinterface-front.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ccInterface-front.png rename to src/resources/assets/sgcraft/textures/blocks/ccinterface-front.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ccInterface-side.png b/src/resources/assets/sgcraft/textures/blocks/ccinterface-side.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ccInterface-side.png rename to src/resources/assets/sgcraft/textures/blocks/ccinterface-side.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ccInterface-top.png b/src/resources/assets/sgcraft/textures/blocks/ccinterface-top.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ccInterface-top.png rename to src/resources/assets/sgcraft/textures/blocks/ccinterface-top.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-bottom.png b/src/resources/assets/sgcraft/textures/blocks/ic2powerunit-bottom.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-bottom.png rename to src/resources/assets/sgcraft/textures/blocks/ic2powerunit-bottom.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-side.png b/src/resources/assets/sgcraft/textures/blocks/ic2powerunit-side.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-side.png rename to src/resources/assets/sgcraft/textures/blocks/ic2powerunit-side.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-top.png b/src/resources/assets/sgcraft/textures/blocks/ic2powerunit-top.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ic2PowerUnit-top.png rename to src/resources/assets/sgcraft/textures/blocks/ic2powerunit-top.png diff --git a/src/resources/assets/sgcraft/textures/blocks/naquadahBlock.png b/src/resources/assets/sgcraft/textures/blocks/naquadahblock.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/naquadahBlock.png rename to src/resources/assets/sgcraft/textures/blocks/naquadahblock.png diff --git a/src/resources/assets/sgcraft/textures/blocks/naquadahOre.png b/src/resources/assets/sgcraft/textures/blocks/naquadahore.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/naquadahOre.png rename to src/resources/assets/sgcraft/textures/blocks/naquadahore.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ocInterface-bottom.png b/src/resources/assets/sgcraft/textures/blocks/ocinterface-bottom.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ocInterface-bottom.png rename to src/resources/assets/sgcraft/textures/blocks/ocinterface-bottom.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ocInterface-side.png b/src/resources/assets/sgcraft/textures/blocks/ocinterface-side.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ocInterface-side.png rename to src/resources/assets/sgcraft/textures/blocks/ocinterface-side.png diff --git a/src/resources/assets/sgcraft/textures/blocks/ocInterface-top.png b/src/resources/assets/sgcraft/textures/blocks/ocinterface-top.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/ocInterface-top.png rename to src/resources/assets/sgcraft/textures/blocks/ocinterface-top.png diff --git a/src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-bottom.png b/src/resources/assets/sgcraft/textures/blocks/rfpowerunit-bottom.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-bottom.png rename to src/resources/assets/sgcraft/textures/blocks/rfpowerunit-bottom.png diff --git a/src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-side.png b/src/resources/assets/sgcraft/textures/blocks/rfpowerunit-side.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-side.png rename to src/resources/assets/sgcraft/textures/blocks/rfpowerunit-side.png diff --git a/src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-top.png b/src/resources/assets/sgcraft/textures/blocks/rfpowerunit-top.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/rfPowerUnit-top.png rename to src/resources/assets/sgcraft/textures/blocks/rfpowerunit-top.png diff --git a/src/resources/assets/sgcraft/textures/blocks/stargateBase_front.png b/src/resources/assets/sgcraft/textures/blocks/stargatebase_front.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/stargateBase_front.png rename to src/resources/assets/sgcraft/textures/blocks/stargatebase_front.png diff --git a/src/resources/assets/sgcraft/textures/blocks/stargateBlock.png b/src/resources/assets/sgcraft/textures/blocks/stargateblock.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/stargateBlock.png rename to src/resources/assets/sgcraft/textures/blocks/stargateblock.png diff --git a/src/resources/assets/sgcraft/textures/blocks/stargateChevron.png b/src/resources/assets/sgcraft/textures/blocks/stargatechevron.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/stargateChevron.png rename to src/resources/assets/sgcraft/textures/blocks/stargatechevron.png diff --git a/src/resources/assets/sgcraft/textures/blocks/stargateRing.png b/src/resources/assets/sgcraft/textures/blocks/stargatering.png similarity index 100% rename from src/resources/assets/sgcraft/textures/blocks/stargateRing.png rename to src/resources/assets/sgcraft/textures/blocks/stargatering.png diff --git a/src/resources/assets/sgcraft/textures/gui/dhd_centre.png b/src/resources/assets/sgcraft/textures/gui/dhd_centre.png index 53f6226c..2647288e 100644 Binary files a/src/resources/assets/sgcraft/textures/gui/dhd_centre.png and b/src/resources/assets/sgcraft/textures/gui/dhd_centre.png differ diff --git a/src/resources/assets/sgcraft/textures/gui/symbols48.png b/src/resources/assets/sgcraft/textures/gui/symbols48.png index 449a8b2b..03c87438 100644 Binary files a/src/resources/assets/sgcraft/textures/gui/symbols48.png and b/src/resources/assets/sgcraft/textures/gui/symbols48.png differ diff --git a/src/resources/assets/sgcraft/textures/items/ic2Capacitor.png b/src/resources/assets/sgcraft/textures/items/ic2capacitor.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/ic2Capacitor.png rename to src/resources/assets/sgcraft/textures/items/ic2capacitor.png diff --git a/src/resources/assets/sgcraft/textures/items/naquadahIngot.png b/src/resources/assets/sgcraft/textures/items/naquadahingot.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/naquadahIngot.png rename to src/resources/assets/sgcraft/textures/items/naquadahingot.png diff --git a/src/resources/assets/sgcraft/textures/items/sgChevronUpgrade.png b/src/resources/assets/sgcraft/textures/items/sgchevronupgrade.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/sgChevronUpgrade.png rename to src/resources/assets/sgcraft/textures/items/sgchevronupgrade.png diff --git a/src/resources/assets/sgcraft/textures/items/sgControllerCrystal.png b/src/resources/assets/sgcraft/textures/items/sgcontrollercrystal.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/sgControllerCrystal.png rename to src/resources/assets/sgcraft/textures/items/sgcontrollercrystal.png diff --git a/src/resources/assets/sgcraft/textures/items/sgCoreCrystal.png b/src/resources/assets/sgcraft/textures/items/sgcorecrystal.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/sgCoreCrystal.png rename to src/resources/assets/sgcraft/textures/items/sgcorecrystal.png diff --git a/src/resources/assets/sgcraft/textures/items/sgIrisBlade.png b/src/resources/assets/sgcraft/textures/items/sgirisblade.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/sgIrisBlade.png rename to src/resources/assets/sgcraft/textures/items/sgirisblade.png diff --git a/src/resources/assets/sgcraft/textures/items/sgIrisUpgrade.png b/src/resources/assets/sgcraft/textures/items/sgirisupgrade.png similarity index 100% rename from src/resources/assets/sgcraft/textures/items/sgIrisUpgrade.png rename to src/resources/assets/sgcraft/textures/items/sgirisupgrade.png diff --git a/src/resources/assets/sgcraft/textures/tileentity/eventhorizonhd.png b/src/resources/assets/sgcraft/textures/tileentity/eventhorizonhd.png new file mode 100644 index 00000000..2f34344a Binary files /dev/null and b/src/resources/assets/sgcraft/textures/tileentity/eventhorizonhd.png differ diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 3afd9c74..a0559322 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -1,16 +1,16 @@ [ -{ - "modid": "${modid}", - "name": "Greg's SG Craft", - "description": "SG-1 stargates and other stuff.", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "http://www.cosc.canterbury.ac.nz/greg.ewing/minecraft/mods/SGCraft/", - "updateUrl": "", - "authors": ["Greg Ewing"], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} + { + "modid": "${modid}", + "name": "SG Craft", + "description": "SG-1 Stargates and other stuff.", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "http://www.cosc.canterbury.ac.nz/greg.ewing/minecraft/mods/SGCraft/", + "updateUrl": "", + "authors": [ "Greg Ewing", "AlmuraDev", "Radviger" ], + "logoFile": "", + "screenshots": [], + "dependencies": [], + "requiredMods": ["forge@14.23.5.2768"] + } ]