Reactor work in progress

This commit is contained in:
brandon3055 committed 2015-08-05 12:29:06 +10:00
1 parent 09d5547c71
commit 6031efd3a1
53 files changed
+1993 -175

No files matched your search

@@ -5,7 +5,14 @@ package com.brandon3055.draconicevolution.api;
*/
public interface IExtendedRFStorage
{
/**I will probably leave these here forever but i highly recommend switching as i may remove then at some point.*/
@Deprecated
double getEnergyStored();
@Deprecated
double getMaxEnergyStored();
long getExtendedStorage();
long getExtendedCapacity();
}
@@ -1,7 +1,7 @@
/**
* Created by Brandon on 19/03/2015.
*/
@API(apiVersion = "1.0", owner = "DraconicEvolution", provides = "DraconicEvolution|API")
@API(apiVersion = "1.1", owner = "DraconicEvolution", provides = "DraconicEvolution|API")
package com.brandon3055.draconicevolution.api;
import cpw.mods.fml.common.API;
@@ -14,10 +14,12 @@ import com.brandon3055.draconicevolution.client.render.item.RenderBow;
import com.brandon3055.draconicevolution.client.render.item.RenderMobSoul;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
import com.brandon3055.draconicevolution.client.render.tile.*;
import com.brandon3055.draconicevolution.common.CommonProxy;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
@@ -29,6 +31,7 @@ import com.brandon3055.draconicevolution.common.tileentities.energynet.TileWirel
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
import com.brandon3055.draconicevolution.common.utills.UpdateChecker;
import cpw.mods.fml.client.FMLClientHandler;
@@ -41,6 +44,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
@@ -118,13 +122,14 @@ public class ClientProxy extends CommonProxy {
KeyBindings.init();
registerRenderIDs();
registerRendering();
ResourceHandler.instance.tick(null);
}
@Override
public void postInit(FMLPostInitializationEvent event)
{
super.postInit(event);
ResourceHandler.instance.tick(null);
}
public void registerRendering()
@@ -137,6 +142,9 @@ public class ClientProxy extends CommonProxy {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new RenderParticleGen());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new RenderEnergyInfuser());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyCrystal), new RenderCrystal());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorStabilizer), new RenderReactorStabilizer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorEnergyInjector), new RenderReactorEnergyInjector());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore());
//ISimpleBlockRendering
RenderingRegistry.registerBlockHandler(new RenderTeleporterStand());
@@ -158,6 +166,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileWirelessEnergyTransceiver.class, new RenderTileCrystal());
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorCore.class, new RenderTileReactorCore());
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorStabilizer.class, new RenderTileReactorStabilizer());
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorEnergyInjector.class, new RenderTileReactorEnergyInjector());
//Entitys
RenderingRegistry.registerEntityRenderingHandler(EntityCustomDragon.class, new RenderDragon());
@@ -223,6 +232,34 @@ public class ClientProxy extends CommonProxy {
return beam;
}
@Override
public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) {
if (!tile.getWorldObj().isRemote || !(tile instanceof IIsSlave)) return null;
ParticleReactorBeam beam = oldBeam;
boolean inRange = ParticleHandler.isInRange(tile.xCoord, tile.yCoord, tile.zCoord, 50);
if (beam == null || beam.isDead)
{
if (inRange)
{
beam = new ParticleReactorBeam(tile);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam);
}
}
else if (!inRange)
{
beam.setDead();
return null;
}
else
{
beam.update(render);
}
return beam;
}
public boolean isOp(String paramString)
{
return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative();
@@ -2,11 +2,13 @@ package com.brandon3055.draconicevolution.client.gui;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIManual;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIReactor;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIToolConfig;
import com.brandon3055.draconicevolution.common.container.*;
import com.brandon3055.draconicevolution.common.inventory.InventoryTool;
import com.brandon3055.draconicevolution.common.tileentities.*;
import com.brandon3055.draconicevolution.common.tileentities.gates.TileGate;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.entity.player.EntityPlayer;
@@ -28,6 +30,7 @@ public class GuiHandler implements IGuiHandler {
public static final int GUIID_DRACONIC_CHEST = 11;
public static final int GUIID_TOOL_CONFIG = 12;
public static final int GUIID_FLOW_GATE = 13;
public static final int GUIID_REACTOR = 14;
public static final int GUIID_CONTAINER_TEMPLATE = 100;
public GuiHandler() {
@@ -85,6 +88,12 @@ public class GuiHandler implements IGuiHandler {
return new ContainerDraconiumChest(player.inventory, (TileDraconiumChest) containerChest);
}
break;
case GUIID_REACTOR:
TileEntity reactor = world.getTileEntity(x, y, z);
if (reactor != null && reactor instanceof TileReactorCore) {
return new ContainerReactor(player, (TileReactorCore) reactor);
}
break;
case GUIID_TOOL_CONFIG:
return new ContainerAdvTool(player.inventory, new InventoryTool(player, null));
@@ -159,6 +168,12 @@ public class GuiHandler implements IGuiHandler {
return new GUIDraconiumChest(player.inventory, (TileDraconiumChest) containerChest);
}
break;
case GUIID_REACTOR:
TileEntity reactor = world.getTileEntity(x, y, z);
if (reactor != null && reactor instanceof TileReactorCore) {
return new GUIReactor(player, (TileReactorCore) reactor, new ContainerReactor(player, (TileReactorCore) reactor));
}
break;
case GUIID_TOOL_CONFIG:
return new GUIToolConfig(player, new ContainerAdvTool(player.inventory, new InventoryTool(player, null)));
case GUIID_FLOW_GATE:
@@ -25,7 +25,6 @@ public class GuiTextureButton extends GuiButton {
if (this.visible)
{
FontRenderer fontrenderer = mc.fontRenderer;
// mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
int k = this.getHoverState(this.field_146123_n);
@@ -115,8 +115,8 @@ public class GUIManual extends GUIScrollingBase {
}
@Override
public void buttonClicked(int id) {
super.buttonClicked(id);
public void buttonClicked(int id, int button) {
super.buttonClicked(id, button);
if (id == 0)
{
collection.setOnlyGroupEnabled(GR_BACKGROUND);
@@ -0,0 +1,126 @@
package com.brandon3055.draconicevolution.client.gui.componentguis;
import com.brandon3055.brandonscore.client.utills.GuiHelper;
import com.brandon3055.draconicevolution.client.gui.guicomponents.*;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.container.ContainerReactor;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import java.util.ArrayList;
import java.util.List;
/**
* Created by brandon3055 on 30/7/2015.
*/
public class GUIReactor extends GUIBase {
private TileReactorCore reactor;
private ContainerReactor container;
public GUIReactor(EntityPlayer player, TileReactorCore reactor, ContainerReactor container) {
super(container, 248, 222);
this.reactor = reactor;
this.container = container;
}
@Override
protected ComponentCollection assembleComponents() {
collection = new ComponentCollection(0, 0, 248, 222, this);
collection.addComponent(new ComponentTexturedRect(0, 0, xSize, ySize, ResourceHandler.getResource("textures/gui/Reactor.png")));
collection.addComponent(new ComponentTextureButton(14, 190, 18, 54, 18, 18, 0, this, "", StatCollector.translateToLocal("button.de.reactorStart.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("ACTIVATE");
collection.addComponent(new ComponentTextureButton(216, 190, 18, 108, 18, 18, 1, this, "", StatCollector.translateToLocal("button.de.reactorStop.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("DEACTIVATE");
return collection;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {//todo tool tips
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
//Draw I/O Slots
if (reactor.reactorState == TileReactorCore.STATE_OFFLINE){
RenderHelper.enableGUIStandardItemLighting();
drawTexturedModalRect(guiLeft + 14, guiTop + 139, 14, ySize, 18, 18);
drawTexturedModalRect(guiLeft + 216, guiTop + 139, 32, ySize, 18, 18);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.insert.txt"), guiLeft + 8, guiTop + 159, 0);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 13, guiTop + 168, 0);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.extract.txt"), guiLeft + 206, guiTop + 159, 0);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 215, guiTop + 168, 0);
}
drawCenteredString(fontRendererObj, "Draconic Reactor", guiLeft + xSize / 2, guiTop + 4, 0x00FFFF);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
ResourceHandler.bindResource("textures/gui/Reactor.png");
//Draw Indicators
double value = reactor.reactionTemperature / reactor.maxReactTemperature;
int pixOffset = (int)(value * 108);
drawTexturedModalRect(11, 112 - pixOffset, 0, 222, 14, 5);
value = reactor.fieldCharge / reactor.maxFieldCharge;
pixOffset = (int)(value * 108);
drawTexturedModalRect(35, 112 - pixOffset, 0, 222, 14, 5);
value = (double)reactor.energySaturation / (double)reactor.maxEnergySaturation;
pixOffset = (int)(value * 108);
drawTexturedModalRect(199, 112 - pixOffset, 0, 222, 14, 5);
value = (double)reactor.convertedFuel / (double)reactor.reactorFuel;
pixOffset = (int)(value * 108);
drawTexturedModalRect(223, 112 - pixOffset, 0, 222, 14, 5);
double fuelM2 = Math.round((double)reactor.reactorFuel / 1296D * 1000D) / 1000D;
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.coreMass.txt") + ": " + fuelM2 + "m³", 5, 130, 0);
String status = StatCollector.translateToLocal("gui.de.status.txt")+": " + (reactor.reactorState == 0 ? EnumChatFormatting.DARK_GRAY : reactor.reactorState == 1 ? EnumChatFormatting.RED : reactor.reactorState == 2 ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + StatCollector.translateToLocal("gui.de.status"+reactor.reactorState+".txt");
fontRendererObj.drawString(status, xSize - 5 - fontRendererObj.getStringWidth(status), 130, 0);
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
List<String> text = new ArrayList<String>();
if (GuiHelper.isInRect(9, 4, 18, 144, mouseX - guiLeft, mouseY - guiTop)){
text.add(StatCollector.translateToLocal("gui.de.reactionTemp.txt"));
text.add((int)reactor.reactionTemperature + "°C");
drawHoveringText(text, mouseX, mouseY, fontRendererObj);
}
else if (GuiHelper.isInRect(33, 4, 18, 144, mouseX-guiLeft, mouseY-guiTop)){
text.add(StatCollector.translateToLocal("gui.de.fieldStrength.txt"));
if (reactor.maxFieldCharge > 0) text.add(reactor.fieldCharge / reactor.maxFieldCharge * 100D + "%");
drawHoveringText(text, mouseX, mouseY, fontRendererObj);
}
else if (GuiHelper.isInRect(197, 4, 18, 144, mouseX-guiLeft, mouseY-guiTop)){
text.add(StatCollector.translateToLocal("gui.de.energySaturation.txt"));
if (reactor.maxEnergySaturation > 0) text.add((double)reactor.energySaturation / (double)reactor.maxEnergySaturation * 100D + "%");
drawHoveringText(text, mouseX, mouseY, fontRendererObj);
}
else if (GuiHelper.isInRect(221, 4, 18, 144, mouseX-guiLeft, mouseY-guiTop)){
text.add(StatCollector.translateToLocal("gui.de.fuelConversion.txt"));
if (reactor.reactorFuel + reactor.convertedFuel > 0) text.add((double)reactor.convertedFuel / ((double)reactor.convertedFuel + (double)reactor.reactorFuel) * 100D + "%");
drawHoveringText(text, mouseX, mouseY, fontRendererObj);
}
}
@Override
public void updateScreen() {
if (reactor.reactorState == TileReactorCore.STATE_OFFLINE || reactor.reactorState == TileReactorCore.STATE_STOP) collection.getComponent("DEACTIVATE").setEnabled(false);
else collection.getComponent("DEACTIVATE").setEnabled(true);
if ((reactor.reactorState == TileReactorCore.STATE_OFFLINE || reactor.reactorState == TileReactorCore.STATE_STOP) && reactor.reactorFuel > 0) collection.getComponent("ACTIVATE").setEnabled(true);
else collection.getComponent("ACTIVATE").setEnabled(false);
super.updateScreen();
}
@Override
public void buttonClicked(int id, int button) {
container.sendObjectToServer(null, 20, id);
super.buttonClicked(id, button);
}
}
@@ -151,8 +151,8 @@ public class GUIToolConfig extends GUIBase {
}
@Override
public void buttonClicked(int id) {
super.buttonClicked(id);
public void buttonClicked(int id, int button) {
super.buttonClicked(id, button);
if (id == 0 && screenLevel > 0){//button back
setLevel(screenLevel - 1);
@@ -50,8 +50,8 @@ public class GUIToolInventory extends GUIBase {
}
@Override
public void buttonClicked(int id) {
super.buttonClicked(id);
public void buttonClicked(int id, int button) {
super.buttonClicked(id, button);
if (guiToolConfig == null) guiToolConfig = new GUIToolConfig(player, container);
guiToolConfig.updateItemButtons();
Minecraft.getMinecraft().displayGuiScreen(guiToolConfig);
@@ -105,6 +105,6 @@ public class ComponentButton extends ComponentBase {
@Override
public void mouseClicked(int x, int y, int button) {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
gui.buttonClicked(buttonId);
gui.buttonClicked(buttonId, button);
}
}
@@ -0,0 +1,54 @@
package com.brandon3055.draconicevolution.client.gui.guicomponents;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/**
* Created by brandon3055 on 31/7/2015.
*/
public class ComponentTextureButton extends ComponentButton {
public int textureXPos;
public int textureYPos;
private ResourceLocation texture;
//public ComponentTextureButton(int id, int xPos, int yPos, int textureXPos, int textureYPos, int xSise, int ySise, String text) {
public ComponentTextureButton(int x, int y, int textureXPos, int textureYPos, int xSize, int ySize, int id, GUIBase gui, String displayString, String hoverText, ResourceLocation texture) {
super(x, y, xSize, ySize, id, gui, displayString, hoverText);
this.textureXPos = textureXPos;
this.textureYPos = textureYPos;
this.texture = texture;
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
GL11.glPushMatrix();
//GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
minecraft.getTextureManager().bindTexture(texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int k = isMouseOver(mouseX, mouseY) ? 2 : 1;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.x, this.y, textureXPos, textureYPos + k * ySize, this.xSize, this.ySize);
int l = 14737632;
if (packedFGColour != 0)
{
l = packedFGColour;
}
else if (!this.enabled)
{
l = 10526880;
}
else if (isMouseOver(mouseX, mouseY))
{
l = 16777120;
}
this.drawCenteredString(fontRendererObj, this.displayString, this.x + this.xSize / 2, this.y + (this.ySize - 8) / 2, l);
//GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -122,7 +122,7 @@ public abstract class GUIBase extends GuiContainer {
buttonPressed = false;
}
public void buttonClicked(int id){buttonPressed = true;}
public void buttonClicked(int id, int button){buttonPressed = true;}
public int getXSize() { return xSize; }
@@ -28,7 +28,7 @@ import java.util.*;
* Created by Brandon on 8/02/2015.
*/
public class ResourceHandler {
private static ResourceHandler instance = new ResourceHandler();
public static ResourceHandler instance = new ResourceHandler();
private static ResourceLocation defaultParticles;
private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png");
private static Map<String, ResourceLocation> cachedResources = new HashMap<String, ResourceLocation>();
@@ -49,10 +49,11 @@ public class ResourceHandler {
{
if (downloadThread != null && downloadThread.isFinished)
{
LogHelper.info("Image Download Finished");
if (downloadThread.isReloadRequired()) LogHelper.info("Image Download Finished");
downloadStatus = downloadThread.wasSuccessful ? 1 : 2;
FMLCommonHandler.instance().bus().unregister(this);
addRSPack();
addRSPack(event != null);
downloadThread = null;
}
}
@@ -73,6 +74,7 @@ public class ResourceHandler {
private List<String> imageURLs;
private boolean isFinished = false;
private boolean wasSuccessful = true;
private boolean reloadRequired = false;
public DownloadThread(List<String> imageURLs)
{
@@ -85,8 +87,7 @@ public class ResourceHandler {
for (String s : imageURLs)
{
LogHelper.info("Checking Image: " + s);
boolean success = true;
if (!checkExistence(s)) downloadImage(s);
if (!checkExistence(s)) if (downloadImage(s)) reloadRequired = true;
if (checkExistence(s))
{
try
@@ -99,18 +100,15 @@ public class ResourceHandler {
}
catch (MalformedURLException e)
{
success = false;
LogHelper.error("Image Read Failed");
e.printStackTrace();
}
catch (IOException e)
{
success = false;
LogHelper.error("Image Read Failed");
e.printStackTrace();
}
}
else success = false;
}
isFinished = true;
@@ -165,10 +163,14 @@ public class ResourceHandler {
public boolean wasSuccessful() {
return wasSuccessful;
}
public boolean isReloadRequired() {
return reloadRequired;
}
}
private static void addRSPack()
private static void addRSPack(boolean refreash)
{
File rspack = new File(getConfigFolder(), "/resources");
if (!rspack.exists()) return;
@@ -202,7 +204,7 @@ public class ResourceHandler {
f.set(Minecraft.getMinecraft(), defaultResourcePacks);
LogHelper.info("RS Added");
Minecraft.getMinecraft().refreshResources();
if (refreash) Minecraft.getMinecraft().refreshResources();
}
catch (IllegalAccessException e) {
e.printStackTrace();
@@ -0,0 +1,185 @@
package com.brandon3055.draconicevolution.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
/**
* ModelReactorPowerInjector - brandon3055
* Created using Tabula 5.0.0
*/
public class ModelReactorEnergyInjector extends ModelBase {
public ModelRenderer BasePlate;
public ModelRenderer shape14;
public ModelRenderer coreSupports;
public ModelRenderer element1;
public ModelRenderer support1;
public ModelRenderer element7;
public ModelRenderer element6;
public ModelRenderer element5;
public ModelRenderer element8;
public ModelRenderer element2;
public ModelRenderer element3;
public ModelRenderer element4;
public ModelRenderer support2;
public ModelRenderer support3;
public ModelRenderer support4;
public ModelRenderer connector1;
public ModelRenderer connector2;
public ModelRenderer connector3;
public ModelRenderer connector4;
public ModelRenderer connector5;
public ModelRenderer connector6;
public ModelRenderer connector7;
public ModelRenderer support8;
public ModelRenderer connector8;
public ModelRenderer support5;
public ModelRenderer support6;
public ModelRenderer support7;
public ModelReactorEnergyInjector() {
this.textureWidth = 64;
this.textureHeight = 32;
this.connector5 = new ModelRenderer(this, 4, 19);
this.connector5.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector5.addBox(-3.5F, 3.5F, -0.5F, 1, 1, 1, 0.0F);
this.support4 = new ModelRenderer(this, 6, 21);
this.support4.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support4.addBox(3.5F, 0.0F, -1.5F, 1, 7, 3, 0.0F);
this.support6 = new ModelRenderer(this, 2, 26);
this.support6.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support6.addBox(4.5F, 3.0F, -0.5F, 1, 4, 1, 0.0F);
this.element2 = new ModelRenderer(this, 0, 12);
this.element2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element2.addBox(-1.0F, 2.5F, 2.0F, 2, 3, 1, 0.0F);
this.setRotateAngle(element2, 0.0F, 1.5707963267948966F, 0.0F);
this.element4 = new ModelRenderer(this, 0, 12);
this.element4.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element4.addBox(-1.0F, 2.5F, 2.0F, 2, 3, 1, 0.0F);
this.setRotateAngle(element4, 0.0F, 3.141592653589793F, 0.0F);
this.element6 = new ModelRenderer(this, 0, 1);
this.element6.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element6.addBox(-1.0F, -3.0F, 1.9F, 2, 5, 1, 0.0F);
this.setRotateAngle(element6, 0.0F, -1.5707963267948966F, 0.0F);
this.connector2 = new ModelRenderer(this, 8, 19);
this.connector2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector2.addBox(-4.5F, -1.0F, -0.5F, 2, 1, 1, 0.0F);
this.element5 = new ModelRenderer(this, 0, 1);
this.element5.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element5.addBox(-1.0F, -3.0F, 1.9F, 2, 5, 1, 0.0F);
this.setRotateAngle(element5, 0.0F, 1.5707963267948966F, 0.0F);
this.support7 = new ModelRenderer(this, 2, 26);
this.support7.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support7.addBox(-0.5F, 3.0F, -5.5F, 1, 4, 1, 0.0F);
this.connector8 = new ModelRenderer(this, 4, 19);
this.connector8.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector8.addBox(-0.5F, 3.5F, 2.5F, 1, 1, 1, 0.0F);
this.element7 = new ModelRenderer(this, 0, 1);
this.element7.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element7.addBox(-1.0F, -3.0F, 1.9F, 2, 5, 1, 0.0F);
this.support1 = new ModelRenderer(this, 42, 23);
this.support1.setRotationPoint(0.0F, -1.0F, 0.0F);
this.support1.addBox(-1.5F, 0.0F, 3.5F, 3, 7, 1, 0.0F);
this.connector7 = new ModelRenderer(this, 4, 19);
this.connector7.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector7.addBox(-0.5F, 3.5F, -3.5F, 1, 1, 1, 0.0F);
this.support5 = new ModelRenderer(this, 2, 26);
this.support5.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support5.addBox(-5.5F, 3.0F, -0.5F, 1, 4, 1, 0.0F);
this.support8 = new ModelRenderer(this, 2, 26);
this.support8.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support8.addBox(-0.5F, 3.0F, 4.5F, 1, 4, 1, 0.0F);
this.shape14 = new ModelRenderer(this, 0, 17);
this.shape14.setRotationPoint(0.0F, 0.0F, 0.0F);
this.shape14.addBox(-7.0F, 6.0F, -7.0F, 14, 1, 14, 0.0F);
this.BasePlate = new ModelRenderer(this, 0, 0);
this.BasePlate.setRotationPoint(0.0F, 0.0F, 0.0F);
this.BasePlate.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 16, 0.0F);
this.element8 = new ModelRenderer(this, 0, 1);
this.element8.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element8.addBox(-1.0F, -3.0F, 1.9F, 2, 5, 1, 0.0F);
this.setRotateAngle(element8, 0.0F, 3.141592653589793F, 0.0F);
this.element1 = new ModelRenderer(this, 0, 12);
this.element1.setRotationPoint(0.0F, -1.0F, 0.0F);
this.element1.addBox(-1.0F, 2.5F, 2.0F, 2, 3, 1, 0.0F);
this.connector4 = new ModelRenderer(this, 3, 21);
this.connector4.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector4.addBox(-0.5F, -1.0F, -4.5F, 1, 1, 2, 0.0F);
this.connector6 = new ModelRenderer(this, 4, 19);
this.connector6.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector6.addBox(2.5F, 3.5F, -0.5F, 1, 1, 1, 0.0F);
this.support2 = new ModelRenderer(this, 42, 23);
this.support2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support2.addBox(-1.5F, 0.0F, -4.5F, 3, 7, 1, 0.0F);
this.support3 = new ModelRenderer(this, 6, 21);
this.support3.setRotationPoint(0.0F, 0.0F, 0.0F);
this.support3.addBox(-4.5F, 0.0F, -1.5F, 1, 7, 3, 0.0F);
this.connector3 = new ModelRenderer(this, 3, 21);
this.connector3.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector3.addBox(-0.5F, -1.0F, 2.5F, 1, 1, 2, 0.0F);
this.element3 = new ModelRenderer(this, 0, 12);
this.element3.setRotationPoint(0.0F, 0.0F, 0.0F);
this.element3.addBox(-1.0F, 2.5F, 2.0F, 2, 3, 1, 0.0F);
this.setRotateAngle(element3, 0.0F, -1.5707963267948966F, 0.0F);
this.connector1 = new ModelRenderer(this, 8, 19);
this.connector1.setRotationPoint(0.0F, 0.0F, 0.0F);
this.connector1.addBox(2.5F, -1.0F, -0.5F, 2, 1, 1, 0.0F);
this.coreSupports = new ModelRenderer(this, 42, 17);
this.coreSupports.setRotationPoint(0.0F, -1.0F, 0.0F);
this.coreSupports.addBox(-2.5F, 6.0F, -2.5F, 5, 1, 5, 0.0F);
this.support1.addChild(this.connector5);
this.support1.addChild(this.support4);
this.support1.addChild(this.support6);
this.element1.addChild(this.element2);
this.element1.addChild(this.element4);
this.element1.addChild(this.element6);
this.support1.addChild(this.connector2);
this.element1.addChild(this.element5);
this.support1.addChild(this.support7);
this.support1.addChild(this.connector8);
this.element1.addChild(this.element7);
this.support1.addChild(this.connector7);
this.support1.addChild(this.support5);
this.support1.addChild(this.support8);
this.BasePlate.addChild(this.shape14);
this.element1.addChild(this.element8);
this.support1.addChild(this.connector4);
this.support1.addChild(this.connector6);
this.support1.addChild(this.support2);
this.support1.addChild(this.support3);
this.support1.addChild(this.connector3);
this.element1.addChild(this.element3);
this.support1.addChild(this.connector1);
}
@Override
public void render(Entity entity, float brightness, float f1, float f2, float f3, float f4, float f5) {
this.support1.render(f5);
this.BasePlate.render(f5);
this.coreSupports.render(f5);
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
float b = brightness * 200F;
float colour = Math.min(2F, (brightness*2F) + 0.5F);
if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b));
GL11.glColor4f(colour, colour, colour, 1F);
this.element1.render(f5);
GL11.glColor4f(1F, 1F, 1F, 1F);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING);
}
/**
* This is a helper function from Tabula to set the rotation of model parts
*/
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -226,4 +226,6 @@ public class ModelReactorStabilizerRing extends ModelBase {
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -0,0 +1,40 @@
package com.brandon3055.draconicevolution.client.render.block;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.render.tile.RenderTileReactorCore;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
/**
* Created by brandon3055 on 30/7/2015.
*/
public class RenderReactorCore implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0);
else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0.5, 0.5, 0.5);
if (type == ItemRenderType.EQUIPPED)GL11.glRotated(90, 0, 1, 0);
}
ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png");
GL11.glScaled(0.5, 0.5, 0.5);
RenderTileReactorCore.reactorModel.renderAll();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,40 @@
package com.brandon3055.draconicevolution.client.render.block;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.render.tile.RenderTileReactorEnergyInjector;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
/**
* Created by brandon3055 on 30/7/2015.
*/
public class RenderReactorEnergyInjector implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
float scale = (1F / 16F);
if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0);
else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0.5, 0.5, 0.5);
GL11.glRotated(90, 0, 1, 0);
}
GL11.glRotated(180, 0, 0, 1);
ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png");
RenderTileReactorEnergyInjector.modelReactorEnergyInjector.render(null, 1F, 0F, 0F, 0F, 0F, scale);
GL11.glPopMatrix();
}
}
@@ -0,0 +1,45 @@
package com.brandon3055.draconicevolution.client.render.block;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.render.tile.RenderTileReactorStabilizer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
/**
* Created by brandon3055 on 30/7/2015.
*/
public class RenderReactorStabilizer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
float scale = (1F / 16F);
if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0);
else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0.5, 0.5, 0.5);
if (type == ItemRenderType.EQUIPPED)GL11.glRotated(90, 0, 1, 0);
}
ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png");
RenderTileReactorStabilizer.modelStabilizerCore.render(null, 0F, 1F, 0F, 0F, 0F, scale);
ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png");
GL11.glRotated(90, 1, 0, 0);
GL11.glTranslated(0, -0.58, 0);
GL11.glScaled(0.95, 0.95, 0.95);
RenderTileReactorStabilizer.modelStabilizerRing.render(null, -70F, 1F, 0F, 0F, 0F, scale);
GL11.glPopMatrix();
}
}
@@ -0,0 +1,224 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 17/7/2015.
*/
public class ParticleReactorBeam extends EntityFX {
/**
* Particle Type 0 = Energy Ring, 1 = single particle
*/
private boolean renderParticle = true;
private TileEntity tile;
private boolean isInjectorBeam = false;
public ParticleReactorBeam(TileEntity tile) {
super(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0.0D, 0.0D, 0.0D);
this.tile = tile;
this.particleRed = 1F;
this.particleGreen = 1F;
this.particleBlue = 1F;
this.noClip = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.particleMaxAge = 4;
this.setSize(1F, 1F);
isInjectorBeam = tile instanceof TileReactorEnergyInjector;
}
public void update(boolean render)
{
for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {}
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
if (!((IIsSlave)tile).isActive()) return;
tessellator.draw();
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F);
float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX);
float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY);
float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ);
GL11.glTranslated((double)xx, (double)yy, (double)zz);
//Common Fields
MultiblockHelper.TileLocation master = ((IIsSlave)tile).getMaster();
float offsetX = (float)(master.posX - tile.xCoord);
float offsetY = (float)((double)master.posY - tile.yCoord);
float offsetZ = (float)(master.posZ - tile.zCoord);
float length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ);
//Rotate beam to face target
float f7 = MathHelper.sqrt_float(offsetX * offsetX + offsetZ * offsetZ);
GL11.glRotatef((float) (-Math.atan2((double) offsetZ, (double) offsetX)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float)(-Math.atan2((double)f7, (double)offsetY)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
if (tile instanceof TileReactorStabilizer) renderStabilizerEffect(tessellator, offsetX, offsetY, offsetZ, length, partialTick);
else {
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glTranslated(0, 0, 0.3);
//GL11.glPushMatrix();
GL11.glRotatef(((float)particleAge + partialTick)*20F, 0, 0, 1);
ResourceHandler.bindResource("textures/particle/reactorEnergyBeam.png");
float sizeOrigin = 0.5F;
float sizeTarget = 0.2F;
int color = 0xFF2200;
int alpha = 200;
length -= 1;
float speed = 20F;
float texV2 = 0.0F + ((float)particleAge + partialTick) * 0.01F * speed;
float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) + ((float)particleAge + partialTick) * 0.01F * speed;
tessellator.startDrawing(5);
tessellator.setBrightness(200);
byte b0 = 16;
for (int i = 0; i <= b0; ++i)
{
float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget;
float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget;
float texU = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha);
tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1);
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0);
tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2);
}
sizeTarget = 0.1F;
length = 0F;
for (int i = 0; i <= b0; ++i)
{
float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.3F / (float)b0) * sizeTarget;
float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.3F / (float)b0) * sizeTarget;
float texU = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0);
tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), -0.55D, (double)texU, (double)texV1);
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha);
tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2);
}
tessellator.draw();
//GL11.glPopMatrix();
GL11.glRotatef(((float)particleAge + partialTick)*-30F, 0, 0, 1);
tessellator.startDrawing(5);
tessellator.setBrightness(200);
color = 0xFF4400;
sizeOrigin = 0.15F;
sizeTarget = 0.6F;
length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) - 1;
GL11.glTranslated(0, 0, -0.1);
for (int i = 0; i <= b0; ++i)
{
float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget;
float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget;
float texU = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha/2);
tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1);
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0);
tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2);
}
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_CULL_FACE);
ResourceHandler.bindDefaultParticles();
tessellator.startDrawingQuads();
}
private void renderStabilizerEffect(Tessellator tessellator, float offsetX, float offsetY, float offsetZ, float length, float partialTick){
GL11.glShadeModel(GL11.GL_SMOOTH);
//Draw Beams
GL11.glPushMatrix();
GL11.glTranslated(0, 0, -0.35);
ResourceHandler.bindResource("textures/particle/reactorBeam.png");
drawBeam(tessellator, 1F, 0.355F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, false, 0x00ffff);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, 0, 0.45);
float coreSize = 0.9F;
float s = 0.355F;
drawBeam(tessellator, s / coreSize, coreSize, length - 1F, offsetX, offsetY, offsetZ, particleAge, partialTick, false, false, 0x00ffff);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, 0, -0.35);
drawBeam(tessellator, 1F, 0.263F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, true, 0xff6600);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, 0, 0.45);
coreSize = 0.5F;
s = 0.263F;
drawBeam(tessellator, s / coreSize, coreSize, length - 0.5F, offsetX, offsetY, offsetZ, particleAge, partialTick, false, true, 0xff6600);
GL11.glPopMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
}
/**Size Origin is the fraction of size start Target
* So if size target is 10 and size origin is 0.5 origin will actually be 5*/
private void drawBeam(Tessellator tessellator, float sizeOrigin, float sizeTarget, float length, float offsetX, float offsetY, float offsetZ, int tick, float partialTick, boolean reverseTransparency, boolean reverseDirection, int color) {
float speed = 3F;
float texV2 = -0.1F + ((float)tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed;
float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) / 32.0F + ((float)tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed;
tessellator.startDrawing(5);
tessellator.setBrightness(200);
byte b0 = 16;
for (int i = 0; i <= b0; ++i)
{
float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13325F / (float)b0) * sizeTarget;
float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13325F / (float)b0) * sizeTarget;
float texU = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? 0 : 255);
tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1);
tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? 255 : 0);
tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2);
}
tessellator.draw();
}
}
@@ -38,21 +38,12 @@ public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer
bindTexture(texture);
tessellator.setColorRGBA(255, 255, 255, 255);
//tessellator.setBrightness(200);
//tessellator.setColorOpaque_F(1f, 1f, 1f);
//OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);
// GL11.glEnable(GL11.GL_CULL_FACE);
// GL11.glDisable(GL11.GL_ALPHA_TEST);
// GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
// GL11.glDepthMask(true);
drawBase(tessellator);
drawWings(tessellator, tile);
renderChargingItem(tile);
GL11.glDisable(GL11.GL_ALPHA_TEST);
// GL11.glDepthMask(false);
}
@@ -88,7 +88,7 @@ public class RenderTileEnergyPylon extends TileEntitySpecialRenderer {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopAttrib();
@@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL11;
* Created by Brandon on 16/6/2015.
*/
public class RenderTileReactorCore extends TileEntitySpecialRenderer {
private IModelCustom reactorModel;
public static IModelCustom reactorModel;
public RenderTileReactorCore(){
reactorModel = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj"));
@@ -24,16 +24,24 @@ public class RenderTileReactorCore extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) {
TileReactorCore tile = (TileReactorCore) tileEntity;
// tile.renderList.clear();
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F);
renderReactorCore(tile, partialTick);
// for (MultiblockHelper.TileOffset offset : tile.stabilizerLocations){
// if (!(offset.getTileEntity(tileEntity) instanceof TileReactorStabilizer)) continue;
// GL11.glPushMatrix();
//
// TileReactorStabilizer stabilizer = (TileReactorStabilizer)offset.getTileEntity(tileEntity);
// GL11.glTranslated(-offset.offsetX, -offset.offsetY, -offset.offsetZ);
// //RenderTileReactorStabilizer.renderCore(stabilizer, partialTick);
// //RenderTileReactorStabilizer.renderEffects(stabilizer, partialTick);
//
// GL11.glPopMatrix();
// }
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -46,25 +54,49 @@ public class RenderTileReactorCore extends TileEntitySpecialRenderer {
double b = ff * 2;
double a = ff < 0.1 ? (ff * 10) + 0.5 : 1;
//Pre Render
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F);
//Render inner
ResourceHandler.bindResource("textures/models/reactorCore.png");
//GL11.glScaled(2F, 2F, 2F);
ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png");
if (tile.reactorFuel + tile.convertedFuel < 144){
GL11.glPushMatrix();
GL11.glScaled(0.1, 0.1, 0.1);
reactorModel.renderAll();
GL11.glPopMatrix();
}
GL11.glRotatef(rotation, 0.5F, 1F, 0.5F);
GL11.glScaled(0.5, 0.5, 0.5);
double r3 = tile.getCoreDiameter();
GL11.glScaled(r3, r3, r3);
reactorModel.renderAll();
//Mid Render
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0F);
//Render Outer
ResourceHandler.bindResource("textures/models/reactorShieldPlate.png");
GL11.glColor4d(r, g, b, a);
GL11.glScaled(1.03F, 1.03F, 1.03F);
GL11.glRotatef(2343, 0.5F, 1F, 0.5F);
GL11.glRotatef(-rotation*2, 0.5F, 1F, 0.5F);
reactorModel.renderAll();
//Post Render
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1f, 1f, 1f, 1f);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
GL11.glPopMatrix();
}
}
@@ -0,0 +1,45 @@
package com.brandon3055.draconicevolution.client.render.tile;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.model.ModelReactorEnergyInjector;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 6/7/2015.
*/
public class RenderTileReactorEnergyInjector extends TileEntitySpecialRenderer {
public static ModelReactorEnergyInjector modelReactorEnergyInjector = new ModelReactorEnergyInjector();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
renderCore((TileReactorEnergyInjector) tileEntity, partialTick);
GL11.glPopMatrix();
}
public static void renderCore(TileReactorEnergyInjector tile, float partialTick) {
GL11.glPushMatrix();
float scale = (1F / 16F);
switch (tile.facingDirection){
case 1: GL11.glRotated(180, -1, 0, 0); break;
case 2: GL11.glRotated(90, 1, 0, 0); break;
case 3: GL11.glRotated(90, -1, 0, 0); break;
case 4: GL11.glRotated(90, 0, 0, -1); break;
case 5: GL11.glRotated(90, 0, 0, 1);
}
ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png");
modelReactorEnergyInjector.render(null, tile.modelIllumination, 0F, 0F, 0F, 0F, scale);
GL11.glPopMatrix();
}
}
@@ -3,14 +3,9 @@ package com.brandon3055.draconicevolution.client.render.tile;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.model.ModelReactorStabilizerCore;
import com.brandon3055.draconicevolution.client.model.ModelReactorStabilizerRing;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/**
@@ -27,12 +22,13 @@ public class RenderTileReactorStabilizer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
renderCore((TileReactorStabilizer) tileEntity, partialTick);
renderEffects((TileReactorStabilizer) tileEntity, partialTick);
//renderEffects((TileReactorStabilizer) tileEntity, partialTick);
GL11.glPopMatrix();
}
private void renderCore(TileReactorStabilizer tile, float partialTick) {
public static void renderCore(TileReactorStabilizer tile, float partialTick) {
GL11.glPushMatrix();
float scale = (1F / 16F);
float coreRotation = tile.coreRotation + (partialTick * tile.coreSpeed);
float ringRotation = tile.ringRotation + (partialTick * tile.ringSpeed);
@@ -48,61 +44,80 @@ public class RenderTileReactorStabilizer extends TileEntitySpecialRenderer {
ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png");
modelStabilizerCore.render(null, coreRotation, tile.modelIllumination, 0F, 0F, 0F, scale);
GL11.glPushMatrix();
ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png");
GL11.glRotated(90, 1, 0, 0);
GL11.glTranslated(0, -0.58, 0);
GL11.glScaled(0.95, 0.95, 0.95);
GL11.glRotatef(ringRotation, 0, 1, 0);
modelStabilizerRing.render(null, 0F, tile.modelIllumination, 0F, 0F, 0F, scale);
modelStabilizerRing.render(null, -70F, tile.modelIllumination, 0F, 0F, 0F, scale);
GL11.glPopMatrix();
}
private void renderEffects(TileReactorStabilizer tile, float partialTick) {
if (tile.isValid)
{
float someRotation = tile.tick;
MultiblockHelper.TileLocation master = tile.masterLocation;
float f2 = someRotation + partialTick;
float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F;
f3 = (f3 * f3 + f3) * 0.2F;
float f4 = (float)(master.posX - tile.xCoord - (0 - 0) * (double)(1.0F - partialTick));
float f5 = (float)((double)f3 + master.posY - 1.0D - tile.yCoord - (0 - 0) * (double)(1.0F - partialTick));
float f6 = (float)(master.posZ - tile.zCoord - (0 - 0) * (double)(1.0F - partialTick));
float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6);
float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6);
GL11.glPushMatrix();
// GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_ + 2.0F, (float)p_76986_6_);
GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_CULL_FACE);
ResourceHandler.bindTexture(new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"));
GL11.glShadeModel(GL11.GL_SMOOTH);
float f9 = 0.0F - ((float)tile.tick + partialTick) * 0.01F;
float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)tile.tick + partialTick) * 0.01F;
tessellator.startDrawing(5);
byte b0 = 8;
for (int i = 0; i <= b0; ++i)
{
float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F;
float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F;
float f13 = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorOpaque_I(0);
tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10);
tessellator.setColorOpaque_I(16777215);
tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9);
}
tessellator.draw();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
}
}
// public static void renderEffects(TileReactorStabilizer tile, float partialTick) {
// if (tile.isValid)
// {
// //Common Fields
// MultiblockHelper.TileLocation master = tile.masterLocation;
// float offsetX = (float)(master.posX - tile.xCoord);
// float offsetY = (float)((double)master.posY - tile.yCoord);
// float offsetZ = (float)(master.posZ - tile.zCoord);
// float length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ);
//
// Tessellator tessellator = Tessellator.instance;
//
// //Pre Render
// GL11.glPushMatrix();
//// RenderHelper.disableStandardItemLighting();
// GL11.glDisable(GL11.GL_CULL_FACE);
// GL11.glShadeModel(GL11.GL_SMOOTH);
// GL11.glEnable(GL11.GL_BLEND);
// OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
// GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F);
// GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDepthMask(false);
//
// //Rotate beam to face target
// float f7 = MathHelper.sqrt_float(offsetX * offsetX + offsetZ * offsetZ);
// GL11.glRotatef((float) (-Math.atan2((double) offsetZ, (double) offsetX)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
// GL11.glRotatef((float)(-Math.atan2((double)f7, (double)offsetY)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
//
//
// //Draw Beams
// GL11.glPushMatrix();
// GL11.glTranslated(0, 0, -0.35);
// ResourceHandler.bindTexture(new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"));
//// drawBeam(tessellator, 1F, 0.355F, 0.8F, offsetX, offsetY, offsetZ, tile.tick, partialTick, true, false);
// GL11.glPopMatrix();
//
// GL11.glPushMatrix();
// GL11.glTranslated(0, 0, 0.4526);
// float coreSize = 1.1F;
// float s = 0.355F;
//// drawBeam(tessellator, s/coreSize, coreSize, length - 0.5F, offsetX, offsetY, offsetZ, tile.tick, partialTick, false, false);
// GL11.glPopMatrix();
//
//// GL11.glPushMatrix();
//// GL11.glTranslated(0, 0, -0.35);
//// ResourceHandler.bindTexture(new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"));
//// drawBeam(tessellator, 1F, 0.26F, 0.8F, offsetX, offsetY, offsetZ, tile.tick, partialTick, true, true);
//// GL11.glPopMatrix();
////
//// GL11.glPushMatrix();
//// GL11.glTranslated(0, 0, 0.4526);
//// coreSize = 1.1F;
//// s = 0.263F;
//// drawBeam(tessellator, s/coreSize, coreSize, length - 0.5F, offsetX, offsetY, offsetZ, tile.tick, partialTick, false, true);
//// GL11.glPopMatrix();
//
// //Post Render
// GL11.glDepthMask(true);
// GL11.glEnable(GL11.GL_LIGHTING);
// GL11.glEnable(GL11.GL_CULL_FACE);
// GL11.glShadeModel(GL11.GL_FLAT);
//// RenderHelper.enableStandardItemLighting();
// GL11.glDisable(GL11.GL_BLEND);
// GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
// GL11.glPopMatrix();
// }
// }
}
@@ -5,6 +5,7 @@ import com.brandon3055.draconicevolution.client.creativetab.DETab;
import com.brandon3055.draconicevolution.client.gui.GuiHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
import com.brandon3055.draconicevolution.common.achievements.Achievements;
import com.brandon3055.draconicevolution.common.entity.*;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
@@ -24,6 +25,7 @@ import com.brandon3055.draconicevolution.common.tileentities.gates.TileFluidGate
import com.brandon3055.draconicevolution.common.tileentities.gates.TileFluxGate;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.*;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator;
@@ -35,6 +37,8 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
@@ -52,6 +56,9 @@ public class CommonProxy {
initializeNetwork();
if (ModBlocks.isEnabled(ModBlocks.draconiumOre)) OreDictionary.registerOre("oreDraconium", ModBlocks.draconiumOre);
if (ModBlocks.isEnabled(ModBlocks.draconiumBlock)) OreDictionary.registerOre("blockDraconium", new ItemStack(ModBlocks.draconiumBlock));
if (ModBlocks.isEnabled(ModBlocks.draconicBlock)) OreDictionary.registerOre("blockDraconiumAwakened", new ItemStack(ModBlocks.draconicBlock));
if (ModItems.isEnabled(ModItems.draconiumIngot)) OreDictionary.registerOre("ingotDraconium", ModItems.draconiumIngot);
if (ModItems.isEnabled(ModItems.draconiumDust)) OreDictionary.registerOre("dustDraconium", ModItems.draconiumDust);
if (ModItems.isEnabled(ModItems.draconicIngot)) OreDictionary.registerOre("ingotDraconiumAwakened", ModItems.draconicIngot);
@@ -150,6 +157,7 @@ public class CommonProxy {
GameRegistry.registerTileEntity(TileFluxGate.class, References.RESOURCESPREFIX + "TileFluxGate");
GameRegistry.registerTileEntity(TileFluidGate.class, References.RESOURCESPREFIX + "TileFluidGate");
GameRegistry.registerTileEntity(TileReactorStabilizer.class, References.RESOURCESPREFIX + "TileReactorStabilizer");
GameRegistry.registerTileEntity(TileReactorEnergyInjector.class, References.RESOURCESPREFIX + "TileReactorEnergyInjector");
if (DraconicEvolution.debug) {
GameRegistry.registerTileEntity(TileTestBlock.class, References.RESOURCESPREFIX + "TileTestBlock");
GameRegistry.registerTileEntity(TileContainerTemplate.class, References.RESOURCESPREFIX + "TileContainerTemplate");
@@ -189,7 +197,9 @@ public class CommonProxy {
return null;
}
public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) {
return null;
}
public void spawnParticle(Object particle, int range)
{
@@ -46,6 +46,7 @@ public class ModBlocks {
public static BlockDE reactorCore;
public static BlockDE flowGate;
public static BlockDE reactorStabilizer;
public static BlockDE reactorEnergyInjector;
public static Block safetyFlame;
public static ItemStack resurrectionStone;
@@ -83,6 +84,7 @@ public class ModBlocks {
reactorCore = new ReactorCore();
flowGate = new FlowGate();
reactorStabilizer = new ReactorStabilizer();
reactorEnergyInjector = new ReactorEnergyInjector();
longRangeDislocator = new LongRangeDislocator();
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.blocks;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner;
import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock;
@@ -26,6 +27,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
@@ -52,6 +54,11 @@ public class CustomSpawner extends BlockDE implements IHudDisplayBlock {
if (item != null && item.getItem().equals(ModItems.mobSoul))
{
String name = ItemNBTHelper.getString(item, "Name", "Pig");
if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(name)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(name))) {
if (!world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "[Error] soul disabled in config!"));
return false;
}
if (name.equals(spawner.getBaseLogic().entityName)){return false;}
spawner.getBaseLogic().entityName = name;
spawner.isSetToSpawn = true;
@@ -0,0 +1,14 @@
package com.brandon3055.draconicevolution.common.blocks.multiblock;
/**
* Created by Brandon on 23/7/2015.
*/
public interface IIsSlave {
public MultiblockHelper.TileLocation getMaster();
public void shutDown();
public boolean checkForMaster();
public boolean isActive();
}
@@ -221,7 +221,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock {
list.add(InfoHelper.HITC() + ModBlocks.energyStorageCore.getLocalizedName());
list.add("Tier: " + InfoHelper.ITC() + (master.getTier() + 1));
String BN = String.valueOf(master.getEnergyStored());
if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2);
if (BN.substring(Math.max(BN.length() - 2, 0)).contentEquals(".0")) BN = BN.substring(0, Math.max(BN.length() - 2, 0));
list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]");
return list;
@@ -13,6 +13,8 @@ public class MultiblockHelper {
public static class TileLocation extends ChunkCoordinates {
public boolean initialized = false;
public TileLocation(){
}
@@ -21,6 +23,7 @@ public class MultiblockHelper {
this.posX = x;
this.posY = y;
this.posZ = z;
initialized = true;
}
public int getXCoord(){
@@ -32,19 +35,32 @@ public class MultiblockHelper {
}
public int getZCoord(){
return posY;
return posZ;
}
public boolean isThisLocation(int x, int y, int z){
return x == posX && y == posY && z == posZ;
}
@Override
public void set(int x, int y, int z) {
initialized = true;
super.set(x, y, z);
}
public void setXCoord(int x){
posX = x;
initialized = true;
}
public void setYCoord(int y){
posY = y;
initialized = true;
}
public void setZCoord(int z){
posZ = z;
initialized = true;
}
public TileEntity getTileEntity(World world) { return world.getTileEntity(posX, posY, posZ); }
@@ -53,12 +69,72 @@ public class MultiblockHelper {
compound.setInteger("X_"+key, posX);
compound.setInteger("Y_"+key, posY);
compound.setInteger("Z_"+key, posZ);
compound.setBoolean("Init_"+key, initialized);
}
public void readFromNBT(NBTTagCompound compound, String key) {
posX = compound.getInteger("X_"+key);
posY = compound.getInteger("Y_"+key);
posZ = compound.getInteger("Z_"+key);
initialized = compound.getBoolean("Z_"+key);
}
}
public static class TileOffset {
public int offsetX;
public int offsetY;
public int offsetZ;
public TileOffset(){}
public TileOffset(int x, int y, int z, int offsetX, int offsetY, int offsetZ){
this.offsetX = x - offsetX;
this.offsetY = y - offsetY;
this.offsetZ = z - offsetZ;
}
public TileOffset(TileEntity tile1, TileEntity offsetTile){
this.offsetX = tile1.xCoord - offsetTile.xCoord;
this.offsetY = tile1.yCoord - offsetTile.yCoord;
this.offsetZ = tile1.zCoord - offsetTile.zCoord;
}
public int getXCoord(TileEntity tileEntity){
return tileEntity.xCoord - offsetX;
}
public int getYCoord(TileEntity tileEntity){
return tileEntity.yCoord - offsetY;
}
public int getZCoord(TileEntity tileEntity){
return tileEntity.zCoord - offsetZ;
}
public int getXCoord(int xCoord){
return xCoord - offsetX;
}
public int getYCoord(int yCoord){
return yCoord - offsetY;
}
public int getZCoord(int zCoord){
return zCoord - offsetZ;
}
public TileEntity getTileEntity(TileEntity tileEntity) { return tileEntity.getWorldObj().getTileEntity(getXCoord(tileEntity), getYCoord(tileEntity), getZCoord(tileEntity)); }
public void writeToNBT(NBTTagCompound compound, String key) {
compound.setInteger("X_"+key, offsetX);
compound.setInteger("Y_"+key, offsetY);
compound.setInteger("Z_"+key, offsetZ);
}
public void readFromNBT(NBTTagCompound compound, String key) {
offsetX = compound.getInteger("X_"+key);
offsetY = compound.getInteger("Y_"+key);
offsetZ = compound.getInteger("Z_"+key);
}
}
@@ -7,7 +7,9 @@ import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -53,4 +55,24 @@ public class ReactorCore extends BlockDE {
public TileEntity createTileEntity(World world, int metadata) {
return new TileReactorCore();
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null;
if (tile != null) tile.onPlaced();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null;
if (tile != null) return tile.onStructureRightClicked(player);
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) {
TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null;
if (tile != null) tile.onBroken();
super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_);
}
}
@@ -0,0 +1,101 @@
package com.brandon3055.draconicevolution.common.blocks.multiblock;
import com.brandon3055.brandonscore.common.utills.Utills;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Created by Brandon on 23/7/2015.
*/
public class ReactorEnergyInjector extends BlockDE {
public ReactorEnergyInjector(){
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
this.setBlockName("reactorEnergyInjector");
ModBlocks.register(this);
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency");
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess access, int x, int y, int z) {
TileReactorEnergyInjector tile = access.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) access.getTileEntity(x, y, z) : null;
if (tile != null){
switch (tile.facingDirection){
case 0: this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); break;
case 1: this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); break;
case 2: this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); break;
case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); break;
case 4: this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); break;
case 5: this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); break;
}
}
super.setBlockBoundsBasedOnState(access, x, y, z);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
TileReactorEnergyInjector tile = world.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) world.getTileEntity(x, y, z) : null;
if (tile != null){
switch (tile.facingDirection){
case 0: this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); break;
case 1: this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); break;
case 2: this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); break;
case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); break;
case 4: this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); break;
case 5: this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); break;
}
}
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int d = Utills.determineOrientation(x, y, z, entity);
TileReactorEnergyInjector tile = (TileReactorEnergyInjector)world.getTileEntity(x, y, z);
tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal();
tile.onPlaced();
}
@Override
public boolean hasTileEntity(int metadata) {
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
return new TileReactorEnergyInjector();
}
}
@@ -5,9 +5,11 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
@@ -60,8 +62,19 @@ public class ReactorStabilizer extends BlockDE {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int d = Utills.determineOrientation(x, y, z, entity);
TileReactorStabilizer tile = (TileReactorStabilizer)world.getTileEntity(x, y, z);
tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal();
tile.onPlaced();
TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer)world.getTileEntity(x, y, z) : null;
if (tile != null){
tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal();
tile.onPlaced();
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) {
TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer)world.getTileEntity(x, y, z) : null;
TileEntity core = null;
if (tile != null) core = tile.getMaster().getTileEntity(world);
super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_);
if (core instanceof TileReactorCore) ((TileReactorCore) core).validateStructure();
}
}
@@ -0,0 +1,167 @@
package com.brandon3055.draconicevolution.common.container;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.inventory.GenericInventory;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
/**
* Created by brandon3055 on 30/7/2015.
*/
public class ContainerReactor extends ContainerDataSync {
private TileReactorCore reactor;
private EntityPlayer player;
private GenericInventory ioSlots = new GenericInventory() {
private ItemStack[] items = new ItemStack[2];
@Override
public ItemStack[] getStorage() {
return items;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return itemstack != null && (itemstack.getItem() == ModItems.draconicIngot || itemstack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock));
}
@Override
public int getInventoryStackLimit() {
return super.getInventoryStackLimit();
}
@Override
public void setInventorySlotContents(int i, ItemStack stack) {
if (i == 0 && stack != null && (stack.getItem() == ModItems.draconicIngot || stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)))
{
if (stack.getItem() == ModItems.draconicIngot) reactor.reactorFuel += stack.stackSize * 144;
if (stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)) reactor.reactorFuel += stack.stackSize * 1296;
}
else getStorage()[i] = stack;
}
};
//Syncing //todo sort out syncing
public int LTReactorFuel = -1;
public int LTReactionIntensity = -1;
public int LTMaxReactIntensity = -1;
public int LTFieldStrength = -1;
public int LTEnergySaturation = -1;
public int LTMaxEnergySaturation = -1;
public int LTFuelConversion = -1;
//#######
public ContainerReactor(EntityPlayer player, TileReactorCore reactor){
this.reactor = reactor;
this.player = player;
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(player.inventory, x, 44 + 18 * x, 198));
}
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, 44 + 18 * x, 140 + y * 18));
}
}
if (reactor.reactorState == TileReactorCore.STATE_OFFLINE){
addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140));
addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {//todo (the chest thing)
return true;
}
@Override
public void detectAndSendChanges() { //todo check what values are being synced by the tile and remove them from here
if (reactor.reactorFuel != LTReactorFuel) LTReactorFuel = (Integer) sendObjectToClient(null, 0, reactor.reactorFuel);
if ((int)reactor.reactionTemperature != LTReactionIntensity)LTReactionIntensity = (Integer) sendObjectToClient(null, 1, (int) reactor.reactionTemperature);
if ((int)reactor.maxReactTemperature != LTMaxReactIntensity)LTMaxReactIntensity = (Integer) sendObjectToClient(null, 2, (int) reactor.maxReactTemperature);
if ((int)reactor.fieldCharge != LTFieldStrength) LTFieldStrength = (Integer) sendObjectToClient(null, 3, (int) reactor.fieldCharge);
if (reactor.energySaturation != LTEnergySaturation) LTEnergySaturation = (Integer) sendObjectToClient(null, 4, reactor.energySaturation);
if (reactor.maxEnergySaturation != LTMaxEnergySaturation) LTMaxEnergySaturation = (Integer) sendObjectToClient(null, 5, reactor.maxEnergySaturation);
if (reactor.convertedFuel != LTFuelConversion) LTFuelConversion = (Integer) sendObjectToClient(null, 6, reactor.convertedFuel);
super.detectAndSendChanges();
}
@Override
public void receiveSyncData(int index, int value) {
if (index == 0) reactor.reactorFuel = value;
else if (index == 1) reactor.reactionTemperature = value;
else if (index == 2) reactor.maxReactTemperature = value;
else if (index == 3) reactor.fieldCharge = value;
else if (index == 4) reactor.energySaturation = value;
else if (index == 5) reactor.maxEnergySaturation = value;
else if (index == 6) reactor.convertedFuel = value;
else if (index == 20){
reactor.processButtonPress(value == 0, value == 1);
}
}
@Override
public ItemStack slotClick(int slot, int button, int p_75144_3_, EntityPlayer player1) {
if (slot == 37 && player1.inventory.getItemStack() == null){
if (reactor.reactorFuel / 144 >= 64){
int i = reactor.reactorFuel / 1296;
int i2 = Math.min(64, i);
ioSlots.getStorage()[1] = new ItemStack(ModBlocks.draconicBlock, i2);
reactor.reactorFuel -= i2 * 1296;
}
else if (reactor.reactorFuel >= 144){
int i = reactor.reactorFuel / 144;
int i2 = Math.min(64, i);
ioSlots.getStorage()[1] = new ItemStack(ModItems.draconicIngot, i2);
reactor.reactorFuel -= i2 * 144;
}
}
return super.slotClick(slot, button, p_75144_3_, player1);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
return null;
}
public static class SlotInsert extends Slot {
public SlotInsert(IInventory iInventory, int iSlot, int x, int y) {
super(iInventory, iSlot, x, y);
}
@Override
public boolean isItemValid(ItemStack stack) {
return stack != null && (stack.getItem() == ModItems.draconicIngot || stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock));
}
@Override
public int getSlotStackLimit() {//todo add the fuel limit
return 64;
}
}
public static class SlotExtract extends Slot {
private GenericInventory inventory;
public SlotExtract(GenericInventory iInventory, int iSlot, int x, int y) {
super(iInventory, iSlot, x, y);
inventory = iInventory;
}
@Override
public boolean isItemValid(ItemStack stack) {
return false;
}
}
}
@@ -24,15 +24,15 @@ public class CraftingHandler {
//Components Key[C=Corner, S=Side, M=Middle ]
addOre(ModItems.draconicCore, "CSC", "SMS", "CSC", 'C', "ingotGold", 'S', ModItems.draconiumIngot, 'M', "gemDiamond");
add(ModItems.wyvernCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', ModItems.draconicCore, 'M', Items.nether_star);
add(ModItems.awakenedCore, "CSC", "SCS", "CSC", 'C', ModItems.draconicIngot, 'S', ModItems.wyvernCore);
addOre(ModItems.awakenedCore, "CSC", "SCS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernCore);
add(ModItems.wyvernEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', Blocks.redstone_block, 'M', ModItems.draconicCore);
add(ModItems.draconicEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconicIngot, 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore);
addOre(ModItems.draconicEnergyCore, "CSC", "SMS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore);
//addOre(ModItems.draconiumBlend, " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust);
addShaplessOre(getStack(ModItems.draconicIngot, 9, 0), Item.getItemFromBlock(ModBlocks.draconicBlock));
addShaplessOre(getStack(ModItems.draconiumIngot, 9, 0), Item.getItemFromBlock(ModBlocks.draconiumBlock));
addShaplessOre(getStack(ModItems.draconicIngot, 9, 0), "blockDraconiumAwakened");
addShaplessOre(getStack(ModItems.draconiumIngot, 9, 0), "blockDraconium");
if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumBlend)) GameRegistry.addSmelting(ModItems.draconiumBlend, getStack(ModItems.draconiumIngot, 2, 0), 1.0f);
if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumDust)) GameRegistry.addSmelting(ModItems.draconiumDust, getStack(ModItems.draconiumIngot, 1, 0), 1.0f);
if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumDust)) GameRegistry.addSmelting(new ItemStack(ModItems.draconiumDust), getStack(ModItems.draconiumIngot, 1, 0), 1.0f);
//Wyvern tools
@@ -50,31 +50,31 @@ public class CraftingHandler {
//Draconic Tools
addEnergy(ModItems.draconicFluxCapacitor, "CMC", "SPS", "CSC", 'C', ModItems.draconicIngot, 'S', ModItems.draconicEnergyCore, 'M', ModItems.awakenedCore, 'P', ModItems.wyvernFluxCapacitor);
addEnergy(ModItems.draconicFluxCapacitor, "CMC", "SPS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.draconicEnergyCore, 'M', ModItems.awakenedCore, 'P', ModItems.wyvernFluxCapacitor);
//tools
addEnergy(ModItems.draconicPickaxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', ModItems.wyvernPickaxe, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicShovel, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', ModItems.wyvernShovel, 'E', ModItems.draconicEnergyCore);
add(ModItems.draconicAxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', Items.diamond_axe, 'E', ModItems.draconicEnergyCore);
add(ModItems.draconicHoe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', Items.diamond_hoe, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicSword, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', ModItems.wyvernSword, 'E', ModItems.draconicEnergyCore);
add(ModItems.draconicBow, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'T', ModItems.wyvernBow, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicDestructionStaff, "IAI", "PIS", "IWI", 'I', ModItems.draconicIngot, 'A', ModItems.awakenedCore, 'P', ModItems.draconicPickaxe, 'S', ModItems.draconicShovel, 'W', ModItems.draconicSword);
addEnergy(ModItems.draconicPickaxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernPickaxe, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicShovel, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernShovel, 'E', ModItems.draconicEnergyCore);
addOre(ModItems.draconicAxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_axe, 'E', ModItems.draconicEnergyCore);
addOre(ModItems.draconicHoe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_hoe, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicSword, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernSword, 'E', ModItems.draconicEnergyCore);
addOre(ModItems.draconicBow, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernBow, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicDestructionStaff, "IAI", "PIS", "IWI", 'I', "ingotDraconiumAwakened", 'A', ModItems.awakenedCore, 'P', ModItems.draconicPickaxe, 'S', ModItems.draconicShovel, 'W', ModItems.draconicSword);
//armor
addEnergy(ModItems.draconicHelm, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'A', ModItems.wyvernHelm, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicChest, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'A', ModItems.wyvernChest, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicLeggs, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'A', ModItems.wyvernLeggs, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicBoots, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', ModItems.draconicIngot, 'A', ModItems.wyvernBoots, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicHelm, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernHelm, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicChest, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernChest, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicLeggs, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernLeggs, 'E', ModItems.draconicEnergyCore);
addEnergy(ModItems.draconicBoots, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernBoots, 'E', ModItems.draconicEnergyCore);
//Blocks
//storage
add(ModBlocks.draconiumBlock, "III", "III", "III", 'I', ModItems.draconiumIngot);
add(ModBlocks.draconicBlock, "III", "III", "III", 'I', ModItems.draconicIngot);
addOre(ModBlocks.draconiumBlock, "III", "III", "III", 'I', "ingotDraconium");
addOre(ModBlocks.draconicBlock, "III", "III", "III", 'I', "ingotDraconiumAwakened");
//aesthetic
add(ModBlocks.particleGenerator, "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore);
add(ModBlocks.infusedObsidian, "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', ModItems.draconiumDust);
addOre(ModBlocks.infusedObsidian, "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', "dustDraconium");
//machines
addOre(ModBlocks.potentiometer, "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block);
@@ -84,18 +84,18 @@ public class CraftingHandler {
//machines adv
add(ModBlocks.resurrectionStone, "CSC", "SMS", "CSC", 'C', mobSoul, 'S', ModItems.wyvernCore, 'M', ModBlocks.draconiumBlock);
add(ModBlocks.energyStorageCore, "CCC", "SMS", "CCC", 'C', ModItems.draconiumIngot, 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore);
add(ModBlocks.weatherController, "RIR", "TPT", "IEI", 'R', Items.blaze_rod, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', ModItems.draconiumIngot, 'E', Blocks.enchanting_table);
add(ModBlocks.playerDetectorAdvanced, "ISI", "EDE", "ICI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector);
add(ModBlocks.energyInfuser, "IPI", "CEC", "ICI", 'I', ModItems.draconiumIngot, 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table);
add(ModBlocks.draconiumChest, "IFI", "SCS", "IWI", 'I', ModItems.draconiumIngot, 'C', ModItems.draconicCore, 'S', getChest(), 'W', Blocks.crafting_table, 'F', Blocks.furnace);
addOre(getStack(ModBlocks.energyPylon, 2, 0), "IEI", "MCM", "IDI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald");
addOre(getStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', ModItems.draconiumIngot, 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace);
addOre(ModBlocks.resurrectionStone, "CSC", "SMS", "CSC", 'C', mobSoul, 'S', ModItems.wyvernCore, 'M', "blockDraconium");
addOre(ModBlocks.energyStorageCore, "CCC", "SMS", "CCC", 'C', "ingotDraconium", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore);
addOre(ModBlocks.weatherController, "RIR", "TPT", "IEI", 'R', Items.blaze_rod, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', "ingotDraconium", 'E', Blocks.enchanting_table);
addOre(ModBlocks.playerDetectorAdvanced, "ISI", "EDE", "ICI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector);
addOre(ModBlocks.energyInfuser, "IPI", "CEC", "ICI", 'I', "ingotDraconium", 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table);
addOre(ModBlocks.draconiumChest, "IFI", "SCS", "IWI", 'I', "ingotDraconium", 'C', ModItems.draconicCore, 'S', getChest(), 'W', Blocks.crafting_table, 'F', Blocks.furnace);
addOre(getStack(ModBlocks.energyPylon, 2, 0), "IEI", "MCM", "IDI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald");
addOre(getStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', "ingotDraconium", 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace);
addOre(ModBlocks.playerDetector, "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore);
addOre(getStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore);
addOre(ModBlocks.dissEnchanter, "PIP", "ETE", "CBC", 'P', Items.ender_eye, 'I', Items.enchanted_book, 'E', "gemEmerald", 'T', Blocks.enchanting_table, 'C', ModItems.draconicCore, 'B', Items.book);
addOre(getStack(ModBlocks.energyCrystal, 4, 0), "IDI", "DCD", "IDI", 'I' , ModItems.draconiumIngot, 'D', "gemDiamond", 'C', ModItems.draconicCore);
addOre(getStack(ModBlocks.energyCrystal, 4, 0), "IDI", "DCD", "IDI", 'I' , "ingotDraconium", 'D', "gemDiamond", 'C', ModItems.draconicCore);
addOre(getStack(ModBlocks.energyCrystal, 4, 1), "CRC", "RWR", "CRC", 'R' , getStack(ModBlocks.energyCrystal, 1, 0), 'W', ModItems.wyvernCore, 'C', ModItems.draconicCore);
addShaplessOre(getStack(ModBlocks.energyCrystal, 1, 0), getStack(ModBlocks.energyCrystal, 1, 2), getStack(ModBlocks.energyCrystal, 1, 2));
addShaplessOre(getStack(ModBlocks.energyCrystal, 2, 2), getStack(ModBlocks.energyCrystal, 1, 0));
@@ -106,14 +106,14 @@ public class CraftingHandler {
//Tools
add(ModItems.teleporterMKII, "IEI", "ETE", "IWI", 'I', ModItems.draconiumIngot, 'E', Items.ender_pearl, 'T', ModItems.teleporterMKI, 'W', ModItems.wyvernCore);
add(ModItems.teleporterMKI, "CSC", "SMS", "CSC", 'C', Items.blaze_powder, 'S', ModItems.draconiumDust, 'M', Items.ender_eye);
addOre(ModItems.teleporterMKII, "IEI", "ETE", "IWI", 'I', "ingotDraconium", 'E', Items.ender_pearl, 'T', ModItems.teleporterMKI, 'W', ModItems.wyvernCore);
addOre(ModItems.teleporterMKI, "CSC", "SMS", "CSC", 'C', Items.blaze_powder, 'S', "dustDraconium", 'M', Items.ender_eye);
addOre(getStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "stickWood");
add(ModItems.safetyMatch, "MMM", "MMM", "MMM", 'M', getStack(ModItems.safetyMatch, 1, 1000));
addOre(ModItems.wrench, " ID", " RI", "C ", 'I' , ModItems.draconiumIngot, 'D', "gemDiamond", 'R', Items.blaze_rod, 'C', ModItems.draconicCore);
addOre(ModItems.wrench, " ID", " RI", "C ", 'I' , "ingotDraconium", 'D', "gemDiamond", 'R', Items.blaze_rod, 'C', ModItems.draconicCore);
//Other
addOre(ModItems.infoTablet, "SSS", "SDS", "SSS", 'S', "stone", 'D', ModItems.draconiumDust);
addOre(ModItems.infoTablet, "SSS", "SDS", "SSS", 'S', "stone", 'D', "dustDraconium");
addShaplessOre(getStack(ModItems.enderArrow, 1, 0), Items.arrow, Items.ender_pearl);
addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeSapling", "treeSapling", "treeSapling");
addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeLeaves", "treeLeaves", "treeLeaves");
@@ -121,7 +121,7 @@ public class CraftingHandler {
//Disable able
//if(ConfigHandler.disableSunDial == 0)
add(ModBlocks.sunDial, "IAI", "CDC", "IEI", 'I', ModItems.draconiumIngot, 'A', ModItems.awakenedCore, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table, 'D', Blocks.dragon_egg);
addOre(ModBlocks.sunDial, "IAI", "CDC", "IEI", 'I', "ingotDraconium", 'A', ModItems.awakenedCore, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table, 'D', Blocks.dragon_egg);
//if(ConfigHandler.disableXrayBlock == 0)
addOre(getStack(ModBlocks.xRayBlock, 4, 0), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', "blockGlassColorless", 'D', "gemDiamond");
@@ -0,0 +1,99 @@
package com.brandon3055.draconicevolution.common.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
/**
* Created by brandon3055 on 31/7/2015.
*/
public abstract class GenericInventory implements IInventory {
public abstract ItemStack[] getStorage();
@Override
public int getSizeInventory() {
return getStorage().length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return slot < getStorage().length ? getStorage()[slot] : null;
}
@Override
public ItemStack decrStackSize(int i, int count) {
ItemStack itemstack = getStackInSlot(i);
if (itemstack != null)
{
if (itemstack.stackSize <= count)
{
setInventorySlotContents(i, null);
} else
{
itemstack = itemstack.splitStack(count);
if (itemstack.stackSize == 0)
{
setInventorySlotContents(i, null);
}
}
}
return itemstack;
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
ItemStack item = getStackInSlot(i);
if (item != null)
setInventorySlotContents(i, null);
return item;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
getStorage()[i] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return true;
}
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
@Override
public void markDirty() {
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; }
}
@@ -4,6 +4,7 @@ package com.brandon3055.draconicevolution.common.tileentities;
* Created by Brandon on 5/07/2014.
*/
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
@@ -18,6 +19,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.Arrays;
public abstract class CustomSpawnerBaseLogic {
/**
* The delay to spawn.
@@ -191,6 +194,11 @@ public abstract class CustomSpawnerBaseLogic {
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
this.entityName = par1NBTTagCompound.getString("EntityId");
this.spawnDelay = par1NBTTagCompound.getShort("Delay");
if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName))) {
this.entityName = "Pig";
((TileCustomSpawner)getSpawnerWorld().getTileEntity(getSpawnerX(), getSpawnerY(), getSpawnerZ())).isSetToSpawn = false;
}
powered = par1NBTTagCompound.getBoolean("Powered");
spawnSpeed = par1NBTTagCompound.getShort("Speed");
requiresPlayer = par1NBTTagCompound.getBoolean("RequiresPlayer");
@@ -146,7 +146,7 @@ public class TileGrinder extends TileObjectSync implements ISidedInventory, IEne
@SuppressWarnings("unchecked")
public boolean killNextEntity() {
if (worldObj.isRemote) return false;
if (fakePlayer == null) fakePlayer = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.randomUUID(), "[Draconic-Evolution]"));
if (fakePlayer == null) fakePlayer = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.fromString("5b5689b9-e43d-4282-a42a-dc916f3616b7"), "[Draconic-Evolution]"));
killBox = AxisAlignedBB.getBoundingBox(centreX - 4.5, centreY - 4.5, centreZ - 4.5, centreX + 4.5, centreY + 4.5, centreZ + 4.5);
killList = worldObj.getEntitiesWithinAABB(EntityLiving.class, killBox);
@@ -329,4 +329,14 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I
public double getMaxEnergyStored() {
return getMaster() != null ? getMaster().getMaxEnergyStored() : 0D;
}
@Override
public long getExtendedStorage() {
return getMaster() != null ? getMaster().getEnergyStored() : 0L;
}
@Override
public long getExtendedCapacity() {
return getMaster() != null ? getMaster().getMaxEnergyStored() : 0L;
}
}
@@ -23,9 +23,9 @@ public class TileEnergyStorageCore extends TileObjectSync {
protected int tier = 0;
protected boolean online = false;
public float modelRotation = 0;
private double energy = 0;
private double capacity = 0;
private double lastTickCapacity = 0;
private long energy = 0;
private long capacity = 0;
private long lastTickCapacity = 0;
private int tick = 0;
public TileEnergyStorageCore(){
@@ -605,28 +605,28 @@ public class TileEnergyStorageCore extends TileObjectSync {
tile.setMaster(new TileLocation(xCoord, yCoord, zCoord));
worldObj.setBlockMetadataWithNotify(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord(), 1, 2);
}
double capacity = 0;
long capacity = 0;
switch (tier){
case 0:
capacity = 45500000D;
capacity = 45500000L;
break;
case 1:
capacity = 273000000D;
capacity = 273000000L;
break;
case 2:
capacity = 1640000000D;
capacity = 1640000000L;
break;
case 3:
capacity = 9880000000D;
capacity = 9880000000L;
break;
case 4:
capacity = 59300000000D;
capacity = 59300000000L;
break;
case 5:
capacity = 356000000000D;
capacity = 356000000000L;
break;
case 6:
capacity = 2140000000000D;
capacity = 2140000000000L;
break;
}
this.capacity = capacity;
@@ -692,7 +692,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
super.writeToNBT(compound);
compound.setBoolean("Online", online);
compound.setShort("Tier", (short)tier);
compound.setDouble("Energy", energy);
compound.setLong("EnergyL", energy);
for (int i = 0; i < stabilizers.length; i++){
if (stabilizers[i] != null)
stabilizers[i].writeToNBT(compound, String.valueOf(i));
@@ -703,33 +703,34 @@ public class TileEnergyStorageCore extends TileObjectSync {
public void readFromNBT(NBTTagCompound compound) {
online = compound.getBoolean("Online");
tier = (int)compound.getShort("Tier");
energy = compound.getDouble("Energy");
energy = compound.getLong("EnergyL");
if (compound.hasKey("Energy")) energy = (long) compound.getDouble("Energy");
for (int i = 0; i < stabilizers.length; i++){
if (stabilizers[i] != null)
stabilizers[i].readFromNBT(compound, String.valueOf(i));
}
double capacity = 0;
long capacity = 0;
switch (tier){
case 0:
capacity = 45500000D;//000
capacity = 45500000L;//000
break;
case 1:
capacity = 273000000D;//000
capacity = 273000000L;//000
break;
case 2:
capacity = 1640000000D;//000
capacity = 1640000000L;//000
break;
case 3:
capacity = 9880000000D;//000
capacity = 9880000000L;//000
break;
case 4:
capacity = 59300000000D;//000
capacity = 59300000000L;//000
break;
case 5:
capacity = 356000000000D;//000
capacity = 356000000000L;//000
break;
case 6:
capacity = 2140000000000D;//000
capacity = 2140000000000L;//000
break;
}
this.capacity = capacity;
@@ -753,7 +754,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
public int receiveEnergy(int maxReceive, boolean simulate) {
int maxReceive1 = Integer.MAX_VALUE;
double energyReceived = Math.min(capacity - energy, Math.min(maxReceive1, maxReceive));
long energyReceived = Math.min(capacity - energy, Math.min(maxReceive1, maxReceive));
if (!simulate) {
energy += energyReceived;
@@ -763,7 +764,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
public int extractEnergy(int maxExtract, boolean simulate) {
int maxExtract1 = Integer.MAX_VALUE;
double energyExtracted = Math.min(energy, Math.min(maxExtract1, maxExtract));
long energyExtracted = Math.min(energy, Math.min(maxExtract1, maxExtract));
if (!simulate) {
energy -= energyExtracted;
@@ -771,11 +772,11 @@ public class TileEnergyStorageCore extends TileObjectSync {
return (int)energyExtracted;
}
public double getEnergyStored() {
public long getEnergyStored() {
return energy;
}
public double getMaxEnergyStored() {
public long getMaxEnergyStored() {
return capacity;
}
@@ -786,11 +787,11 @@ public class TileEnergyStorageCore extends TileObjectSync {
private void detectAndRendChanges(){
int diff = (int)Math.abs(lastTickCapacity - energy);
if (diff > 1000) lastTickCapacity = (Double) sendObjectToClient(References.DOUBLE_ID, 0, energy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20));
if (diff > 1000) lastTickCapacity = (Long) sendObjectToClient(References.LONG_ID, 0, energy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20));
}
@Override
public void receiveObjectFromServer(int index, Object object) {
energy = (Double) object;
energy = (Long) object;
}
}
@@ -1,17 +1,208 @@
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor;
import net.minecraft.tileentity.TileEntity;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.gui.GuiHandler;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by Brandon on 16/6/2015.
*/
public class TileReactorCore extends TileEntity {
public class TileReactorCore extends TileObjectSync {
public static final int MAX_SLAVE_RANGE = 10;
public static final int STATE_OFFLINE = 0;
public static final int STATE_START = 1;
public static final int STATE_ONLINE = 2;
public static final int STATE_STOP = 3;
public int reactorState = 0;
public float renderRotation = 0;
public boolean isStructureValid = true;
public boolean isActive = true;
public float renderStartProgress = 0F; //todo go from 0 to one when the reactor is starting and from 1 to 0 when the reactor is stopping (to control render transitions)
//Key operational figures
public int reactorFuel = 0;
public int convertedFuel = 0; //The amount of fuel that has converted to chaos
public double conversionUnit = 0; //used to smooth out the conversion between int and floating point. When >= 1 minus one and convert one int worth of fuel
public double reactionTemperature = 20;
public double maxReactTemperature = 10000; //Todo make this dependent on the fuel amount + fuel conversion
public double fieldCharge = 0;
public double maxFieldCharge = 200; //Todo make this dependent on the fuel value
public int energySaturation = 0; //Todo make this the energy buffer that the generation dumps into and that the stabilizers extract from
public int maxEnergySaturation = 10000; //Todo make this dependent on the fuel amount, This is the max RF/t output when at 0% saturation
public int startupEnergy = 0; //Used when starting. startup energy needs to reach max startup energy for the reactor to start
public int maxStartupEnergy = 0; //Todo make this dependent on the fuel level //maby just use saturation for startup...
//#######################
public List<TileLocation> stabilizerLocations = new ArrayList<TileLocation>();
@Override
public void updateEntity() {
if (worldObj.isRemote) renderRotation += 0.2F;
// if (!worldObj.isRemote) {
// renderRotation += 0.05;
//
// reactionTemperature = (int)(((1D + Math.sin(renderRotation)) / 2D) * (double)maxReactTemperature);
//
// fieldCharge = (int)(((1D + Math.sin(renderRotation + 1)) / 2D) * maxFieldCharge);
//
// energySaturation = (int)(((1D + Math.sin(renderRotation + 2)) / 2D) * (double)maxEnergySaturation);
//
// convertedFuel = (int)(((1D + Math.sin(renderRotation + 3)) / 2D) * (double)reactorFuel);
// }
}
public void validateStructure(){
boolean updateRequired = false;
LogHelper.info("validate");
//Check that all of the stabilizers are still valid
Iterator<TileLocation> i = stabilizerLocations.iterator();
while (i.hasNext()) {
TileLocation location = i.next();
if (!(location.getTileEntity(worldObj) instanceof TileReactorStabilizer) || !((TileReactorStabilizer) location.getTileEntity(worldObj)).masterLocation.isThisLocation(xCoord, yCoord, zCoord)) {
i.remove();
updateRequired = true;
}
}
if (updateRequired) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public void onPlaced(){
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
boolean flag = false;
for (int i = 1; i < MAX_SLAVE_RANGE && !flag; i++){
TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i);
if (location.getTileEntity(worldObj) != null){
if (location.getTileEntity(worldObj) instanceof IIsSlave && !((IIsSlave) location.getTileEntity(worldObj)).getMaster().initialized) ((IIsSlave) location.getTileEntity(worldObj)).checkForMaster();
flag = true;
}
}
}
}
public void onBroken(){
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
for (int i = 1; i < MAX_SLAVE_RANGE; i++){
TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i);
if (location.getTileEntity(worldObj) instanceof IIsSlave && ((IIsSlave) location.getTileEntity(worldObj)).getMaster().compareTo(new TileLocation(xCoord, yCoord, zCoord)) == 0) ((IIsSlave)location.getTileEntity(worldObj)).shutDown();
}
}
// for (TileLocation location : stabilizerLocations) {
// LogHelper.info(location.getTileEntity(worldObj));
// if (location.getTileEntity(worldObj) instanceof TileReactorStabilizer) ((TileReactorStabilizer) location.getTileEntity(worldObj)).shutDown();
// }
}
public boolean onStructureRightClicked(EntityPlayer player){
if (!worldObj.isRemote) player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_REACTOR, worldObj, xCoord, yCoord, zCoord);
return true;
}
public int injectEnergy(int RF){
return 0;
}
public void processButtonPress(boolean start, boolean stop){
}
//Getters
public double getCoreDiameter(){
double volume = (double)reactorFuel / 1296D;
volume *= 1 + ((double) reactionTemperature / (double) maxReactTemperature) * 10D;
return Math.cbrt(volume / (4/3 * Math.PI)) * 2;
}
@SideOnly(Side.CLIENT)
@Override
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList stabilizerList = new NBTTagList();
for (TileLocation offset : stabilizerLocations){
NBTTagCompound compound1 = new NBTTagCompound();
offset.writeToNBT(compound1, "tag");
stabilizerList.appendTag(compound1);
}
if (stabilizerList.tagCount() > 0) compound.setTag("Stabilizers", stabilizerList);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound compound = pkt.func_148857_g();
stabilizerLocations = new ArrayList<TileLocation>();
if (compound.hasKey("Stabilizers")){
NBTTagList stabilizerList = compound.getTagList("Stabilizers", 10);
for (int i = 0; i < stabilizerList.tagCount(); i++){
TileLocation offset = new TileLocation();
offset.readFromNBT(stabilizerList.getCompoundTagAt(i), "tag");
stabilizerLocations.add(offset);
}
}
super.onDataPacket(net, pkt);
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
NBTTagList stabilizerList = new NBTTagList();
for (TileLocation offset : stabilizerLocations){
NBTTagCompound compound1 = new NBTTagCompound();
offset.writeToNBT(compound1, "tag");
stabilizerList.appendTag(compound1);
}
if (stabilizerList.tagCount() > 0) compound.setTag("Stabilizers", stabilizerList);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
stabilizerLocations = new ArrayList<TileLocation>();
if (compound.hasKey("Stabilizers")){
NBTTagList stabilizerList = compound.getTagList("Stabilizers", 10);
for (int i = 0; i < stabilizerList.tagCount(); i++){
TileLocation offset = new TileLocation();
offset.readFromNBT(stabilizerList.getCompoundTagAt(i), "tag");
stabilizerLocations.add(offset);
}
}
}
}
@@ -0,0 +1,150 @@
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor;
import cofh.api.energy.IEnergyReceiver;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Created by Brandon on 23/7/2015.
*/
public class TileReactorEnergyInjector extends TileEntity implements IIsSlave, IEnergyReceiver{
public float modelIllumination = 1F;
public int facingDirection = ForgeDirection.UP.ordinal();
public MultiblockHelper.TileLocation masterLocation = new MultiblockHelper.TileLocation();
public boolean isValid = false;
public int tick = 0;
private ParticleReactorBeam beam = null;
private TileReactorCore core = null;
@Override
public void updateEntity() {
if (worldObj.isRemote && isValid){
beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
}
}
public void onPlaced() {
checkForMaster();
}
public boolean checkForMaster(){
for (int i = 1; i < 10; i++) {
ForgeDirection dir = ForgeDirection.getOrientation(facingDirection);
int x = xCoord + (dir.offsetX*i);
int y = yCoord + (dir.offsetY*i);
int z = zCoord + (dir.offsetZ*i);
if (!worldObj.isAirBlock(x, y, z))
{
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile instanceof TileReactorCore)
{
masterLocation.set(x, y, z);
isValid = true;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return true;
}else {
isValid = false;
return false;
}
}
}
isValid = false;
return false;
}
@Override
public boolean isActive() {
return isValid;
}
@Override
public void shutDown() {
masterLocation = new MultiblockHelper.TileLocation();
isValid = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
masterLocation.writeToNBT(compound, "Master");
compound.setInteger("Facing", facingDirection);
compound.setBoolean("IsValid", isValid);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound compound = pkt.func_148857_g();
masterLocation.readFromNBT(compound, "Master");
facingDirection = compound.getInteger("Facing");
isValid = compound.getBoolean("IsValid");
super.onDataPacket(net, pkt);
}
public TileReactorCore getCore(){
if (core == null || core.isInvalid()) {
if (getMaster().getTileEntity(worldObj) instanceof TileReactorCore) core = (TileReactorCore)getMaster().getTileEntity(worldObj);
else core = null;
}
return core;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
masterLocation.writeToNBT(compound, "Master");
compound.setInteger("Facing", facingDirection);
compound.setBoolean("IsValid", isValid);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
masterLocation.readFromNBT(compound, "Master");
facingDirection = compound.getInteger("Facing");
isValid = compound.getBoolean("IsValid");
}
@Override
public MultiblockHelper.TileLocation getMaster() {
return masterLocation;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
if (simulate) return Integer.MAX_VALUE;
else if (getCore() != null) return getCore().injectEnergy(maxReceive);
return 0;
}
@Override
public int getEnergyStored(ForgeDirection from) {
return 0;
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return Integer.MAX_VALUE;
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return from == ForgeDirection.getOrientation(facingDirection).getOpposite();
}
}
@@ -1,5 +1,9 @@
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor;
import cofh.api.energy.IEnergyProvider;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
@@ -9,9 +13,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Created by Brandon on 5/7/2015.
* Created by brandon3055 on 5/7/2015.
*/
public class TileReactorStabilizer extends TileEntity {
public class TileReactorStabilizer extends TileEntity implements IIsSlave , IEnergyProvider{
public float coreRotation = 0F;
public float ringRotation = 0F;
@@ -22,6 +26,7 @@ public class TileReactorStabilizer extends TileEntity {
public TileLocation masterLocation = new TileLocation();
public boolean isValid = false;
public int tick = 0;
private ParticleReactorBeam beam = null;
@Override
public void updateEntity() {
@@ -33,6 +38,7 @@ public class TileReactorStabilizer extends TileEntity {
coreSpeed = 30F;
ringSpeed = 5F;
modelIllumination = 1F;
if (isValid) beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
}
}
@@ -41,23 +47,48 @@ public class TileReactorStabilizer extends TileEntity {
checkForMaster();
}
public void onBroken() {
}
public boolean checkForMaster(){
for (int i = 1; i < 10; i++) {
ForgeDirection dir = ForgeDirection.getOrientation(facingDirection);
int x = xCoord + (dir.offsetX*i);
int y = yCoord + (dir.offsetY*i);
int z = zCoord + (dir.offsetZ*i);
if (worldObj.getTileEntity(x, y, z) instanceof TileReactorCore){
masterLocation.set(x, y, z);
isValid = true;
worldObj.markBlockForUpdate(x, y, z);
return true;
if (!worldObj.isAirBlock(x, y, z))
{
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile instanceof TileReactorCore && ((TileReactorCore) tile).stabilizerLocations.size() < 4) //todo add check reactor side to make sure this aligns with other stabilizers
{
((TileReactorCore) tile).stabilizerLocations.add(new TileLocation(xCoord, yCoord, zCoord));
masterLocation.set(x, y, z);
isValid = true;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return true;
}else {
isValid = false;
return false;
}
}
}
isValid = false;
return false;
}
@Override
public boolean isActive() {
return isValid;
}
@Override
public void shutDown(){
isValid = false;
masterLocation = new TileLocation();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
@@ -91,4 +122,35 @@ public class TileReactorStabilizer extends TileEntity {
facingDirection = compound.getInteger("Facing");
isValid = compound.getBoolean("IsValid");
}
@Override
public TileLocation getMaster() {
return masterLocation;
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return 0;
}
@Override
public int getEnergyStored(ForgeDirection from) {
return 0;
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return 0;
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return from == ForgeDirection.getOrientation(facingDirection).getOpposite();
}
// @SideOnly(Side.CLIENT)
// @Override
// public AxisAlignedBB getRenderBoundingBox() {
// return INFINITE_EXTENT_AABB;
// }
}