Revert "Rewrite to use new RebornCore Power API. Texture fixes."

This reverts commit b292fdd352.

# Conflicts:
#	src/main/java/techreborn/client/gui/GuiImplosionCompressor.java
#	src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java
#	src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java
#	src/main/java/techreborn/client/gui/GuiVacuumFreezer.java
#	src/main/java/techreborn/tiles/TileAlloyFurnace.java
#	src/main/java/techreborn/tiles/TileAlloySmelter.java
#	src/main/java/techreborn/tiles/TileAssemblingMachine.java
#	src/main/java/techreborn/tiles/TileImplosionCompressor.java
#	src/main/java/techreborn/tiles/TileIndustrialSawmill.java
#	src/main/java/techreborn/tiles/TileVacuumFreezer.java
#	src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java
#	src/main/java/techreborn/tiles/multiblock/TileIndustrialGrinder.java
#	src/main/java/techreborn/tiles/teir1/TileCompressor.java
#	src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java
#	src/main/java/techreborn/tiles/teir1/TileExtractor.java
#	src/main/java/techreborn/tiles/teir1/TileGrinder.java
#	src/main/java/techreborn/tiles/teir1/TileRecycler.java
This commit is contained in:
modmuss50 2016-08-10 00:45:07 +01:00
parent 9b882e75ce
commit cdae866b2d
87 changed files with 3721 additions and 1277 deletions

View file

@ -43,16 +43,16 @@ public class StackToolTipEvent
color = TextFormatting.YELLOW; color = TextFormatting.YELLOW;
} }
event.getToolTip().add(color + "" event.getToolTip().add(color + ""
+ PowerSystem.getLocalizedPower( + PowerSystem.getLocaliszedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getEnergy(event.getItemStack())) (int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getEnergy(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " stored"); + TextFormatting.LIGHT_PURPLE + " stored");
event.getToolTip().add(Color.GREEN + "" event.getToolTip().add(Color.GREEN + ""
+ PowerSystem.getLocalizedPower( + PowerSystem.getLocaliszedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxPower(event.getItemStack())) (int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxPower(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " max"); + TextFormatting.LIGHT_PURPLE + " max");
event.getToolTip() event.getToolTip()
.add(TextFormatting.GREEN + "" + percentage + "%" + TextFormatting.LIGHT_PURPLE + " charged"); .add(TextFormatting.GREEN + "" + percentage + "%" + TextFormatting.LIGHT_PURPLE + " charged");
event.getToolTip().add(Color.GREEN + "" + PowerSystem.getLocalizedPower( event.getToolTip().add(Color.GREEN + "" + PowerSystem.getLocaliszedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxTransfer(event.getItemStack())) (int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxTransfer(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " /tick in/out"); + TextFormatting.LIGHT_PURPLE + " /tick in/out");
} }

View file

@ -14,7 +14,7 @@ public class ContainerIndustrialGrinder extends ContainerCrafting {
TileIndustrialGrinder tile; TileIndustrialGrinder tile;
public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player) { public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player) {
super(tileGrinder.crafter); super(tileGrinder.getRecipeCrafter());
tile = tileGrinder; tile = tileGrinder;
this.player = player; this.player = player;

View file

@ -60,11 +60,11 @@ public class GuiAESU extends GuiContainer
{ {
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.aesu.name"), 40, 10, this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.aesu.name"), 40, 10,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.euOut) + " /tick", 10, 20, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerAesu.euOut) + " /tick", 10, 20,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.storedEu) + " ", 10, 30, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerAesu.storedEu) + " ", 10, 30,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.euChange) + " change", 10, 40, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerAesu.euChange) + " change", 10, 40,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
} }

View file

@ -42,13 +42,15 @@ public class GuiAlloySmelter extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = alloysmelter.getProgressScaled(24); int j = 0;
if (j > 0) {
j = alloysmelter.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
} }
j = alloysmelter.getEnergyScaled(12);
j = (int)(alloysmelter.getEnergy() * 24f / alloysmelter.getMaxPower());
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -45,12 +45,15 @@ public class GuiAssemblingMachine extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = assemblingmachine.getProgressScaled(20); int j = 0;
if (j > 0) {
j = assemblingmachine.getProgressScaled(20);
if (j > 0)
{
this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16);
} }
j = (int)(assemblingmachine.getEnergy() * 12f / assemblingmachine.getMaxPower()); j = assemblingmachine.getEnergyScaled(12);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -42,7 +42,9 @@ public class GuiBatbox extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower()); int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16); this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
@ -64,9 +66,9 @@ public class GuiBatbox extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 25, this.ySize - 140, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 25, this.ySize - 140,
4210752); 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752); 4210752);
} }
} }

View file

@ -78,15 +78,17 @@ public class GuiBlastFurnace extends GuiContainer
l + 52 + 12 - 0, -1); l + 52 + 12 - 0, -1);
} }
int j = 0;
this.mc.getTextureManager().bindTexture(texture); this.mc.getTextureManager().bindTexture(texture);
int j = blastfurnace.getProgressScaled(24); j = blastfurnace.getProgressScaled(24);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16);
} }
j = (int)(blastfurnace.getEnergy() * 12f / blastfurnace.getMaxPower()); j = blastfurnace.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 9, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 9, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }

View file

@ -43,7 +43,9 @@ public class GuiCentrifuge extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = centrifuge.getProgressScaled(11); int j = 0;
j = centrifuge.getProgressScaled(11);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j); this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j);
@ -52,8 +54,10 @@ public class GuiCentrifuge extends GuiContainer
this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10); this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10);
} }
j = (int)(centrifuge.getEnergy() * 12f / centrifuge.getMaxPower()); j = centrifuge.getEnergyScaled(12);
if (j > 0) {
if (j > 0)
{
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }

View file

@ -42,8 +42,9 @@ public class GuiChargeBench extends GuiContainer
int j = 0; int j = 0;
j = (int)(chargebench.getEnergy() * 12f / chargebench.getMaxPower()); j = chargebench.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 10, l + 32 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 10, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }

View file

@ -51,8 +51,9 @@ public class GuiChemicalReactor extends GuiContainer
this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j); this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j);
} }
j = (int)(chemicalReactor.getEnergy() * 12f / chemicalReactor.getMaxPower()); j = chemicalReactor.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
} }

View file

@ -34,16 +34,19 @@ public class GuiCompressor extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = compressor.getProgressScaled(24); int j = 0;
if (j > 0) {
j = compressor.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
j = (int)(compressor.getEnergy() * 12f / compressor.getMaxPower()); j = compressor.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)

View file

@ -49,7 +49,7 @@ public class GuiDieselGenerator extends GuiContainer
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 16448255); this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 16448255);
this.fontRendererObj.drawString("Power Amount", 10, 40, 16448255); this.fontRendererObj.drawString("Power Amount", 10, 40, 16448255);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerDieselGenerator.energy) + "", 10, 50, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerDieselGenerator.energy) + "", 10, 50,
16448255); 16448255);
} }
} }

View file

@ -34,16 +34,19 @@ public class GuiElectricFurnace extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = furnace.gaugeProgressScaled(24); int j = 0;
if (j > 0) {
j = furnace.gaugeProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16);
} }
j = (int)(furnace.getEnergy() * 12f / furnace.getMaxPower()); j = furnace.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)

View file

@ -35,13 +35,17 @@ public class GuiExtractor extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = extractor.getProgressScaled(24); int j = 0;
if (j > 0) {
j = extractor.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
j = (int)(extractor.getEnergy() * 12f / extractor.getMaxPower()); j = extractor.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }

View file

@ -35,7 +35,7 @@ public class GuiFusionReactor extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerFusionReactor.energy), 11, 8, 16448255); this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerFusionReactor.energy), 11, 8, 16448255);
this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.coilStatus == 1 ? "Yes" : "No"), 11, 16, this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.coilStatus == 1 ? "Yes" : "No"), 11, 16,
16448255); 16448255);
if (containerFusionReactor.neededEU > 1 && containerFusionReactor.tickTime < 1) if (containerFusionReactor.neededEU > 1 && containerFusionReactor.tickTime < 1)

View file

@ -42,8 +42,11 @@ public class GuiGenerator extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower()); int j = 0;
if (j > 0) {
j = generator.getEnergyScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16); this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
} }
@ -62,7 +65,7 @@ public class GuiGenerator extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752); 4210752);
} }
} }

View file

@ -43,8 +43,9 @@ public class GuiGrinder extends GuiContainer
this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16);
} }
j = (int)(grinder.getEnergy() * 12f / grinder.getMaxPower()); j = grinder.getEnergyScaled(12);
if (j > 0) { if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }

View file

@ -85,11 +85,11 @@ public class GuiIDSU extends GuiContainer
{ {
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.idsu.name"), 75, 10, this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.idsu.name"), 75, 10,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.euOut) + "/tick", 10, 22, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euOut) + "/tick", 10, 22,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.storedEu), 10, 32, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.storedEu), 10, 32,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.euChange) + " change", 10, 42, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euChange) + " change", 10, 42,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
} }

View file

@ -50,11 +50,12 @@ public class GuiImplosionCompressor extends GuiContainer {
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
} }
j = (int) (compresser.getEnergy() * 12f / compresser.getMaxPower()); j = compresser.getEnergyScaled(12);
if (j > 0) { if (j > 0)
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); {
} this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.name"); String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.name");

View file

@ -52,7 +52,7 @@ public class GuiIndustrialElectrolyzer extends GuiContainer
this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16);
} }
j = (int)(eletrolyzer.getEnergy() * 12f / eletrolyzer.getMaxPower()); j = eletrolyzer.getEnergyScaled(12);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 134, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 134, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -93,4 +93,5 @@ public class GuiIndustrialGrinder extends GuiContainer {
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
} }
} }

View file

@ -54,8 +54,15 @@ public class GuiIndustrialSawmill extends GuiContainer
if(!sawmill.tank.isEmpty()) { if(!sawmill.tank.isEmpty()) {
drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity()); drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity());
<<<<<<< HEAD
mc.renderEngine.bindTexture(texture); mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37); drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37);
=======
j = sawmill.getEnergyScaled(12);
if (j > 0)
{
this.drawTexturedModalRect(k + 33, l + 65 + 12 - j, 176, 12 - j, 14, j + 2);
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
} }
if (!sawmill.getMutliBlock()) { if (!sawmill.getMutliBlock()) {

View file

@ -43,14 +43,14 @@ public class GuiLESU extends GuiContainer
{ {
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.lesu.name"), 40, 10, this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.lesu.name"), 40, 10,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euOut) + "/t", 10, 20, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerLesu.euOut) + "/t", 10, 20,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.storedEu), 10, 30, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerLesu.storedEu), 10, 30,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euChange) + " change", 10, 40, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerLesu.euChange) + " change", 10, 40,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
this.fontRendererObj.drawString(containerLesu.connectedBlocks + " blocks", 10, 50, Color.WHITE.getRGB()); this.fontRendererObj.drawString(containerLesu.connectedBlocks + " blocks", 10, 50, Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euStorage) + " max", 10, 60, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerLesu.euStorage) + " max", 10, 60,
Color.WHITE.getRGB()); Color.WHITE.getRGB());
} }

View file

@ -45,8 +45,11 @@ public class GuiMFE extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower()); int j = 0;
if (j > 0) {
j = generator.getEnergyScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16); this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
} }
// //
@ -66,9 +69,9 @@ public class GuiMFE extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150,
4210752); 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752); 4210752);
} }
} }

View file

@ -45,8 +45,11 @@ public class GuiMFSU extends GuiContainer
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower()); int j = 0;
if (j > 0) {
j = generator.getEnergyScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16); this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
} }
// //
@ -66,9 +69,9 @@ public class GuiMFSU extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150,
4210752); 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160, this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752); 4210752);
} }
} }

View file

@ -42,7 +42,7 @@ public class GuiRecycler extends GuiContainer
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
j = (int)(compressor.getEnergy() * 12f / compressor.getMaxPower()); j = compressor.getEnergyScaled(12);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -38,7 +38,7 @@ public class GuiRollingMachine extends GuiContainer
int j = this.containerRollingMachine.getBurnTimeRemainingScaled(24); int j = this.containerRollingMachine.getBurnTimeRemainingScaled(24);
this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19); this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19);
j = (int)(rollingMachine.getEnergy() * 12f / rollingMachine.getMaxPower()); j = this.rollingMachine.getEnergyScaled(12);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 7, l + 33 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 7, l + 33 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -44,7 +44,7 @@ public class GuiScrapboxinator extends GuiContainer
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
j = (int)(tile.getEnergy() * 12f / tile.getMaxPower()); j = tile.getEnergyScaled(12);
if (j > 0) if (j > 0)
{ {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -43,7 +43,15 @@ public class GuiVacuumFreezer extends GuiContainer {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
} }
<<<<<<< HEAD
} }
=======
j = crafter.getEnergyScaled(12);
if (j > 0)
{
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name"); String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");

View file

@ -55,7 +55,8 @@ public class ItemBlockAesu extends ItemBlock
} }
if (stack != null && stack.hasTagCompound()) if (stack != null && stack.hasTagCompound())
{ {
//TODO ((TileAesu) world.getTileEntity(pos)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); ((TileAesu) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
} }
return true; return true;
} }

View file

@ -34,8 +34,6 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties; import net.minecraftforge.common.property.Properties;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile; import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyProducerTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
import reborncore.common.misc.Functions; import reborncore.common.misc.Functions;
import reborncore.common.misc.vecmath.Vecs3dCube; import reborncore.common.misc.vecmath.Vecs3dCube;
@ -213,11 +211,8 @@ public class CableMultipart extends Multipart
TileEntity tile = getNeighbourTile(dir); TileEntity tile = getNeighbourTile(dir);
if(tile != null) { if(tile != null) {
EnumFacing facing = dir.getOpposite(); EnumFacing facing = dir.getOpposite();
if (tile instanceof IEnergyReceiverTile && if (tile instanceof IEnergyInterfaceTile &&
((IEnergyReceiverTile) tile).canAcceptEnergy(facing)) { ((IEnergyInterfaceTile) tile).canAcceptEnergy(facing)) {
return true;
} else if(tile instanceof IEnergyProducerTile &&
((IEnergyProducerTile) tile).canProvideEnergy(facing)) {
return true; return true;
} else if (tile instanceof IEnergyReceiver && } else if (tile instanceof IEnergyReceiver &&
((IEnergyReceiver) tile).canConnectEnergy(facing) && ((IEnergyReceiver) tile).canConnectEnergy(facing) &&

View file

@ -11,7 +11,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile; import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.mcmultipart.block.TileMultipartContainer; import reborncore.mcmultipart.block.TileMultipartContainer;
@ -27,6 +26,25 @@ import java.util.function.BiFunction;
public class EnergyUtils { public class EnergyUtils {
/**
* Dispatches energy to available neighbours
* @param world world
* @param source source position
* @param tile controller
* @param amount amount of energy
* @return amount of energy dispatched
*/
public static double dispatchEnergyToNeighbours(World world, BlockPos source, IEnergyInterfaceTile tile, double amount) {
double energyLeft = amount;
for(EnumFacing facing : EnumFacing.VALUES) {
if(tile.canProvideEnergy(facing)) {
PowerNetReceiver receiver = getReceiver(world, facing.getOpposite(), source.offset(facing));
if(receiver != null) energyLeft -= receiver.receiveEnergy(energyLeft, false);
if(energyLeft == 0) return energyLeft;
}
}
return amount - energyLeft;
}
/** /**
* Same as {@link #dispatchWiresEnergyPacketRecursively(World, ArrayList, BlockPos, boolean, double)} * Same as {@link #dispatchWiresEnergyPacketRecursively(World, ArrayList, BlockPos, boolean, double)}
@ -156,8 +174,8 @@ public class EnergyUtils {
} }
public static PowerNetReceiver getInternalReceiver(TileEntity tileEntity, EnumFacing side) { public static PowerNetReceiver getInternalReceiver(TileEntity tileEntity, EnumFacing side) {
if(tileEntity instanceof IEnergyReceiverTile) { if(tileEntity instanceof IEnergyInterfaceTile) {
IEnergyReceiverTile energyInterface = (IEnergyReceiverTile) tileEntity; IEnergyInterfaceTile energyInterface = (IEnergyInterfaceTile) tileEntity;
return new PowerNetReceiver( return new PowerNetReceiver(
(energy, simulated) -> { (energy, simulated) -> {
if(energyInterface.canAcceptEnergy(side)) if(energyInterface.canAcceptEnergy(side))

View file

@ -1,6 +1,5 @@
package techreborn.tiles; package techreborn.tiles;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -8,13 +7,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable { public class TileAesu extends TilePowerAcceptor implements IWrenchable
{
public static final int MAX_OUTPUT = ConfigTechReborn.AesuMaxOutput; public static final int MAX_OUTPUT = ConfigTechReborn.AesuMaxOutput;
public static final int MAX_STORAGE = ConfigTechReborn.AesuMaxStorage; public static final int MAX_STORAGE = ConfigTechReborn.AesuMaxStorage;
@ -24,116 +22,117 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
private double euChange; private double euChange;
private int ticks; private int ticks;
public TileAesu()
{
super(5);
}
@Override @Override
public void update() { public void updateEntity()
super.update(); {
if (ticks == ConfigTechReborn.AverageEuOutTickTime) { super.updateEntity();
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
{
euChange = -1; euChange = -1;
ticks = 0; ticks = 0;
} else { } else
{
ticks++; ticks++;
euChange += getEnergy() - euLastTick; euChange += getEnergy() - euLastTick;
if (euLastTick == getEnergy()) { if (euLastTick == getEnergy())
{
euChange = 0; euChange = 0;
} }
} }
euLastTick = getEnergy(); euLastTick = getEnergy();
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
} }
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return true; return true;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return getDropWithNBT(); return getDropWithNBT();
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
public void handleGuiInputFromClient(int id) { public void handleGuiInputFromClient(int id)
if (id == 0) { {
if (id == 0)
{
OUTPUT += 256; OUTPUT += 256;
} }
if (id == 1) { if (id == 1)
{
OUTPUT += 64; OUTPUT += 64;
} }
if (id == 2) { if (id == 2)
{
OUTPUT -= 64; OUTPUT -= 64;
} }
if (id == 3) { if (id == 3)
{
OUTPUT -= 256; OUTPUT -= 256;
} }
if (OUTPUT > MAX_OUTPUT) { if (OUTPUT > MAX_OUTPUT)
{
OUTPUT = MAX_OUTPUT; OUTPUT = MAX_OUTPUT;
} }
if (OUTPUT <= -1) { if (OUTPUT <= -1)
{
OUTPUT = 0; OUTPUT = 0;
} }
} }
public double getEuChange() { public double getEuChange()
if (euChange == -1) { {
if (euChange == -1)
{
return -1; return -1;
} }
return (euChange / ticks); return (euChange / ticks);
} }
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT()
{
NBTTagCompound tileEntity = new NBTTagCompound(); NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(ModBlocks.Aesu, 1); ItemStack dropStack = new ItemStack(ModBlocks.Aesu, 1);
writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound()); dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity); dropStack.getTagCompound().setTag("tileEntity", tileEntity);
return dropStack; return dropStack;
} }
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tagCompound.setDouble("euChange", euChange); tagCompound.setDouble("euChange", euChange);
tagCompound.setDouble("euLastTick", euLastTick); tagCompound.setDouble("euLastTick", euLastTick);
@ -142,7 +141,8 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
return tagCompound; return tagCompound;
} }
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbttagcompound)
{
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
this.euChange = nbttagcompound.getDouble("euChange"); this.euChange = nbttagcompound.getDouble("euChange");
this.euLastTick = nbttagcompound.getDouble("euLastTick"); this.euLastTick = nbttagcompound.getDouble("euLastTick");
@ -151,18 +151,38 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return TileAesu.MAX_STORAGE; return TileAesu.MAX_STORAGE;
} }
@Override @Override
public double getMaxOutput() { public boolean canAcceptEnergy(EnumFacing direction)
{
return getFacingEnum() != direction;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return getFacingEnum() == direction;
}
@Override
public double getMaxOutput()
{
return OUTPUT; return OUTPUT;
} }
@Override @Override
public EnumPowerTier getTier() { public double getMaxInput()
return EnumPowerTier.INSANE; {
return 4096 * 2;
} }
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
}
} }

View file

@ -18,7 +18,8 @@ import reborncore.common.util.ItemUtils;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider { public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider
{
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this); public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this);
@ -30,7 +31,8 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
int output = 2; int output = 2;
int fuel = 3; int fuel = 3;
public TileAlloyFurnace() { public TileAlloyFurnace()
{
} }
@ -38,24 +40,31 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
* Returns the number of ticks that the supplied fuel item will keep the * Returns the number of ticks that the supplied fuel item will keep the
* furnace burning, or 0 if the item isn't fuel * furnace burning, or 0 if the item isn't fuel
*/ */
public static int getItemBurnTime(ItemStack stack) { public static int getItemBurnTime(ItemStack stack)
if (stack == null) { {
if (stack == null)
{
return 0; return 0;
} else { } else
{
Item item = stack.getItem(); Item item = stack.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
{
Block block = Block.getBlockFromItem(item); Block block = Block.getBlockFromItem(item);
if (block == Blocks.WOODEN_SLAB) { if (block == Blocks.WOODEN_SLAB)
{
return 150; return 150;
} }
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) { if (block.getMaterial(block.getDefaultState()) == Material.WOOD)
{
return 300; return 300;
} }
if (block == Blocks.COAL_BLOCK) { if (block == Blocks.COAL_BLOCK)
{
return 16000; return 16000;
} }
} }
@ -81,54 +90,71 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
boolean flag = this.burnTime > 0; boolean flag = this.burnTime > 0;
boolean flag1 = false; boolean flag1 = false;
if (this.burnTime > 0) { if (this.burnTime > 0)
{
--this.burnTime; --this.burnTime;
} }
if (!this.worldObj.isRemote) { if (!this.worldObj.isRemote)
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null) { {
if (this.burnTime == 0 && this.canSmelt()) { if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null)
{
if (this.burnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel)); this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel));
if (this.burnTime > 0) { if (this.burnTime > 0)
{
flag1 = true; flag1 = true;
if (this.getStackInSlot(fuel) != null) { if (this.getStackInSlot(fuel) != null)
{
decrStackSize(fuel, 1); decrStackSize(fuel, 1);
} }
} }
} }
if (this.isBurning() && this.canSmelt()) { if (this.isBurning() && this.canSmelt())
{
++this.cookTime; ++this.cookTime;
if (this.cookTime == 200) { if (this.cookTime == 200)
{
this.cookTime = 0; this.cookTime = 0;
this.smeltItem(); this.smeltItem();
flag1 = true; flag1 = true;
} }
} else { } else
{
this.cookTime = 0; this.cookTime = 0;
} }
} }
if (flag != this.burnTime > 0) { if (flag != this.burnTime > 0)
{
flag1 = true; flag1 = true;
// TODO sync on/off // TODO sync on/off
} }
} }
if (flag1) { if (flag1)
{
this.markDirty(); this.markDirty();
} }
} }
public boolean hasAllInputs(IBaseRecipeType recipeType) { public boolean hasAllInputs(IBaseRecipeType recipeType)
if (recipeType == null) { {
if (recipeType == null)
{
return false; return false;
} }
for (ItemStack input : recipeType.getInputs()) { for (ItemStack input : recipeType.getInputs())
{
Boolean hasItem = false; Boolean hasItem = false;
for (int inputslot = 0; inputslot < 2; inputslot++) { for (int inputslot = 0; inputslot < 2; inputslot++)
{
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) { recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize)
{
hasItem = true; hasItem = true;
} }
} }
@ -138,13 +164,18 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
return true; return true;
} }
private boolean canSmelt() { private boolean canSmelt()
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null) { {
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null)
{
return false; return false;
} else { } else
{
ItemStack itemstack = null; ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
if (hasAllInputs(recipeType)) { {
if (hasAllInputs(recipeType))
{
itemstack = recipeType.getOutput(0); itemstack = recipeType.getOutput(0);
break; break;
} }
@ -158,13 +189,13 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
return false; return false;
int result = getStackInSlot(output).stackSize + itemstack.stackSize; int result = getStackInSlot(output).stackSize + itemstack.stackSize;
return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge
// BugFix: // BugFix:
// Make // Make
// it // it
// respect // respect
// stack // stack
// sizes // sizes
// properly. // properly.
} }
} }
@ -172,37 +203,51 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
* Turn one item from the furnace source stack into the appropriate smelted * Turn one item from the furnace source stack into the appropriate smelted
* item in the furnace result stack * item in the furnace result stack
*/ */
public void smeltItem() { public void smeltItem()
if (this.canSmelt()) { {
if (this.canSmelt())
{
ItemStack itemstack = null; ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
if (hasAllInputs(recipeType)) { {
if (hasAllInputs(recipeType))
{
itemstack = recipeType.getOutput(0); itemstack = recipeType.getOutput(0);
break; break;
} }
if (itemstack != null) { if (itemstack != null)
{
break; break;
} }
} }
if (this.getStackInSlot(output) == null) { if (this.getStackInSlot(output) == null)
{
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) { } else if (this.getStackInSlot(output).getItem() == itemstack.getItem())
{
decrStackSize(output, -itemstack.stackSize); decrStackSize(output, -itemstack.stackSize);
} }
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
{
boolean hasAllRecipes = true; boolean hasAllRecipes = true;
if (hasAllInputs(recipeType)) { if (hasAllInputs(recipeType))
{
} else { } else
hasAllRecipes = false; {
} hasAllRecipes = false;
if (hasAllRecipes) { }
for (ItemStack input : recipeType.getInputs()) { if (hasAllRecipes)
for (int inputSlot = 0; inputSlot < 2; inputSlot++) { {
for (ItemStack input : recipeType.getInputs())
{
for (int inputSlot = 0; inputSlot < 2; inputSlot++)
{
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) { recipeType.useOreDic()))
{
inventory.decrStackSize(inputSlot, input.stackSize); inventory.decrStackSize(inputSlot, input.stackSize);
break; break;
} }
@ -217,48 +262,58 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
/** /**
* Furnace isBurning * Furnace isBurning
*/ */
public boolean isBurning() { public boolean isBurning()
{
return this.burnTime > 0; return this.burnTime > 0;
} }
public int getBurnTimeRemainingScaled(int scale) { public int getBurnTimeRemainingScaled(int scale)
if (this.currentItemBurnTime == 0) { {
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200; this.currentItemBurnTime = 200;
} }
return this.burnTime * scale / this.currentItemBurnTime; return this.burnTime * scale / this.currentItemBurnTime;
} }
public int getCookProgressScaled(int scale) { public int getCookProgressScaled(int scale)
{
return this.cookTime * scale / 200; return this.cookTime * scale / 200;
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloyFurnace, 1); return new ItemStack(ModBlocks.AlloyFurnace, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@ -266,6 +321,7 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
<<<<<<< HEAD
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side) {
@ -282,4 +338,6 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
return index == 2; return index == 2;
} }
=======
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
} }

View file

@ -9,21 +9,25 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler; import techreborn.utils.upgrade.UpgradeHandler;
public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider { public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
{
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this); public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public int capacity = 1000;
UpgradeHandler upgrades; UpgradeHandler upgrades;
public TileAlloySmelter() { public TileAlloySmelter()
{
super(1);
// Input slots // Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -35,51 +39,65 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
} }
@Override @Override
<<<<<<< HEAD
public void update() { public void update() {
super.update(); super.update();
=======
public void updateEntity()
{
super.updateEntity();
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
crafter.updateEntity(); crafter.updateEntity();
upgrades.tick(); upgrades.tick();
//charge(3); TODO charge(3);
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloySmelter, 1); return new ItemStack(ModBlocks.AlloySmelter, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
@ -95,6 +113,7 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
// } // }
// } // }
<<<<<<< HEAD
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side) {
return new int[] {0, 1, 2}; return new int[] {0, 1, 2};
@ -109,21 +128,71 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
return index == 2; return index == 2;
} }
=======
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
}
public int getProgressScaled(int scale) { @Override
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex == 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2;
}
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 8000; {
return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }

View file

@ -10,20 +10,23 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider; import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer; import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.client.container.ContainerAssemblingMachine; import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, ISidedInventory,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, ISidedInventory,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider
{
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this); public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileAssemblingMachine() { public TileAssemblingMachine()
{
super(2);
// Input slots // Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -34,52 +37,101 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
crafter.updateEntity(); super.updateEntity();
// charge(3); charge(3);
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AssemblyMachine, 1); return new ItemStack(ModBlocks.AssemblyMachine, 1);
} }
public int getProgressScaled(int scale) {
if (crafter.currentTickTime != 0) { public boolean isComplete()
{
return false;
}
// @Override
// public void addWailaInfo(List<String> info)
// {
// super.addWailaInfo(info);
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
// if(crafter.currentRecipe !=null){
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
// }
// }
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.MEDIUM; {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
} }
@Override @Override

View file

@ -13,8 +13,8 @@ import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer; import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.PoweredItem; import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.client.container.ContainerCentrifuge; import techreborn.client.container.ContainerCentrifuge;
@ -23,7 +23,9 @@ import techreborn.init.ModBlocks;
import java.util.List; import java.util.List;
public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider { public class TileCentrifuge extends TilePowerAcceptor
implements IWrenchable,IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider
{
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this); public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this);
@ -31,7 +33,9 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IIn
public int euTick = ConfigTechReborn.CentrifugeInputTick; public int euTick = ConfigTechReborn.CentrifugeInputTick;
public TileCentrifuge() { public TileCentrifuge()
{
super(2);
// Input slots // Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -46,16 +50,20 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IIn
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
// charge(6); TODO charge(6);
if (inventory.getStackInSlot(6) != null) { if (inventory.getStackInSlot(6) != null)
{
ItemStack stack = inventory.getStackInSlot(6); ItemStack stack = inventory.getStackInSlot(6);
if (stack.getItem() instanceof IEnergyItemInfo) { if(stack.getItem() instanceof IEnergyItemInfo){
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem(); IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
if (item.canProvideEnergy(stack)) { if (item.canProvideEnergy(stack))
if (getEnergy() != getMaxPower()) { {
if (getEnergy() != getMaxPower())
{
addEnergy(item.getMaxTransfer(stack)); addEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack); PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
} }
@ -65,68 +73,105 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IIn
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.centrifuge, 1); return new ItemStack(ModBlocks.centrifuge, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile)
{
super.addInfo(info, isRealTile); super.addInfo(info, isRealTile);
info.add("Round and round it goes"); info.add("Round and round it goes");
} }
public int getProgressScaled(int scale) { public int getProgressScaled(int scale)
if (crafter.currentTickTime != 0) { {
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.MEDIUM; {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
} }
@Override @Override

View file

@ -8,23 +8,35 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyInterfaceItem; import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory { public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
{
public Inventory inventory = new Inventory(6, "TileChargeBench", 64, this); public Inventory inventory = new Inventory(6, "TileChargeBench", 64, this);
public int capacity = 100000;
public TileChargeBench()
{
super(4);
}
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++)
if (inventory.getStackInSlot(i) != null) { {
if (getEnergy() > 0) { if (inventory.getStackInSlot(i) != null)
{
if (getEnergy() > 0)
{
ItemStack stack = inventory.getStackInSlot(i); ItemStack stack = inventory.getStackInSlot(i);
if (stack.getItem() instanceof IEnergyInterfaceItem) { if (stack.getItem() instanceof IEnergyInterfaceItem)
{
IEnergyInterfaceItem interfaceItem = (IEnergyInterfaceItem) stack.getItem(); IEnergyInterfaceItem interfaceItem = (IEnergyInterfaceItem) stack.getItem();
double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack), double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack),
Math.min(interfaceItem.getMaxTransfer(stack), getEnergy())); Math.min(interfaceItem.getMaxTransfer(stack), getEnergy()));
@ -37,47 +49,56 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,II
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.chargeBench, 1); return new ItemStack(ModBlocks.chargeBench, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
// ISidedInventory // ISidedInventory
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side)
return side == EnumFacing.DOWN ? new int[]{0, 1, 2, 3, 4, 5} : new int[]{0, 1, 2, 3, 4, 5}; {
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
} }
@Override @Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return isItemValidForSlot(slotIndex, itemStack); return isItemValidForSlot(slotIndex, itemStack);
} }
@Override @Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
// if (itemStack.getItem() instanceof IElectricItem) { // if (itemStack.getItem() instanceof IElectricItem) {
// double CurrentCharge = ElectricItem.manager.getCharge(itemStack); // double CurrentCharge = ElectricItem.manager.getCharge(itemStack);
// double MaxCharge = ((IElectricItem) // double MaxCharge = ((IElectricItem)
@ -89,12 +110,38 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,II
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 512;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM; return EnumPowerTier.MEDIUM;
} }

View file

@ -9,8 +9,8 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -24,6 +24,7 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
public TileChemicalReactor() public TileChemicalReactor()
{ {
super(2);
// Input slots // Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -34,11 +35,11 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
} }
@Override @Override
public void update() public void updateEntity()
{ {
super.update(); super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
//charge(3); TODO charge(3);
} }
@Override @Override
@ -134,7 +135,31 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
@Override @Override
public double getMaxPower() public double getMaxPower()
{ {
return 8000; return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
} }
@Override @Override

View file

@ -6,11 +6,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,IInventoryProvider { public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this); public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this);
@ -19,42 +20,79 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,II
public int euTick = 32; public int euTick = 32;
public TileChunkLoader()
{
super(1);
}
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.ChunkLoader, 1); return new ItemStack(ModBlocks.ChunkLoader, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM; return EnumPowerTier.MEDIUM;
} }

View file

@ -31,9 +31,8 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
public Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this); public Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this);
@Override @Override
public void update() public void updateEntity()
{ {
super.update();
if (!worldObj.isRemote) if (!worldObj.isRemote)
{ {
if (storedItem != null) if (storedItem != null)

View file

@ -0,0 +1,214 @@
package techreborn.tiles;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
{
public int tickTime;
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
public RecipeCrafter crafter;
public TileImplosionCompressor()
{
super(1);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[2];
outputs[0] = 2;
outputs[1] = 3;
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.ImplosionCompressor, 1);
}
public boolean getMutliBlock()
{
for (EnumFacing direction : EnumFacing.values())
{
TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
if (tileEntity instanceof TileMachineCasing)
{
if (!((TileMachineCasing) tileEntity).isConnected())
{
return false;
}
if ((tileEntity.getBlockType() instanceof BlockMachineCasing))
{
int heat;
BlockMachineCasing machineCasing = (BlockMachineCasing) tileEntity.getBlockType();
heat = machineCasing.getHeatFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
location.modifyPositionFromSide(direction, 1);
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava"))
{
heat += 500;
}
return true;
}
}
}
return false;
}
@Override
public void updateEntity()
{
super.updateEntity();
if (getMutliBlock())
{
crafter.updateEntity();
}
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
return tagCompound;
}
// @Override
// public void addWailaInfo(List<String> info)
// {
// super.addWailaInfo(info);
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
// if(crafter.currentRecipe !=null){
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
// }
// }
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex >= 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2 || slotIndex == 3;
}
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
}
return 0;
}
@Override
public double getMaxPower()
{
return 100000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
}
@Override
public Inventory getInventory() {
return inventory;
}
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -9,8 +9,8 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -24,6 +24,7 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
public TileIndustrialElectrolyzer() public TileIndustrialElectrolyzer()
{ {
super(2);
// Input slots // Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -37,11 +38,11 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
} }
@Override @Override
public void update() public void updateEntity()
{ {
super.update(); super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
//charge(6); TODO charge(6);
} }
@Override @Override
@ -137,13 +138,37 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
@Override @Override
public double getMaxPower() public double getMaxPower()
{ {
return 64000; return 1000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
} }
@Override @Override
public EnumPowerTier getTier() public EnumPowerTier getTier()
{ {
return EnumPowerTier.MEDIUM; return EnumPowerTier.LOW;
} }
@Override @Override

View file

@ -0,0 +1,317 @@
package techreborn.tiles;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
public class TileIndustrialSawmill extends TilePowerAcceptor
implements IWrenchable, IFluidHandler,IInventoryProvider, ISidedInventory, IListInfoProvider, ITileRecipeHandler<IndustrialSawmillRecipe>, IRecipeCrafterProvider
{
public static final int TANK_CAPACITY = 16000;
public int tickTime;
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64, this);
public Tank tank = new Tank("TileSawmill", TANK_CAPACITY, this);
public RecipeCrafter crafter;
public TileIndustrialSawmill()
{
super(2);
// TODO configs
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[3];
outputs[0] = 2;
outputs[1] = 3;
outputs[2] = 4;
crafter = new RecipeCrafter(Reference.industrialSawmillRecipe, this, 2, 3, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
if (getMutliBlock())
{
crafter.updateEntity();
}
FluidUtils.drainContainers(this, inventory, 0, 4);
FluidUtils.drainContainers(this, inventory, 1, 4);
}
public boolean getMutliBlock()
{
for (EnumFacing direction : EnumFacing.values())
{
TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
if (tileEntity instanceof TileMachineCasing)
{
if ((tileEntity.getBlockType() instanceof BlockMachineCasing))
{
int heat;
BlockMachineCasing blockMachineCasing = (BlockMachineCasing) tileEntity.getBlockType();
heat = blockMachineCasing
.getHeatFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
location.modifyPositionFromSide(direction, 1);
if (worldObj.getBlockState(location.getBlockPos()).getBlock().getUnlocalizedName()
.equals("tile.lava"))
{
heat += 500;
}
return true;
}
}
}
return false;
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.industrialSawmill, 1);
}
public boolean isComplete()
{
return false;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
return tagCompound;
}
/* IFluidHandler */
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate)
{
int filled = tank.fill(resource, doFill);
tank.compareAndUpdate();
return filled;
}
return 0;
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
{
return null;
}
FluidStack fluidStack = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate();
return fluidStack;
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drained = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate();
return drained;
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid)
{
return fluid == FluidRegistry.WATER;
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid)
{
return false;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[] { tank.getInfo() };
}
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4 } : new int[] { 0, 1, 2, 3, 4 };
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex >= 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4;
}
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
}
return 0;
}
@Override
public double getMaxPower()
{
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
}
@Override
public boolean canCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {
if (recipe.fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid() == recipe.fluidStack) {
if (sawmill.tank.getFluidAmount() >= recipe.fluidStack.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {
if (recipe.fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid() == recipe.fluidStack) {
if (sawmill.tank.getFluidAmount() >= recipe.fluidStack.amount) {
if (sawmill.tank.getFluidAmount() > 0) {
sawmill.tank.setFluid(new FluidStack(recipe.fluidStack.getFluid(),
sawmill.tank.getFluidAmount() - recipe.fluidStack.amount));
} else {
sawmill.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
@Override
public Inventory getInventory() {
return inventory;
}
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -16,7 +16,8 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TileMachineBase; import reborncore.common.tile.TileMachineBase;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
public class TileIronFurnace extends TileMachineBase implements IInventoryProvider { public class TileIronFurnace extends TileMachineBase implements IInventoryProvider
{
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this); public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
@ -29,14 +30,18 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
int fuelslot = 2; int fuelslot = 2;
boolean active = false; boolean active = false;
public int gaugeProgressScaled(int scale) { public int gaugeProgressScaled(int scale)
{
return (progress * scale) / fuelScale; return (progress * scale) / fuelScale;
} }
public int gaugeFuelScaled(int scale) { public int gaugeFuelScaled(int scale)
if (fuelGague == 0) { {
if (fuelGague == 0)
{
fuelGague = fuel; fuelGague = fuel;
if (fuelGague == 0) { if (fuelGague == 0)
{
fuelGague = fuelScale; fuelGague = fuelScale;
} }
} }
@ -44,69 +49,88 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
boolean burning = isBurning(); boolean burning = isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (fuel > 0) { if (fuel > 0)
{
fuel--; fuel--;
updateState(); updateState();
} }
if (fuel <= 0 && canSmelt()) { if (fuel <= 0 && canSmelt())
{
fuel = fuelGague = (int) (TileEntityFurnace.getItemBurnTime(getStackInSlot(fuelslot)) * 1.25); fuel = fuelGague = (int) (TileEntityFurnace.getItemBurnTime(getStackInSlot(fuelslot)) * 1.25);
if (fuel > 0) { if (fuel > 0)
{
if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel
// slot // slot
{ {
setInventorySlotContents(fuelslot, setInventorySlotContents(fuelslot,
new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem())); new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
} else if (getStackInSlot(fuelslot).stackSize > 1) { } else if (getStackInSlot(fuelslot).stackSize > 1)
{
decrStackSize(fuelslot, 1); decrStackSize(fuelslot, 1);
} else if (getStackInSlot(fuelslot).stackSize == 1) { } else if (getStackInSlot(fuelslot).stackSize == 1)
{
setInventorySlotContents(fuelslot, null); setInventorySlotContents(fuelslot, null);
} }
updateInventory = true; updateInventory = true;
} }
} }
if (isBurning() && canSmelt()) { if (isBurning() && canSmelt())
{
progress++; progress++;
if (progress >= fuelScale) { if (progress >= fuelScale)
{
progress = 0; progress = 0;
cookItems(); cookItems();
updateInventory = true; updateInventory = true;
} }
} else { } else
{
progress = 0; progress = 0;
} }
if (burning != isBurning()) { if (burning != isBurning())
{
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory)
{
markDirty(); markDirty();
} }
} }
public void cookItems() { public void cookItems()
if (this.canSmelt()) { {
if (this.canSmelt())
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == null)
{
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack))
{
getStackInSlot(output).stackSize += itemstack.stackSize; getStackInSlot(output).stackSize += itemstack.stackSize;
} }
if (getStackInSlot(input1).stackSize > 1) { if (getStackInSlot(input1).stackSize > 1)
{
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else
{
setInventorySlotContents(input1, null); setInventorySlotContents(input1, null);
} }
} }
} }
public boolean canSmelt() { public boolean canSmelt()
if (getStackInSlot(input1) == null) { {
if (getStackInSlot(input1) == null)
{
return false; return false;
} else { } else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack == null) if (itemstack == null)
return false; return false;
@ -119,21 +143,26 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
} }
} }
public boolean isBurning() { public boolean isBurning()
{
return fuel > 0; return fuel > 0;
} }
public ItemStack getResultFor(ItemStack stack) { public ItemStack getResultFor(ItemStack stack)
{
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != null) { if (result != null)
{
return result.copy(); return result.copy();
} }
return null; return null;
} }
public void updateState() { public void updateState()
{
IBlockState BlockStateContainer = worldObj.getBlockState(pos); IBlockState BlockStateContainer = worldObj.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != fuel > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != fuel > 0)
blockMachineBase.setActive(fuel > 0, worldObj, pos); blockMachineBase.setActive(fuel > 0, worldObj, pos);

View file

@ -5,51 +5,71 @@ import reborncore.common.multiblock.MultiblockValidationException;
import reborncore.common.multiblock.rectangular.RectangularMultiblockTileEntityBase; import reborncore.common.multiblock.rectangular.RectangularMultiblockTileEntityBase;
import techreborn.multiblocks.MultiBlockCasing; import techreborn.multiblocks.MultiBlockCasing;
public class TileMachineCasing extends RectangularMultiblockTileEntityBase { public class TileMachineCasing extends RectangularMultiblockTileEntityBase
{
@Override @Override
public void onMachineActivated() { public void onMachineActivated()
{
} }
@Override @Override
public void onMachineDeactivated() { public void onMachineDeactivated()
{
} }
@Override @Override
public MultiblockControllerBase createNewMultiblock() { public MultiblockControllerBase createNewMultiblock()
{
return new MultiBlockCasing(worldObj); return new MultiBlockCasing(worldObj);
} }
@Override @Override
public Class<? extends MultiblockControllerBase> getMultiblockControllerType() { public Class<? extends MultiblockControllerBase> getMultiblockControllerType()
{
return MultiBlockCasing.class; return MultiBlockCasing.class;
} }
@Override @Override
public void isGoodForFrame() throws MultiblockValidationException { public void isGoodForFrame() throws MultiblockValidationException
{
} }
@Override @Override
public void isGoodForSides() throws MultiblockValidationException { public void isGoodForSides() throws MultiblockValidationException
{
} }
@Override @Override
public void isGoodForTop() throws MultiblockValidationException { public void isGoodForTop() throws MultiblockValidationException
{
} }
@Override @Override
public void isGoodForBottom() throws MultiblockValidationException { public void isGoodForBottom() throws MultiblockValidationException
{
} }
@Override @Override
public void isGoodForInterior() throws MultiblockValidationException { public void isGoodForInterior() throws MultiblockValidationException
{
} }
public MultiBlockCasing getMultiblockController() { public MultiBlockCasing getMultiblockController()
{
return (MultiBlockCasing) super.getMultiblockController(); return (MultiBlockCasing) super.getMultiblockController();
} }
@Override @Override
public void update() {} public void update()
{
}
} }

View file

@ -6,14 +6,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems; import techreborn.init.ModItems;
import techreborn.items.ItemParts; import techreborn.items.ItemParts;
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider { public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public static int fabricationRate = 10000; public static int fabricationRate = 10000;
public int tickTime; public int tickTime;
@ -21,32 +22,44 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
public int progresstime = 0; public int progresstime = 0;
private int amplifier = 0; private int amplifier = 0;
public TileMatterFabricator()
{
super(6);
// TODO configs
}
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.MatterFabricator, 1); return new ItemStack(ModBlocks.MatterFabricator, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@ -71,21 +84,28 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
// return slotIndex == 6; // return slotIndex == 6;
// } // }
public int maxProgresstime() { public int maxProgresstime()
{
return fabricationRate; return fabricationRate;
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
if (!super.worldObj.isRemote) { if (!super.worldObj.isRemote)
for (int i = 0; i < 6; i++) { {
for (int i = 0; i < 6; i++)
{
ItemStack stack = inventory.getStackInSlot(i); ItemStack stack = inventory.getStackInSlot(i);
if (this.amplifier < 10000 && stack != null) { if (this.amplifier < 10000 && stack != null)
{
int amp = (int) ((long) (getValue(stack) / 32)); int amp = (int) ((long) (getValue(stack) / 32));
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) { if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true))
if (canUseEnergy(1)) { {
if (canUseEnergy(1))
{
useEnergy(1); useEnergy(1);
this.amplifier += amp; this.amplifier += amp;
inventory.decrStackSize(i, 1); inventory.decrStackSize(i, 1);
@ -94,18 +114,22 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
} }
} }
if (this.amplifier > 0) { if (this.amplifier > 0)
if (this.amplifier > this.getEnergy()) { {
if (this.amplifier > this.getEnergy())
{
this.progresstime += this.getEnergy(); this.progresstime += this.getEnergy();
this.amplifier -= this.getEnergy(); this.amplifier -= this.getEnergy();
this.decreaseStoredEnergy(this.getEnergy(), true); this.decreaseStoredEnergy(this.getEnergy(), true);
} else { } else
{
this.progresstime += this.amplifier; this.progresstime += this.amplifier;
this.decreaseStoredEnergy(this.amplifier, true); this.decreaseStoredEnergy(this.amplifier, true);
this.amplifier = 0; this.amplifier = 0;
} }
} }
if (this.progresstime > this.maxProgresstime() && this.spaceForOutput()) { if (this.progresstime > this.maxProgresstime() && this.spaceForOutput())
{
this.progresstime -= this.maxProgresstime(); this.progresstime -= this.maxProgresstime();
this.addOutputProducts(); this.addOutputProducts();
} }
@ -114,42 +138,52 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
} }
private boolean spaceForOutput() { private boolean spaceForOutput()
{
return inventory.getStackInSlot(6) == null return inventory.getStackInSlot(6) == null
|| ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true) || ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)
&& inventory.getStackInSlot(6).stackSize < 64; && inventory.getStackInSlot(6).stackSize < 64;
} }
private void addOutputProducts() { private void addOutputProducts()
{
if (inventory.getStackInSlot(6) == null) { if (inventory.getStackInSlot(6) == null)
{
inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter)); inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter));
} else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)) { } else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true))
{
inventory.getStackInSlot(6).stackSize = Math.min(64, 1 + inventory.getStackInSlot(6).stackSize); inventory.getStackInSlot(6).stackSize = Math.min(64, 1 + inventory.getStackInSlot(6).stackSize);
} }
} }
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) { public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy)
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) { {
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy)
{
return false; return false;
} else { } else
{
setEnergy(this.getEnergy() - aEnergy); setEnergy(this.getEnergy() - aEnergy);
if (this.getEnergy() < 0) { if (this.getEnergy() < 0)
{
setEnergy(0); setEnergy(0);
return false; return false;
} else { } else
{
return true; return true;
} }
} }
} }
// TODO ic2 // TODO ic2
public int getValue(ItemStack itemStack) { public int getValue(ItemStack itemStack)
{
// int value = getValue(Recipes.matterAmplifier.getOutputFor(itemStack, // int value = getValue(Recipes.matterAmplifier.getOutputFor(itemStack,
// false)); // false));
if (itemStack.getItem() == ModItems.parts && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) { if(itemStack.getItem() == ModItems.parts && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()){
return 5000; return 5000;
} else if (itemStack.getItem() == ModItems.scrapBox) { } else if (itemStack.getItem() == ModItems.scrapBox){
return 45000; return 45000;
} }
return 0; return 0;
@ -163,12 +197,36 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
// } // }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 1024000; {
return 100000000;
}
@Override public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override public boolean canProvideEnergy(EnumFacing direction)
{
return false;
} }
@Override @Override
public EnumPowerTier getTier() { public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 4096;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME; return EnumPowerTier.EXTREME;
} }
@ -176,5 +234,4 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -5,48 +5,90 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.WorldUtils; import reborncore.common.util.WorldUtils;
import java.util.Iterator; import java.util.Iterator;
public class TilePlayerDectector extends TilePowerAcceptor { public class TilePlayerDectector extends TilePowerAcceptor
{
public String owenerUdid = ""; public String owenerUdid = "";
boolean redstone = false; boolean redstone = false;
@Override public TilePlayerDectector()
public double getMaxPower() { {
return 8000; super(1);
} }
@Override @Override
public EnumPowerTier getTier() { public double getMaxPower()
{
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) { super.updateEntity();
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
{
boolean lastRedstone = redstone; boolean lastRedstone = redstone;
redstone = false; redstone = false;
if (canUseEnergy(10)) { if (canUseEnergy(10))
{
Iterator tIterator = super.worldObj.playerEntities.iterator(); Iterator tIterator = super.worldObj.playerEntities.iterator();
while (tIterator.hasNext()) { while (tIterator.hasNext())
{
EntityPlayer player = (EntityPlayer) tIterator.next(); EntityPlayer player = (EntityPlayer) tIterator.next();
if (player.getDistanceSq((double) super.getPos().getX() + 0.5D, if (player.getDistanceSq((double) super.getPos().getX() + 0.5D,
(double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D) { (double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) worldObj.getBlockState(pos).getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) worldObj.getBlockState(pos).getBlock();
int meta = blockMachineBase.getMetaFromState(worldObj.getBlockState(pos)); int meta = blockMachineBase.getMetaFromState(worldObj.getBlockState(pos));
if (meta == 0) {// ALL if (meta == 0)
{// ALL
redstone = true; redstone = true;
} else if (meta == 1) {// Others } else if (meta == 1)
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())) { {// Others
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString()))
{
redstone = true; redstone = true;
} }
} else {// You } else
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString())) { {// You
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString()))
{
redstone = true; redstone = true;
} }
} }
@ -55,28 +97,31 @@ public class TilePlayerDectector extends TilePowerAcceptor {
} }
useEnergy(10); useEnergy(10);
} }
if (lastRedstone != redstone) { if (lastRedstone != redstone)
{
WorldUtils.updateBlock(worldObj, getPos()); WorldUtils.updateBlock(worldObj, getPos());
worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock()); worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock());
} }
} }
} }
public boolean isProvidingPower() { public boolean isProvidingPower()
{
return redstone; return redstone;
} }
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag); super.readFromNBT(tag);
owenerUdid = tag.getString("ownerID"); owenerUdid = tag.getString("ownerID");
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tag) { public NBTTagCompound writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag); super.writeToNBT(tag);
tag.setString("ownerID", owenerUdid); tag.setString("ownerID", owenerUdid);
return tag; return tag;
} }
} }

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
@ -24,12 +24,16 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
public Tank tank = new Tank("TilePump", 10000, this); public Tank tank = new Tank("TilePump", 10000, this);
public TilePump() {
super(1);
}
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote && worldObj.getTotalWorldTime() % 10 == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(ConfigTechReborn.pumpExtractEU)) { if(!worldObj.isRemote && worldObj.getTotalWorldTime() % 10 == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(ConfigTechReborn.pumpExtractEU)){
FluidStack fluidStack = drainBlock(worldObj, pos.down(), false); FluidStack fluidStack = drainBlock(worldObj, pos.down(), false);
if (fluidStack != null) { if(fluidStack != null){
tank.fill(drainBlock(worldObj, pos.down(), true), true); tank.fill(drainBlock(worldObj, pos.down(), true), true);
useEnergy(ConfigTechReborn.pumpExtractEU); useEnergy(ConfigTechReborn.pumpExtractEU);
} }
@ -41,7 +45,7 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile) {
super.addInfo(info, isRealTile); super.addInfo(info, isRealTile);
info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN
+ PowerSystem.getLocalizedPower(ConfigTechReborn.pumpExtractEU)); + PowerSystem.getLocaliszedPower(ConfigTechReborn.pumpExtractEU));
info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN
+ "1000mb/5 sec"); + "1000mb/5 sec");
} }
@ -76,7 +80,27 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
@Override @Override
public double getMaxPower() { public double getMaxPower() {
return 16000; return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
} }
@Override @Override
@ -85,62 +109,71 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
readFromNBTWithoutCoords(tagCompound); readFromNBTWithoutCoords(tagCompound);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
{
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
writeToNBTWithoutCoords(tagCompound); writeToNBTWithoutCoords(tagCompound);
return tagCompound; return tagCompound;
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
{
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
// IFluidHandler // IFluidHandler
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
int fill = tank.fill(resource, doFill); int fill = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return fill; return fill;
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
FluidStack drain = tank.drain(resource.amount, doDrain); FluidStack drain = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drain = tank.drain(maxDrain, doDrain); FluidStack drain = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
{
return false; return false;
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
} }

View file

@ -19,7 +19,8 @@ import techreborn.init.ModBlocks;
import java.util.List; import java.util.List;
public class TileQuantumChest extends TileMachineBase public class TileQuantumChest extends TileMachineBase
implements IInventoryProvider, IWrenchable, IDeepStorageUnit, IListInfoProvider { implements IInventoryProvider, IWrenchable, IDeepStorageUnit, IListInfoProvider
{
// Slot 0 = Input // Slot 0 = Input
// Slot 1 = Output // Slot 1 = Output
@ -32,44 +33,56 @@ public class TileQuantumChest extends TileMachineBase
public Inventory inventory = new Inventory(3, "TileQuantumChest", storage, this); public Inventory inventory = new Inventory(3, "TileQuantumChest", storage, this);
@Override @Override
public void update() { public void updateEntity()
super.update(); {
if (!worldObj.isRemote) { if (!worldObj.isRemote)
if (storedItem != null) { {
if (storedItem != null)
{
ItemStack fakeStack = storedItem.copy(); ItemStack fakeStack = storedItem.copy();
fakeStack.stackSize = 1; fakeStack.stackSize = 1;
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
} else if (storedItem == null && getStackInSlot(1) != null) { } else if (storedItem == null && getStackInSlot(1) != null)
{
ItemStack fakeStack = getStackInSlot(1).copy(); ItemStack fakeStack = getStackInSlot(1).copy();
fakeStack.stackSize = 1; fakeStack.stackSize = 1;
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
} else { } else
{
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
if (getStackInSlot(0) != null) { if (getStackInSlot(0) != null)
if (storedItem == null) { {
if (storedItem == null)
{
storedItem = getStackInSlot(0); storedItem = getStackInSlot(0);
setInventorySlotContents(0, null); setInventorySlotContents(0, null);
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) { } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true))
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize) { {
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize)
{
storedItem.stackSize += getStackInSlot(0).stackSize; storedItem.stackSize += getStackInSlot(0).stackSize;
decrStackSize(0, getStackInSlot(0).stackSize); decrStackSize(0, getStackInSlot(0).stackSize);
} }
} }
} }
if (storedItem != null && getStackInSlot(1) == null) { if (storedItem != null && getStackInSlot(1) == null)
{
ItemStack itemStack = storedItem.copy(); ItemStack itemStack = storedItem.copy();
itemStack.stackSize = itemStack.getMaxStackSize(); itemStack.stackSize = itemStack.getMaxStackSize();
setInventorySlotContents(1, itemStack); setInventorySlotContents(1, itemStack);
storedItem.stackSize -= itemStack.getMaxStackSize(); storedItem.stackSize -= itemStack.getMaxStackSize();
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true)) { } else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true))
{
int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize; int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize;
if (storedItem.stackSize >= wanted) { if (storedItem.stackSize >= wanted)
{
decrStackSize(1, -wanted); decrStackSize(1, -wanted);
storedItem.stackSize -= wanted; storedItem.stackSize -= wanted;
} else { } else
{
decrStackSize(1, -storedItem.stackSize); decrStackSize(1, -storedItem.stackSize);
storedItem = null; storedItem = null;
} }
@ -78,43 +91,51 @@ public class TileQuantumChest extends TileMachineBase
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
readFromNBTWithoutCoords(tagCompound); readFromNBTWithoutCoords(tagCompound);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
{
storedItem = null; storedItem = null;
if (tagCompound.hasKey("storedStack")) { if (tagCompound.hasKey("storedStack"))
{
storedItem = ItemStack.loadItemStackFromNBT((NBTTagCompound) tagCompound.getTag("storedStack")); storedItem = ItemStack.loadItemStackFromNBT((NBTTagCompound) tagCompound.getTag("storedStack"));
} }
if (storedItem != null) { if (storedItem != null)
{
storedItem.stackSize = tagCompound.getInteger("storedQuantity"); storedItem.stackSize = tagCompound.getInteger("storedQuantity");
} }
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
writeToNBTWithoutCoords(tagCompound); writeToNBTWithoutCoords(tagCompound);
return tagCompound; return tagCompound;
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
if (storedItem != null) { {
if (storedItem != null)
{
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound())); tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", storedItem.stackSize); tagCompound.setInteger("storedQuantity", storedItem.stackSize);
} else { } else{
tagCompound.setInteger("storedQuantity", 0); tagCompound.setInteger("storedQuantity", 0);
} }
@ -122,31 +143,37 @@ public class TileQuantumChest extends TileMachineBase
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1F; return 1F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return getDropWithNBT(); return getDropWithNBT();
} }
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT()
{
NBTTagCompound tileEntity = new NBTTagCompound(); NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1); ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1);
writeToNBTWithoutCoords(tileEntity); writeToNBTWithoutCoords(tileEntity);
@ -156,39 +183,47 @@ public class TileQuantumChest extends TileMachineBase
} }
@Override @Override
public ItemStack getStoredItemType() { public ItemStack getStoredItemType()
{
return this.storedItem; return this.storedItem;
} }
@Override @Override
public void setStoredItemCount(int amount) { public void setStoredItemCount(int amount)
{
this.storedItem.stackSize = 0; this.storedItem.stackSize = 0;
this.storedItem.stackSize += (amount); this.storedItem.stackSize += (amount);
this.markDirty(); this.markDirty();
} }
@Override @Override
public void setStoredItemType(ItemStack type, int amount) { public void setStoredItemType(ItemStack type, int amount)
{
this.storedItem = type; this.storedItem = type;
this.storedItem.stackSize = amount; this.storedItem.stackSize = amount;
this.markDirty(); this.markDirty();
} }
@Override @Override
public int getMaxStoredCount() { public int getMaxStoredCount()
{
return this.storage; return this.storage;
} }
@Override @Override
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile)
if (isRealTile) { {
if (isRealTile)
{
int size = 0; int size = 0;
String name = "of nothing"; String name = "of nothing";
if (storedItem != null) { if (storedItem != null)
{
name = storedItem.getDisplayName(); name = storedItem.getDisplayName();
size += storedItem.stackSize; size += storedItem.stackSize;
} }
if (getStackInSlot(1) != null) { if (getStackInSlot(1) != null)
{
name = getStackInSlot(1).getDisplayName(); name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).stackSize; size += getStackInSlot(1).stackSize;
} }
@ -200,5 +235,4 @@ public class TileQuantumChest extends TileMachineBase
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -22,49 +22,60 @@ import techreborn.init.ModBlocks;
import java.util.List; import java.util.List;
public class TileQuantumTank extends TileMachineBase implements IFluidHandler,IInventoryProvider, IWrenchable, IListInfoProvider { public class TileQuantumTank extends TileMachineBase
implements IFluidHandler,IInventoryProvider, IWrenchable, IListInfoProvider
{
public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this); public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this);
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this); public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this);
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
readFromNBTWithoutCoords(tagCompound); readFromNBTWithoutCoords(tagCompound);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
{
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
writeToNBTWithoutCoords(tagCompound); writeToNBTWithoutCoords(tagCompound);
return tagCompound; return tagCompound;
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
{
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
if (!worldObj.isRemote) { super.updateEntity();
if (!worldObj.isRemote)
{
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType()); FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType());
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == null)
{
// inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); // inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != null)
{
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
tank.compareAndUpdate(); tank.compareAndUpdate();
@ -73,67 +84,79 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler,II
// IFluidHandler // IFluidHandler
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
int fill = tank.fill(resource, doFill); int fill = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return fill; return fill;
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
FluidStack drain = tank.drain(resource.amount, doDrain); FluidStack drain = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drain = tank.drain(maxDrain, doDrain); FluidStack drain = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1F; return 1F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return getDropWithNBT(); return getDropWithNBT();
} }
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT()
{
NBTTagCompound tileEntity = new NBTTagCompound(); NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1); ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1);
writeToNBTWithoutCoords(tileEntity); writeToNBTWithoutCoords(tileEntity);
@ -143,11 +166,15 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler,II
} }
@Override @Override
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile)
if (isRealTile) { {
if (tank.getFluid() != null) { if (isRealTile)
{
if (tank.getFluid() != null)
{
info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName()); info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName());
} else { } else
{
info.add("Empty"); info.add("Empty");
} }
} }
@ -159,5 +186,4 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler,II
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -9,14 +9,15 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.api.RollingMachineRecipe; import techreborn.api.RollingMachineRecipe;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
//TODO add tick and power bars. //TODO add tick and power bars.
public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable,IInventoryProvider { public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public final InventoryCrafting craftMatrix = new InventoryCrafting(new RollingTileContainer(), 3, 3); public final InventoryCrafting craftMatrix = new InventoryCrafting(new RollingTileContainer(), 3, 3);
public Inventory inventory = new Inventory(3, "TileRollingMachine", 64, this); public Inventory inventory = new Inventory(3, "TileRollingMachine", 64, this);
@ -27,34 +28,73 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
public int euTick = 5; public int euTick = 5;
@Override public TileRollingMachine()
public double getMaxPower() { {
return 64000; super(1);
} }
@Override @Override
public EnumPowerTier getTier() { public double getMaxPower()
return EnumPowerTier.MEDIUM; {
return 100000;
} }
@Override @Override
public void update() { public boolean canAcceptEnergy(EnumFacing direction)
super.update(); {
//charge(2); TODO return true;
if (!worldObj.isRemote) { }
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
}
@Override
public void updateEntity()
{
super.updateEntity();
charge(2);
if (!worldObj.isRemote)
{
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
if (currentRecipe != null && canMake()) { if (currentRecipe != null && canMake())
if (tickTime >= runTime) { {
if (tickTime >= runTime)
{
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
if (currentRecipe != null) { if (currentRecipe != null)
{
boolean hasCrafted = false; boolean hasCrafted = false;
if (inventory.getStackInSlot(0) == null) { if (inventory.getStackInSlot(0) == null)
{
inventory.setInventorySlotContents(0, currentRecipe); inventory.setInventorySlotContents(0, currentRecipe);
tickTime = -1; tickTime = -1;
hasCrafted = true; hasCrafted = true;
} else { } else
{
if (inventory.getStackInSlot(0).stackSize + currentRecipe.stackSize <= currentRecipe if (inventory.getStackInSlot(0).stackSize + currentRecipe.stackSize <= currentRecipe
.getMaxStackSize()) { .getMaxStackSize())
{
ItemStack stack = inventory.getStackInSlot(0); ItemStack stack = inventory.getStackInSlot(0);
stack.stackSize = stack.stackSize + currentRecipe.stackSize; stack.stackSize = stack.stackSize + currentRecipe.stackSize;
inventory.setInventorySlotContents(0, stack); inventory.setInventorySlotContents(0, stack);
@ -62,8 +102,10 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
hasCrafted = true; hasCrafted = true;
} }
} }
if (hasCrafted) { if (hasCrafted)
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { {
for (int i = 0; i < craftMatrix.getSizeInventory(); i++)
{
craftMatrix.decrStackSize(i, 1); craftMatrix.decrStackSize(i, 1);
} }
currentRecipe = null; currentRecipe = null;
@ -71,56 +113,69 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
} }
} }
} }
if (currentRecipe != null) { if (currentRecipe != null)
if (canUseEnergy(euTick) && tickTime < runTime) { {
if (canUseEnergy(euTick) && tickTime < runTime)
{
useEnergy(euTick); useEnergy(euTick);
tickTime++; tickTime++;
} }
} }
if (currentRecipe == null) { if (currentRecipe == null)
{
tickTime = -1; tickTime = -1;
} }
} else { } else
{
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
if (currentRecipe != null) { if (currentRecipe != null)
{
inventory.setInventorySlotContents(1, currentRecipe); inventory.setInventorySlotContents(1, currentRecipe);
} else { } else
{
inventory.setInventorySlotContents(1, null); inventory.setInventorySlotContents(1, null);
} }
} }
} }
public boolean canMake() { public boolean canMake()
{
return RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj) != null; return RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj) != null;
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.RollingMachine, 1); return new ItemStack(ModBlocks.RollingMachine, 1);
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound); ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound);
isRunning = tagCompound.getBoolean("isRunning"); isRunning = tagCompound.getBoolean("isRunning");
@ -128,25 +183,29 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound); ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound);
writeUpdateToNBT(tagCompound); writeUpdateToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
public void writeUpdateToNBT(NBTTagCompound tagCompound) { public void writeUpdateToNBT(NBTTagCompound tagCompound)
{
tagCompound.setBoolean("isRunning", isRunning); tagCompound.setBoolean("isRunning", isRunning);
tagCompound.setInteger("tickTime", tickTime); tagCompound.setInteger("tickTime", tickTime);
} }
@Override @Override
public void invalidate() { public void invalidate()
{
super.invalidate(); super.invalidate();
} }
@Override @Override
public void onChunkUnload() { public void onChunkUnload()
{
super.onChunkUnload(); super.onChunkUnload();
} }
@ -155,13 +214,14 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
return inventory; return inventory;
} }
private static class RollingTileContainer extends Container { private static class RollingTileContainer extends Container
{
@Override @Override
public boolean canInteractWith(EntityPlayer entityplayer) { public boolean canInteractWith(EntityPlayer entityplayer)
{
return true; return true;
} }
} }
} }

View file

@ -9,7 +9,7 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.ScrapboxList; import techreborn.api.ScrapboxList;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -17,9 +17,11 @@ import techreborn.init.ModItems;
import java.util.Random; import java.util.Random;
public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory { public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
{
public Inventory inventory = new Inventory(6, "TileScrapboxinator", 64, this); public Inventory inventory = new Inventory(6, "TileScrapboxinator", 64, this);
public int capacity = 1000;
public int cost = 20; public int cost = 20;
public int progress; public int progress;
public int time = 200; public int time = 200;
@ -28,71 +30,93 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public int input1 = 0; public int input1 = 0;
public int output = 1; public int output = 1;
public int gaugeProgressScaled(int scale) { public TileScrapboxinator()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
return (progress * scale) / time; return (progress * scale) / time;
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
boolean burning = isBurning(); boolean burning = isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (getEnergy() <= cost && canOpen()) { if (getEnergy() <= cost && canOpen())
if (getEnergy() > cost) { {
if (getEnergy() > cost)
{
updateInventory = true; updateInventory = true;
} }
} }
if (isBurning() && canOpen()) { if (isBurning() && canOpen())
{
updateState(); updateState();
progress++; progress++;
if (progress >= time) { if (progress >= time)
{
progress = 0; progress = 0;
recycleItems(); recycleItems();
updateInventory = true; updateInventory = true;
} }
} else { } else
{
progress = 0; progress = 0;
updateState(); updateState();
} }
if (burning != isBurning()) { if (burning != isBurning())
{
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory)
{
markDirty(); markDirty();
} }
} }
public void recycleItems() { public void recycleItems()
if (this.canOpen() && !worldObj.isRemote) { {
if (this.canOpen() && !worldObj.isRemote)
{
int random = new Random().nextInt(ScrapboxList.stacks.size()); int random = new Random().nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy(); ItemStack out = ScrapboxList.stacks.get(random).copy();
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == null)
{
useEnergy(cost); useEnergy(cost);
setInventorySlotContents(output, out); setInventorySlotContents(output, out);
} }
if (getStackInSlot(input1).stackSize > 1) { if (getStackInSlot(input1).stackSize > 1)
{
useEnergy(cost); useEnergy(cost);
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else
{
useEnergy(cost); useEnergy(cost);
setInventorySlotContents(input1, null); setInventorySlotContents(input1, null);
} }
} }
} }
public boolean canOpen() { public boolean canOpen()
{
return getStackInSlot(input1) != null && getStackInSlot(output) == null; return getStackInSlot(input1) != null && getStackInSlot(output) == null;
} }
public boolean isBurning() { public boolean isBurning()
{
return getEnergy() > cost; return getEnergy() > cost;
} }
public void updateState() { public void updateState()
{
IBlockState blockState = worldObj.getBlockState(pos); IBlockState blockState = worldObj.getBlockState(pos);
if (blockState.getBlock() instanceof BlockMachineBase) { if (blockState.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0) if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, worldObj, pos); blockMachineBase.setActive(progress > 0, worldObj, pos);
@ -100,46 +124,56 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.scrapboxinator, 1); return new ItemStack(ModBlocks.scrapboxinator, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
// ISidedInventory // ISidedInventory
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side)
return side == EnumFacing.DOWN ? new int[]{0, 1, 2} : new int[]{0, 1, 2}; {
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
} }
@Override @Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex == 2) if (slotIndex == 2)
return false; return false;
if (slotIndex == 1) { if (slotIndex == 1)
if (itemStack.getItem() == ModItems.scrapBox) { {
if (itemStack.getItem() == ModItems.scrapBox)
{
return true; return true;
} }
} }
@ -147,18 +181,45 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
} }
@Override @Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2; return slotIndex == 2;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 16000; {
return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.LOW; {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM;
} }
@ -166,5 +227,4 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -0,0 +1,212 @@
package techreborn.tiles;
import reborncore.common.IWrenchable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ITileRecipeHandler<VacuumFreezerRecipe>, IRecipeCrafterProvider
{
public int tickTime;
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
public RecipeCrafter crafter;
public int multiBlockStatus = 0;
public TileVacuumFreezer()
{
super(2);
// Input slots
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
outputs[0] = 1;
crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
crafter.updateEntity();
if (worldObj.getTotalWorldTime() % 20 == 0)
{
multiBlockStatus = checkMachine() ? 1 : 0;
}
}
@Override
public double getMaxPower()
{
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM;
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloySmelter, 1);
}
public boolean isComplete()
{
return false;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
return tagCompound;
}
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
}
return 0;
}
public boolean checkMachine()
{
int xDir = EnumFacing.UP.getFrontOffsetX() * 2;
int yDir = EnumFacing.UP.getFrontOffsetY() * 2;
int zDir = EnumFacing.UP.getFrontOffsetZ() * 2;
for (int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
for (int k = -1; k < 2; k++)
{
if ((i != 0) || (j != 0) || (k != 0))
{
if (worldObj.getBlockState(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
getPos().getZ() - zDir + k)).getBlock() != ModBlocks.MachineCasing)
{
return false;
}
IBlockState BlockStateContainer = worldObj.getBlockState(new BlockPos(
getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k));
BlockMachineCasing blockMachineCasing = (BlockMachineCasing) BlockStateContainer.getBlock();
if (blockMachineCasing
.getMetaFromState(BlockStateContainer) != (((i == 0) && (j == 0) && (k != 0))
|| ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2
: 1))
{
return false;
}
} else if (!worldObj.isAirBlock(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
getPos().getZ() - zDir + k)))
{
return false;
}
}
}
}
return true;
}
@Override
public boolean canCraft(TileEntity tile, VacuumFreezerRecipe recipe) {
if (tile instanceof TileVacuumFreezer) {
if (((TileVacuumFreezer) tile).multiBlockStatus == 1) {
return true;
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile, VacuumFreezerRecipe recipe) {
return true;
}
@Override
public Inventory getInventory() {
return inventory;
}
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -8,7 +8,6 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.api.reactor.FusionReactorRecipe; import techreborn.api.reactor.FusionReactorRecipe;
@ -16,7 +15,7 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileEntityFusionController extends TilePowerAcceptorProducer implements IInventoryProvider public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider
{ {
public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this); public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this);
@ -32,23 +31,31 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
FusionReactorRecipe currentRecipe = null; FusionReactorRecipe currentRecipe = null;
boolean hasStartedCrafting = false; boolean hasStartedCrafting = false;
public TileEntityFusionController()
{
super(4);
}
@Override @Override
public double getMaxPower() { public double getMaxPower() {
return 100000000; return 100000000;
} }
@Override @Override
public boolean canAcceptEnergy(EnumFacing direction) { public boolean canAcceptEnergy(EnumFacing direction)
return hasStartedCrafting; {
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
} }
@Override @Override
public boolean canProvideEnergy(EnumFacing direction) { public boolean canProvideEnergy(EnumFacing direction)
return !hasStartedCrafting; {
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
} }
@Override @Override
public double getMaxOutput() { public double getMaxOutput()
{
if (!hasStartedCrafting) if (!hasStartedCrafting)
{ {
return 0; return 0;
@ -56,10 +63,18 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
return 1000000; return 1000000;
} }
@Override
public double getMaxInput() {
if (hasStartedCrafting) {
return 0;
}
return 8192;
}
@Override @Override
public EnumPowerTier getTier() public EnumPowerTier getTier()
{ {
return EnumPowerTier.INSANE; return EnumPowerTier.EXTREME;
} }
@Override @Override
@ -137,9 +152,9 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
} }
@Override @Override
public void update() public void updateEntity()
{ {
super.update(); super.updateEntity();
// TODO improve this code a lot // TODO improve this code a lot
if (worldObj.getTotalWorldTime() % 20 == 0) if (worldObj.getTotalWorldTime() % 20 == 0)
@ -261,29 +276,11 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
if (!worldObj.isRemote && getEnergy() > 0 && hasStartedCrafting) { if (!worldObj.isRemote && getEnergy() > 0 && hasStartedCrafting) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy(); double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) { useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
} }
} }
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
private boolean validateRecipe() private boolean validateRecipe()
{ {
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true)) if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true))
@ -336,7 +333,7 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
@Override @Override
public String getName() public String getName()
{ {
return "Fusion Reactor"; return null;
} }
@Override @Override

View file

@ -1,6 +1,5 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -13,7 +12,6 @@ import reborncore.api.fuel.FluidPowerManager;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
@ -21,23 +19,16 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileDieselGenerator extends TilePowerProducer implements IWrenchable, IFluidHandler, IInventoryProvider public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider
{ {
public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput; public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput;
public Tank tank = new Tank("TileDieselGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); public Tank tank = new Tank("TileDieselGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64, this); public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64, this);
public TileDieselGenerator()
@Override {
public double emitEnergy(EnumFacing enumFacing, double amount) { super(ConfigTechReborn.ThermalGeneratorTier);
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
@ -140,8 +131,8 @@ public class TileDieselGenerator extends TilePowerProducer implements IWrenchabl
} }
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType()); FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType());
@ -156,28 +147,57 @@ public class TileDieselGenerator extends TilePowerProducer implements IWrenchabl
if (!tank.isEmpty() && tank.getFluidType() != null if (!tank.isEmpty() && tank.getFluidType() != null
&& FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType())) { && FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType())) {
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType()); double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
if (getMaxPower() - getEnergy() >= powerIn) { if (getFreeSpace() >= powerIn) {
addEnergy(powerIn, false); addEnergy(powerIn, false);
tank.drain(1, true); tank.drain(1, true);
} }
} }
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return ConfigTechReborn.ThermalGeneratorCharge;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
public double getMaxInput()
{
return 0;
} }
@Override @Override
public EnumPowerTier getTier() public EnumPowerTier getTier()
{ {
return EnumPowerTier.MEDIUM; return EnumPowerTier.LOW;
} }
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -9,31 +9,25 @@ import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileDragonEggSiphoner extends TilePowerProducer implements IWrenchable,IInventoryProvider { public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public static final int euTick = ConfigTechReborn.DragonEggSiphonerOutput; public static final int euTick = ConfigTechReborn.DragonEggSiphonerOutput;
public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64, this); public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64, this);
@Override public TileDragonEggSiphoner()
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing); super(2);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ())) if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))
@ -41,44 +35,81 @@ public class TileDragonEggSiphoner extends TilePowerProducer implements IWrencha
addEnergy(euTick); addEnergy(euTick);
} }
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Dragoneggenergysiphoner, 1); return new ItemStack(ModBlocks.Dragoneggenergysiphoner, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 256000; {
return 1000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.HIGH; return EnumPowerTier.HIGH;
} }

View file

@ -1,31 +1,32 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IFluidHandler,IInventoryProvider { public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
// TODO: run this off config // TODO: run this off config
public static final int euTick = 16; public static final int euTick = 16;
public Tank tank = new Tank("TileGasTurbine", Fluid.BUCKET_VOLUME * 10, this); public Tank tank = new Tank("TileGasTurbine", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileGasTurbine", 64, this); public Inventory inventory = new Inventory(3, "TileGasTurbine", 64, this);
Map<String, Integer> fluids = new HashMap<>(); Map<String, Integer> fluids = new HashMap<>();
@ -34,7 +35,9 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
// amounts. // amounts.
double pendingWithdraw = 0.0; double pendingWithdraw = 0.0;
public TileGasTurbine() { public TileGasTurbine()
{
super(ConfigTechReborn.ThermalGeneratorTier);
// TODO: fix this to have Gas Turbine generator values // TODO: fix this to have Gas Turbine generator values
fluids.put("fluidhydrogen", 15000); fluids.put("fluidhydrogen", 15000);
@ -42,103 +45,107 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
} }
@Override @Override
public double emitEnergy(EnumFacing enumFacing, double amount) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
BlockPos pos = getPos().offset(enumFacing); {
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Gasturbine, 1); return new ItemStack(ModBlocks.Gasturbine, 1);
} }
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
int fill = tank.fill(resource, doFill); int fill = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return fill; return fill;
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
FluidStack drain = tank.drain(resource.amount, doDrain); FluidStack drain = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drain = tank.drain(maxDrain, doDrain); FluidStack drain = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
if (fluid != null) { {
if (fluid != null)
{
return fluids.containsKey(FluidRegistry.getFluidName(fluid)); return fluids.containsKey(FluidRegistry.getFluidName(fluid));
} }
return false; return false;
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
tank.compareAndUpdate(); tank.compareAndUpdate();
@ -166,15 +173,45 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return ConfigTechReborn.ThermalGeneratorCharge;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM; return EnumPowerTier.MEDIUM;
} }

View file

@ -1,6 +1,5 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,42 +9,37 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileGenerator extends TilePowerProducer implements IWrenchable,IInventoryProvider { public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public static int outputAmount = 10; // This is in line with BC engines rf, public static int outputAmount = 10; // This is in line with BC engines rf,
public Inventory inventory = new Inventory(2, "TileGenerator", 64, this); public Inventory inventory = new Inventory(2, "TileGenerator", 64, this);
public int fuelSlot = 0; public int fuelSlot = 0;
public int burnTime; public int burnTime;
public int totalBurnTime = 0; public int totalBurnTime = 0;
// sould properly use the conversion // sould properly use the conversion
// ratio here. // ratio here.
public boolean isBurning; public boolean isBurning;
public boolean lastTickBurning; public boolean lastTickBurning;
ItemStack burnItem; ItemStack burnItem;
public static int getItemBurnTime(ItemStack stack) { public TileGenerator()
{
super(1);
}
public static int getItemBurnTime(ItemStack stack)
{
return TileEntityFurnace.getItemBurnTime(stack) / 4; return TileEntityFurnace.getItemBurnTime(stack) / 4;
} }
@Override @Override
public double emitEnergy(EnumFacing enumFacing, double amount) { public void updateEntity() {
BlockPos pos = getPos().offset(enumFacing); super.updateEntity();
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public void update() {
super.update();
if (worldObj.isRemote) { if (worldObj.isRemote) {
return; return;
} }
@ -75,11 +69,17 @@ public class TileGenerator extends TilePowerProducer implements IWrenchable,IInv
lastTickBurning = isBurning; lastTickBurning = isBurning;
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
public void updateState() { public void updateState()
{
IBlockState BlockStateContainer = worldObj.getBlockState(pos); IBlockState BlockStateContainer = worldObj.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0)
blockMachineBase.setActive(burnTime > 0, worldObj, pos); blockMachineBase.setActive(burnTime > 0, worldObj, pos);
@ -87,37 +87,68 @@ public class TileGenerator extends TilePowerProducer implements IWrenchable,IInv
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 8000; {
return 100;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer p0) { public ItemStack getWrenchDrop(EntityPlayer p0)
{
return new ItemStack(ModBlocks.Generator); return new ItemStack(ModBlocks.Generator);
} }

View file

@ -1,35 +1,30 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileHeatGenerator extends TilePowerProducer implements IWrenchable { public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable
{
public static final int euTick = ConfigTechReborn.HeatGeneratorOutput; public static final int euTick = ConfigTechReborn.HeatGeneratorOutput;
@Override public TileHeatGenerator()
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing); super(1);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (worldObj.getBlockState(new BlockPos(getPos().getX() + 1, getPos().getY(), getPos().getZ())) if (worldObj.getBlockState(new BlockPos(getPos().getX() + 1, getPos().getY(), getPos().getZ()))
@ -51,45 +46,89 @@ public class TileHeatGenerator extends TilePowerProducer implements IWrenchable
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.heatGenerator, 1); return new ItemStack(ModBlocks.heatGenerator, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 16000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
// @Override
// public void addWailaInfo(List<String> info)
// {
// super.addWailaInfo(info);
// info.add("Power Generarating " + euTick +" EU/t");
//
// }
} }

View file

@ -8,14 +8,18 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileLightningRod extends TilePowerProducer { public class TileLightningRod extends TilePowerAcceptor {
private int onStatusHoldTicks = -1; private int onStatusHoldTicks = -1;
public TileLightningRod() {
super(2);
}
@Override @Override
public void update() { public void update() {
super.update(); super.update();
@ -47,6 +51,10 @@ public class TileLightningRod extends TilePowerProducer {
} }
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
public float getLightningStrikeMultiplier() { public float getLightningStrikeMultiplier() {
@ -64,17 +72,6 @@ public class TileLightningRod extends TilePowerProducer {
return 4F; return 4F;
} }
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
public boolean isValidIronFence(int y) { public boolean isValidIronFence(int y) {
Item itemBlock = Item.getItemFromBlock(worldObj.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock()); Item itemBlock = Item.getItemFromBlock(worldObj.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
for(ItemStack fence : OreDictionary.getOres("fenceIron")) { for(ItemStack fence : OreDictionary.getOres("fenceIron")) {
@ -85,17 +82,32 @@ public class TileLightningRod extends TilePowerProducer {
@Override @Override
public double getMaxPower() { public double getMaxPower() {
return 1024000; return 327680;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return direction == getFacingEnum();
} }
@Override @Override
public double getMaxOutput() { public double getMaxOutput() {
return 32768; return 2048;
}
@Override
public double getMaxInput() {
return 0;
} }
@Override @Override
public EnumPowerTier getTier() { public EnumPowerTier getTier() {
return EnumPowerTier.INSANE; return EnumPowerTier.HIGH;
} }
} }

View file

@ -1,27 +1,28 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class TileSemifluidGenerator extends TilePowerProducer implements IWrenchable, IFluidHandler,IInventoryProvider { public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
// TODO: run this off config // TODO: run this off config
public static final int euTick = 8; public static final int euTick = 8;
@ -34,7 +35,9 @@ public class TileSemifluidGenerator extends TilePowerProducer implements IWrench
// amounts. // amounts.
double pendingWithdraw = 0.0; double pendingWithdraw = 0.0;
public TileSemifluidGenerator() { public TileSemifluidGenerator()
{
super(ConfigTechReborn.ThermalGeneratorTier);
// TODO: fix this to have SemiFluid generator values // TODO: fix this to have SemiFluid generator values
fluids.put("creosote", 3000); fluids.put("creosote", 3000);
@ -48,103 +51,107 @@ public class TileSemifluidGenerator extends TilePowerProducer implements IWrench
} }
@Override @Override
public double emitEnergy(EnumFacing enumFacing, double amount) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
BlockPos pos = getPos().offset(enumFacing); {
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Semifluidgenerator, 1); return new ItemStack(ModBlocks.Semifluidgenerator, 1);
} }
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
int fill = tank.fill(resource, doFill); int fill = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return fill; return fill;
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
FluidStack drain = tank.drain(resource.amount, doDrain); FluidStack drain = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drain = tank.drain(maxDrain, doDrain); FluidStack drain = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
if (fluid != null) { {
if (fluid != null)
{
return fluids.containsKey(FluidRegistry.getFluidName(fluid)); return fluids.containsKey(FluidRegistry.getFluidName(fluid));
} }
return false; return false;
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) if (!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
@ -170,15 +177,45 @@ public class TileSemifluidGenerator extends TilePowerProducer implements IWrench
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 16000; {
return ConfigTechReborn.ThermalGeneratorCharge;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
@ -186,5 +223,4 @@ public class TileSemifluidGenerator extends TilePowerProducer implements IWrench
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
} }

View file

@ -2,9 +2,8 @@ package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.blocks.generator.BlockSolarPanel; import techreborn.blocks.generator.BlockSolarPanel;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
@ -13,15 +12,22 @@ import java.util.List;
/** /**
* Created by modmuss50 on 25/02/2016. * Created by modmuss50 on 25/02/2016.
*/ */
public class TileSolarPanel extends TilePowerProducer implements ITickable { public class TileSolarPanel extends TilePowerAcceptor implements ITickable
{
boolean shouldMakePower = false; boolean shouldMakePower = false;
boolean lastTickSate = false;
int powerToAdd; int powerToAdd;
public TileSolarPanel()
{
super(1);
}
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (worldObj.getTotalWorldTime() % 60 == 0) { if (worldObj.getTotalWorldTime() % 60 == 0) {
shouldMakePower = isSunOut(); shouldMakePower = isSunOut();
@ -35,12 +41,19 @@ public class TileSolarPanel extends TilePowerProducer implements ITickable {
} }
worldObj.setBlockState(getPos(), worldObj.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, isSunOut())); worldObj.setBlockState(getPos(), worldObj.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, isSunOut()));
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile)
{
super.addInfo(info, isRealTile); super.addInfo(info, isRealTile);
if (isRealTile) { if (isRealTile)
{
// FIXME: 25/02/2016 // FIXME: 25/02/2016
// info.add(TextFormatting.LIGHT_PURPLE + "Power gen/tick " + // info.add(TextFormatting.LIGHT_PURPLE + "Power gen/tick " +
// TextFormatting.GREEN + PowerSystem.getLocalizedPower( // TextFormatting.GREEN + PowerSystem.getLocalizedPower(
@ -48,30 +61,45 @@ public class TileSolarPanel extends TilePowerProducer implements ITickable {
} }
} }
@Override public boolean isSunOut()
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing); return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
public boolean isSunOut() {
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
&& worldObj.isDaytime(); && worldObj.isDaytime();
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 8000; {
return 1000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.LOW; {
return false;
} }
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 32;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
}
} }

View file

@ -1,5 +1,6 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -11,9 +12,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
@ -21,73 +21,79 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileThermalGenerator extends TilePowerProducer implements IWrenchable, IFluidHandler,IInventoryProvider { public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput; public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput;
public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64, this); public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64, this);
@Override public TileThermalGenerator()
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing); super(ConfigTechReborn.ThermalGeneratorTier);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.thermalGenerator, 1); return new ItemStack(ModBlocks.thermalGenerator, 1);
} }
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
int fill = tank.fill(resource, doFill); int fill = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return fill; return fill;
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
FluidStack drain = tank.drain(resource.amount, doDrain); FluidStack drain = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drain = tank.drain(maxDrain, doDrain); FluidStack drain = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drain; return drain;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
if (fluid != null) { {
if (fluid == FluidRegistry.LAVA) { if (fluid != null)
{
if (fluid == FluidRegistry.LAVA)
{
return true; return true;
} }
} }
@ -95,30 +101,35 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
@ -126,8 +137,8 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
@Override @Override
// TODO optimise this code // TODO optimise this code
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
for (EnumFacing direction : EnumFacing.values()) { for (EnumFacing direction : EnumFacing.values()) {
@ -161,15 +172,46 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 16000; {
return ConfigTechReborn.ThermalGeneratorCharge;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 128;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }

View file

@ -2,57 +2,84 @@ package techreborn.tiles.generator;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
/** /**
* Created by modmuss50 on 25/02/2016. * Created by modmuss50 on 25/02/2016.
*/ */
public class TileWaterMill extends TilePowerProducer { public class TileWaterMill extends TilePowerAcceptor
{
int waterblocks = 0; int waterblocks = 0;
public TileWaterMill()
{
super(1);
}
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (worldObj.getTotalWorldTime() % 20 == 0) { if (worldObj.getTotalWorldTime() % 20 == 0) {
checkForWater(); checkForWater();
} }
if (waterblocks > 0) { if (waterblocks > 0) {
addEnergy(waterblocks); addEnergy(waterblocks);
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
public void checkForWater() { public void checkForWater()
{
waterblocks = 0; waterblocks = 0;
for (EnumFacing facing : EnumFacing.HORIZONTALS) { for (EnumFacing facing : EnumFacing.HORIZONTALS)
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER) { {
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER)
{
waterblocks++; waterblocks++;
} }
} }
} }
@Override @Override
public double emitEnergy(EnumFacing enumFacing, double amount) { public double getMaxPower()
BlockPos pos = getPos().offset(enumFacing); {
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver( return 1000;
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
public double getMaxPower() { public boolean canAcceptEnergy(EnumFacing direction)
return 8000; {
return false;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 32;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
} }

View file

@ -1,47 +1,70 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
/** /**
* Created by modmuss50 on 25/02/2016. * Created by modmuss50 on 25/02/2016.
*/ */
public class TileWindMill extends TilePowerProducer { public class TileWindMill extends TilePowerAcceptor
{
int basePower = 16; int basePower = 16;
public TileWindMill()
{
super(2);
}
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (pos.getY() > 64) { if (pos.getY() > 64) {
double actualPower = basePower + basePower * worldObj.getThunderStrength(1.0F); double actualPower = basePower + basePower * worldObj.getThunderStrength(1.0F);
addEnergy(actualPower); addEnergy(actualPower);
} }
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
} }
@Override @Override
public double emitEnergy(EnumFacing enumFacing, double amount) { public double getMaxPower()
BlockPos pos = getPos().offset(enumFacing); {
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver( return 10000;
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
} }
@Override @Override
public double getMaxPower() { public boolean canAcceptEnergy(EnumFacing direction)
return 8000; {
return false;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 128;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
} }

View file

@ -15,29 +15,37 @@ import java.util.HashMap;
import java.util.TreeMap; import java.util.TreeMap;
public class IDSUManager { public class IDSUManager
{
public static final String savename = "idsu.json"; public static final String savename = "idsu.json";
public static IDSUManager INSTANCE; public static IDSUManager INSTANCE;
public HashMap<World, IDSUWorldSaveData> worldData = new HashMap<>(); public HashMap<World, IDSUWorldSaveData> worldData = new HashMap<>();
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void worldSave(WorldEvent.Save event) { public void worldSave(WorldEvent.Save event)
{
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) { && event.getWorld().getSaveHandler().getWorldDirectory() != null)
if (worldData.containsKey(event.getWorld())) { {
if (worldData.containsKey(event.getWorld()))
{
worldData.get(event.getWorld()).save(); worldData.get(event.getWorld()).save();
} }
} }
} }
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void worldLoad(WorldEvent.Load event) { public void worldLoad(WorldEvent.Load event)
{
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) { && event.getWorld().getSaveHandler().getWorldDirectory() != null)
if (worldData.containsKey(event.getWorld())) { {
if (worldData.containsKey(event.getWorld()))
{
worldData.get(event.getWorld()).load(); worldData.get(event.getWorld()).load();
} else { } else
{
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(event.getWorld()); IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(event.getWorld());
worldData.put(event.getWorld(), worldSaveData); worldData.put(event.getWorld(), worldSaveData);
worldSaveData.load(); worldSaveData.load();
@ -46,10 +54,13 @@ public class IDSUManager {
} }
@SubscribeEvent(priority = EventPriority.LOWEST) @SubscribeEvent(priority = EventPriority.LOWEST)
public void worldClosed(WorldEvent.Unload event) { public void worldClosed(WorldEvent.Unload event)
{
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) { && event.getWorld().getSaveHandler().getWorldDirectory() != null)
if (worldData.containsKey(event.getWorld())) { {
if (worldData.containsKey(event.getWorld()))
{
worldData.get(event.getWorld()).save(); worldData.get(event.getWorld()).save();
} }
} }
@ -57,10 +68,13 @@ public class IDSUManager {
worldData.clear(); worldData.clear();
} }
public IDSUValueSaveData getSaveDataForWorld(World world, String channel) { public IDSUValueSaveData getSaveDataForWorld(World world, String channel)
if (worldData.containsKey(world)) { {
if (worldData.containsKey(world))
{
return worldData.get(world).getSaves(channel); return worldData.get(world).getSaves(channel);
} else { } else
{
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world); IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
worldData.put(world, worldSaveData); worldData.put(world, worldSaveData);
worldSaveData.load(); worldSaveData.load();
@ -68,10 +82,13 @@ public class IDSUManager {
} }
} }
public IDSUWorldSaveData getWorldDataFormWorld(World world) { public IDSUWorldSaveData getWorldDataFormWorld(World world)
if (worldData.containsKey(world)) { {
if (worldData.containsKey(world))
{
return worldData.get(world); return worldData.get(world);
} else { } else
{
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world); IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
worldData.put(world, worldSaveData); worldData.put(world, worldSaveData);
worldSaveData.load(); worldSaveData.load();
@ -79,25 +96,31 @@ public class IDSUManager {
} }
} }
public void loadFromString(String json, World world) { public void loadFromString(String json, World world)
if (json.equals("EMPTY")) { {
if (json.equals("EMPTY"))
{
return; return;
} }
IDSUWorldSaveData worldSaveData; IDSUWorldSaveData worldSaveData;
if (worldData.containsKey(world)) { if (worldData.containsKey(world))
{
worldSaveData = worldData.get(world); worldSaveData = worldData.get(world);
} else { } else
{
worldSaveData = new IDSUWorldSaveData(world); worldSaveData = new IDSUWorldSaveData(world);
worldData.put(world, worldSaveData); worldData.put(world, worldSaveData);
} }
Gson gson = new Gson(); Gson gson = new Gson();
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() { Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>()
{
}.getType(); }.getType();
worldSaveData.idsuValues.clear(); worldSaveData.idsuValues.clear();
worldSaveData.idsuValues = gson.fromJson(json, typeOfHashMap); worldSaveData.idsuValues = gson.fromJson(json, typeOfHashMap);
} }
public class IDSUWorldSaveData { public class IDSUWorldSaveData
{
public TreeMap<String, IDSUValueSaveData> idsuValues = new TreeMap<>(); public TreeMap<String, IDSUValueSaveData> idsuValues = new TreeMap<>();
@ -109,90 +132,114 @@ public class IDSUManager {
File file; File file;
public IDSUWorldSaveData(World world) { public IDSUWorldSaveData(World world)
{
this.world = world; this.world = world;
this.saveHandler = world.getSaveHandler(); this.saveHandler = world.getSaveHandler();
folder = new File(saveHandler.getWorldDirectory(), "idsuData"); folder = new File(saveHandler.getWorldDirectory(), "idsuData");
file = new File(folder, savename); file = new File(folder, savename);
} }
public IDSUValueSaveData getSaves(String udid) { public IDSUValueSaveData getSaves(String udid)
if (udid == null) { {
if (udid == null)
{
return null; return null;
} }
if (idsuValues.containsKey(udid)) { if (idsuValues.containsKey(udid))
{
return idsuValues.get(udid); return idsuValues.get(udid);
} else { } else
{
IDSUValueSaveData data = new IDSUValueSaveData(); IDSUValueSaveData data = new IDSUValueSaveData();
idsuValues.put(udid, data); idsuValues.put(udid, data);
return data; return data;
} }
} }
public void load() { public void load()
if (!file.exists()) { {
if (!file.exists())
{
return; return;
} }
try { try
{
Gson gson = new Gson(); Gson gson = new Gson();
BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));
Type typeOfHashMap = new TypeToken<TreeMap<String, IDSUValueSaveData>>() { Type typeOfHashMap = new TypeToken<TreeMap<String, IDSUValueSaveData>>()
{
}.getType(); }.getType();
idsuValues.clear(); idsuValues.clear();
idsuValues = gson.fromJson(reader, typeOfHashMap); idsuValues = gson.fromJson(reader, typeOfHashMap);
} catch (Exception e) { } catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
public void save() { public void save()
if (idsuValues.isEmpty()) { {
if (idsuValues.isEmpty())
{
return; return;
} }
if (!file.exists()) { if (!file.exists())
if (!folder.exists()) { {
if (!folder.exists())
{
folder.mkdirs(); folder.mkdirs();
} }
try { try
{
file.createNewFile(); file.createNewFile();
} catch (IOException e) { } catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(idsuValues); String json = gson.toJson(idsuValues);
try { try
{
FileWriter writer = new FileWriter(file); FileWriter writer = new FileWriter(file);
writer.write(json); writer.write(json);
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public class IDSUValueSaveData { public class IDSUValueSaveData
{
public double storedPower = 0; public double storedPower = 0;
public IDSUValueSaveData(double storedPower) { public IDSUValueSaveData(double storedPower)
{
this.storedPower = storedPower; this.storedPower = storedPower;
} }
public IDSUValueSaveData() { public IDSUValueSaveData()
{
} }
public double getStoredPower() { public double getStoredPower()
{
return storedPower; return storedPower;
} }
public void setStoredPower(double storedPower) { public void setStoredPower(double storedPower)
{
this.storedPower = storedPower; this.storedPower = storedPower;
} }
public void addEnergy(double storedPower) { public void addEnergy(double storedPower)
{
this.storedPower += storedPower; this.storedPower += storedPower;
} }
} }

View file

@ -1,19 +1,19 @@
package techreborn.tiles.idsu; package techreborn.tiles.idsu;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable { public class TileIDSU extends TilePowerAcceptor implements IWrenchable
{
public String ownerUdid; public String ownerUdid;
public int tier; public int tier;
@ -23,67 +23,111 @@ public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
private double euChange; private double euChange;
private int ticks; private int ticks;
public TileIDSU(int tier1, int output1, int maxStorage1) { public TileIDSU(int tier1, int output1, int maxStorage1)
{
super(tier1);
this.tier = tier1; this.tier = tier1;
this.output = output1; this.output = output1;
this.maxStorage = maxStorage1; this.maxStorage = maxStorage1;
} }
public TileIDSU() { public TileIDSU()
{
this(5, 2048, 100000000); this(5, 2048, 100000000);
} }
@Override @Override
public double getEnergy() { public double getEnergy()
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) { {
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
{
return 0.0; return 0.0;
} }
return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower; return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower;
} }
@Override @Override
public void setEnergy(double energy) { public void setEnergy(double energy)
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) { {
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
{
return; return;
} }
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower = energy; IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower = energy;
} }
@Override @Override
public double getMaxPower() { public void readFromNBTWithoutCoords(NBTTagCompound tag)
{
}
@Override
public double getMaxPower()
{
return 1000000000; return 1000000000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.INSANE; {
return getFacingEnum() != direction;
} }
public float getChargeLevel() { @Override
public boolean canProvideEnergy(EnumFacing direction)
{
return getFacingEnum() == direction;
}
@Override
public double getMaxOutput()
{
return output;
}
@Override
public double getMaxInput()
{
return maxStorage;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
}
public float getChargeLevel()
{
float ret = (float) this.getEnergy() / (float) this.maxStorage; float ret = (float) this.getEnergy() / (float) this.maxStorage;
if (ret > 1.0F) { if (ret > 1.0F)
{
ret = 1.0F; ret = 1.0F;
} }
return ret; return ret;
} }
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbttagcompound)
{
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
this.ownerUdid = nbttagcompound.getString("ownerUdid"); this.ownerUdid = nbttagcompound.getString("ownerUdid");
} }
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
{
super.writeToNBT(nbttagcompound); super.writeToNBT(nbttagcompound);
if (ownerUdid == null || StringUtils.isEmpty(ownerUdid)) { if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
{
return nbttagcompound; return nbttagcompound;
} }
nbttagcompound.setString("ownerUdid", this.ownerUdid); nbttagcompound.setString("ownerUdid", this.ownerUdid);
return nbttagcompound; return nbttagcompound;
} }
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (ticks == ConfigTechReborn.AverageEuOutTickTime) { if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
euChange = -1; euChange = -1;
@ -101,55 +145,38 @@ public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
if (!worldObj.isRemote && getEnergy() > 0) { if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy(); double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) { useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
} }
} }
//TODO move to RebornCore public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
return false; return false;
} }
@Override @Override public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1)
public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1) { {
return true; return true;
} }
@Override @Override public EnumFacing getFacing()
public EnumFacing getFacing() { {
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override public boolean wrenchCanRemove(EntityPlayer p0)
public boolean wrenchCanRemove(EntityPlayer p0) { {
return true; return true;
} }
@Override @Override public float getWrenchDropRate()
public float getWrenchDropRate() { {
return 1.0F; return 1.0F;
} }
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
NBTTagCompound tileEntity = new NBTTagCompound(); NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(ModBlocks.Idsu, 1); ItemStack dropStack = new ItemStack(ModBlocks.Idsu, 1);
writeToNBT(tileEntity); writeToNBT(tileEntity);
@ -158,32 +185,40 @@ public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
return dropStack; return dropStack;
} }
public double getEuChange() { public double getEuChange()
if (euChange == -1) { {
if (euChange == -1)
{
return -1; return -1;
} }
return (euChange / ticks); return (euChange / ticks);
} }
public void handleGuiInputFromClient(int id) { public void handleGuiInputFromClient(int id)
if (id == 0) { {
if (id == 0)
{
output += 256; output += 256;
} }
if (id == 1) { if (id == 1)
{
output += 64; output += 64;
} }
if (id == 2) { if (id == 2)
{
output -= 64; output -= 64;
} }
if (id == 3) { if (id == 3)
{
output -= 256; output -= 256;
} }
if (output > 4096) { if (output > 4096)
{
output = 4096; output = 4096;
} }
if (output <= -1) { if (output <= -1)
{
output = 0; output = 0;
} }
} }
} }

View file

@ -3,14 +3,15 @@ package techreborn.tiles.lesu;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerAcceptorProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
import java.util.ArrayList; import java.util.ArrayList;
public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench public class TileLesu extends TilePowerAcceptor
{// TODO wrench
public int connectedBlocks = 0; public int connectedBlocks = 0;
public Inventory inventory = new Inventory(2, "TileAesu", 64, this); public Inventory inventory = new Inventory(2, "TileAesu", 64, this);
@ -21,10 +22,14 @@ public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
private int output; private int output;
private int maxStorage; private int maxStorage;
public TileLesu()
{
super(5);
}
@Override @Override
public void update() { public void updateEntity() {
super.update(); super.updateEntity();
if (worldObj.isRemote) { if (worldObj.isRemote) {
return; return;
} }
@ -72,44 +77,53 @@ public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
if (!worldObj.isRemote && getEnergy() > 0) { if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy(); double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) { useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
} }
} }
//TODO move to RebornCore public double getEuChange()
public double emitEnergy(EnumFacing enumFacing, double amount) { {
BlockPos pos = getPos().offset(enumFacing); if (euChange == -1)
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver( {
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
public double getEuChange() {
if (euChange == -1) {
return 0; return 0;
} }
return (euChange / ticks); return (euChange / ticks);
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return maxStorage; return maxStorage;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.INSANE; {
return direction != getFacingEnum();
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return direction == getFacingEnum();
}
@Override
public double getMaxOutput()
{
return output;
}
@Override
public double getMaxInput()
{
return 8192;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
} }
} }

View file

@ -15,8 +15,8 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location; import reborncore.common.misc.Location;
import reborncore.common.multiblock.IMultiblockPart; import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler; import techreborn.api.recipe.ITileRecipeHandler;
@ -26,7 +26,8 @@ import techreborn.init.ModBlocks;
import techreborn.multiblocks.MultiBlockCasing; import techreborn.multiblocks.MultiBlockCasing;
import techreborn.tiles.TileMachineCasing; import techreborn.tiles.TileMachineCasing;
public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider { public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider
{
public static int euTick = 5; public static int euTick = 5;
public int tickTime; public int tickTime;
@ -34,7 +35,9 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
public RecipeCrafter crafter; public RecipeCrafter crafter;
public int capacity = 1000; public int capacity = 1000;
public TileBlastFurnace() { public TileBlastFurnace()
{
super(ConfigTechReborn.CentrifugeTier);
// TODO configs // TODO configs
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -46,53 +49,65 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.BlastFurnace, 1); return new ItemStack(ModBlocks.BlastFurnace, 1);
} }
public int getHeat() { public int getHeat()
for (EnumFacing direction : EnumFacing.values()) { {
for (EnumFacing direction : EnumFacing.values())
{
TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())); getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
if (tileEntity instanceof TileMachineCasing) { if (tileEntity instanceof TileMachineCasing)
{
if (((TileMachineCasing) tileEntity).isConnected() if (((TileMachineCasing) tileEntity).isConnected()
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) { && ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled())
{
MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController(); MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController();
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction); Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
location.modifyPositionFromSide(direction, 1); location.modifyPositionFromSide(direction, 1);
int heat = 0; int heat = 0;
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ())) if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
.getBlock() == tileEntity.getBlockType()) { .getBlock() == tileEntity.getBlockType())
{
return 0; return 0;
} }
for (IMultiblockPart part : casing.connectedParts) { for (IMultiblockPart part : casing.connectedParts)
{
BlockMachineCasing casing1 = (BlockMachineCasing) worldObj.getBlockState(part.getPos()) BlockMachineCasing casing1 = (BlockMachineCasing) worldObj.getBlockState(part.getPos())
.getBlock(); .getBlock();
heat += casing1 heat += casing1
@ -103,8 +118,9 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ())) if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava") .getBlock().getUnlocalizedName().equals("tile.lava")
&& worldObj && worldObj
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ())) .getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava")) { .getBlock().getUnlocalizedName().equals("tile.lava"))
{
heat += 500; heat += 500;
} }
return heat; return heat;
@ -115,29 +131,34 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
{
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
getPos().getY(), getPos().getZ()); getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tickTime = tagCompound.getInteger("tickTime"); tickTime = tagCompound.getInteger("tickTime");
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
writeUpdateToNBT(tagCompound); writeUpdateToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
public void writeUpdateToNBT(NBTTagCompound tagCompound) { public void writeUpdateToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("tickTime", tickTime); tagCompound.setInteger("tickTime", tickTime);
} }
<<<<<<< HEAD:src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side) {
return new int[] {0, 1, 2, 3}; return new int[] {0, 1, 2, 3};
@ -152,21 +173,71 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
return index == 2 || index == 3; return index == 2 || index == 3;
} }
=======
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
}
public int getProgressScaled(int scale) { @Override
if (crafter.currentTickTime != 0) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex >= 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2 || slotIndex == 3;
}
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.:src/main/java/techreborn/tiles/TileBlastFurnace.java
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 512000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.HIGH; return EnumPowerTier.HIGH;
} }

View file

@ -10,8 +10,8 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -26,6 +26,7 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileImplosionCompressor() { public TileImplosionCompressor() {
super(2);
int[] inputs = new int[]{0, 1}; int[] inputs = new int[]{0, 1};
int[] outputs = new int[]{2, 3}; int[] outputs = new int[]{2, 3};
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs); crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
@ -117,6 +118,26 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
return 64000; return 64000;
} }
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 64;
}
@Override @Override
public EnumPowerTier getTier() { public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM; return EnumPowerTier.MEDIUM;

View file

@ -14,14 +14,15 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler; import techreborn.api.recipe.ITileRecipeHandler;
import techreborn.api.recipe.machines.IndustrialGrinderRecipe; import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModFluids; import techreborn.init.ModFluids;
@ -35,33 +36,49 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
public RecipeCrafter crafter; public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker; public MultiblockChecker multiblockChecker;
public TileIndustrialGrinder() { public TileIndustrialGrinder()
int[] inputs = new int[] {0}; {
int[] outputs = new int[] {2, 3, 4, 5}; super(ConfigTechReborn.CentrifugeTier);
// TODO configs
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[4];
outputs[0] = 2;
outputs[1] = 3;
outputs[2] = 4;
outputs[3] = 5;
crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, inventory, inputs, outputs); crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, inventory, inputs, outputs);
} }
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
return true;
}
@Override @Override
public EnumFacing getFacing() { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.IndustrialGrinder, 1); return new ItemStack(ModBlocks.IndustrialGrinder, 1);
} }
@ -90,24 +107,41 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override
public void invalidate()
{
super.invalidate();
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
}
/* IFluidHandler */ /* IFluidHandler */
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) { public int fill(EnumFacing from, FluidStack resource, boolean doFill)
if (resource != null && canFill(from, resource.getFluid())) { {
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate)
{
int filled = tank.fill(resource, doFill); int filled = tank.fill(resource, doFill);
tank.compareAndUpdate(); tank.compareAndUpdate();
return filled; return filled;
@ -116,8 +150,10 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
} }
@Override @Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
if (resource == null || !resource.isFluidEqual(tank.getFluid())) { {
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
{
return null; return null;
} }
FluidStack fluidStack = tank.drain(resource.amount, doDrain); FluidStack fluidStack = tank.drain(resource.amount, doDrain);
@ -126,57 +162,95 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
} }
@Override @Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
FluidStack drained = tank.drain(maxDrain, doDrain); FluidStack drained = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate(); tank.compareAndUpdate();
return drained; return drained;
} }
@Override @Override
public boolean canFill(EnumFacing from, Fluid fluid) { public boolean canFill(EnumFacing from, Fluid fluid)
{
return fluid == FluidRegistry.WATER || fluid == ModFluids.fluidMercury || fluid == ModFluids.fluidSodiumpersulfate; return fluid == FluidRegistry.WATER || fluid == ModFluids.fluidMercury || fluid == ModFluids.fluidSodiumpersulfate;
} }
@Override @Override
public boolean canDrain(EnumFacing from, Fluid fluid) { public boolean canDrain(EnumFacing from, Fluid fluid)
{
return false; return false;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(EnumFacing from) { public FluidTankInfo[] getTankInfo(EnumFacing from)
return new FluidTankInfo[]{tank.getInfo()}; {
return new FluidTankInfo[] { tank.getInfo() };
} }
@Override // ISidedInventory
public int[] getSlotsForFace(EnumFacing side) { @Override
return new int[] {0, 2, 3}; public int[] getSlotsForFace(EnumFacing side)
} {
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
}
@Override @Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
return index == 0; {
} if (slotIndex >= 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override @Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
return index == 2 || index == 3; {
} return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
}
public int getProgressScaled(int scale) { public int getProgressScaled(int scale)
if (crafter.currentTickTime != 0) { {
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
return 64000; {
return 10000;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
return EnumPowerTier.MEDIUM; {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
} }
@ -229,6 +303,4 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
return crafter; return crafter;
} }
} }

View file

@ -15,7 +15,6 @@ import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;

View file

@ -9,8 +9,8 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;

View file

@ -1,8 +1,11 @@
package techreborn.tiles.storage; package techreborn.tiles.storage;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import java.util.List;
/** /**
* Created by modmuss50 on 14/03/2016. * Created by modmuss50 on 14/03/2016.
*/ */

View file

@ -1,18 +1,17 @@
package techreborn.tiles.storage; package techreborn.tiles.storage;
import reborncore.api.IListInfoProvider;
import reborncore.common.IWrenchable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyItemInfo; import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.PoweredItem; import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.tile.TilePowerAcceptorProducer; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.blocks.storage.BlockEnergyStorage; import techreborn.blocks.storage.BlockEnergyStorage;
import techreborn.power.EnergyUtils; import techreborn.power.EnergyUtils;
@ -22,7 +21,7 @@ import java.util.List;
/** /**
* Created by Rushmead * Created by Rushmead
*/ */
public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider { public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
public Inventory inventory; public Inventory inventory;
public String name; public String name;
@ -33,6 +32,7 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
public int maxStorage; public int maxStorage;
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) { public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
super(1);
inventory = new Inventory(invSize, "Tile" + name, 64, this); inventory = new Inventory(invSize, "Tile" + name, 64, this);
this.wrenchDrop = wrenchDrop; this.wrenchDrop = wrenchDrop;
this.tier = tier; this.tier = tier;
@ -64,8 +64,7 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
} }
@Override @Override
public void update() { public void updateEntity() {
super.update();
if (inventory.getStackInSlot(0) != null) { if (inventory.getStackInSlot(0) != null) {
ItemStack stack = inventory.getStackInSlot(0); ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) { if (!(stack.getItem() instanceof IEnergyItemInfo)) {
@ -93,33 +92,13 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
} }
} }
if (!worldObj.isRemote && getEnergy() > 0) { if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy(); double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) { useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
} }
} }
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
@Override @Override
public void setFacing(EnumFacing enumFacing) { public void setFacing(EnumFacing enumFacing) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing)); worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
@ -140,6 +119,12 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
return maxStorage; return maxStorage;
} }
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return getFacingEnum() != direction;
}
@Override @Override
public EnumFacing getFacingEnum() { public EnumFacing getFacingEnum() {
Block block = worldObj.getBlockState(pos).getBlock(); Block block = worldObj.getBlockState(pos).getBlock();
@ -149,6 +134,21 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
return null; return null;
} }
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return getFacing() == direction;
}
@Override
public double getMaxOutput() {
return maxOutput;
}
@Override
public double getMaxInput() {
return maxInput;
}
@Override @Override
public EnumPowerTier getTier() { public EnumPowerTier getTier() {
return tier; return tier;

View file

@ -8,14 +8,15 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler; import techreborn.utils.upgrade.UpgradeHandler;
public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory { public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory
{
public Inventory inventory = new Inventory(6, "TileCompressor", 64, this); public Inventory inventory = new Inventory(6, "TileCompressor", 64, this);
@ -24,7 +25,9 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
public int capacity = 1000; public int capacity = 1000;
public TileCompressor() { public TileCompressor()
{
super(1);
int[] inputs = new int[1]; int[] inputs = new int[1];
inputs[0] = 0; inputs[0] = 0;
int[] outputs = new int[1]; int[] outputs = new int[1];
@ -38,67 +41,108 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
super.update(); super.update();
crafter.updateEntity(); crafter.updateEntity();
upgradeHandler.tick(); upgradeHandler.tick();
//charge(3); TODO charge(3);
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Compressor, 1); return new ItemStack(ModBlocks.Compressor, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override
public int[] getSlotsForFace(EnumFacing side) {
return new int[] {0, 1};
}
@Override // ISidedInventory
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { @Override
return index == 0; public int[] getSlotsForFace(EnumFacing side)
} {
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
}
@Override @Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
return index == 1; {
} if (slotIndex == 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
public int getProgressScaled(int scale) { @Override
if (crafter.currentTickTime != 0) { public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2;
}
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return capacity; return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }

View file

@ -1,6 +1,10 @@
package techreborn.tiles.teir1; package techreborn.tiles.teir1;
<<<<<<< HEAD
import ic2.core.upgrade.IUpgradeItem; import ic2.core.upgrade.IUpgradeItem;
=======
import reborncore.common.IWrenchable;
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -9,82 +13,112 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
<<<<<<< HEAD
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.tile.TilePowerAcceptor;
=======
import reborncore.common.powerSystem.TilePowerAcceptor;
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler; import techreborn.utils.upgrade.UpgradeHandler;
public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory { public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
{
public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this); public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this);
public int capacity = 1000;
public int progress; public int progress;
public int fuelScale = 100; public int fuelScale = 100;
public int cost = 8; public int cost = 8;
int input1 = 0; int input1 = 0;
int output = 1; int output = 1;
private static final int[] SLOTS_TOP = new int[]{0}; private static final int[] SLOTS_TOP = new int[] {0};
private static final int[] SLOTS_BOTTOM = new int[]{1}; private static final int[] SLOTS_BOTTOM = new int[] {1};
private static final int[] SLOTS_SIDES = new int[]{1}; private static final int[] SLOTS_SIDES = new int[] {1};
public int gaugeProgressScaled(int scale) { public TileElectricFurnace()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
return (progress * scale) / fuelScale; return (progress * scale) / fuelScale;
} }
@Override @Override
<<<<<<< HEAD
public void update() { public void update() {
super.update(); super.update();
//charge(3); TODO //charge(3); TODO
=======
public void updateEntity()
{
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
boolean burning = isBurning(); boolean burning = isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (isBurning() && canSmelt()) { if (isBurning() && canSmelt())
{
updateState(); updateState();
progress++; progress++;
if (progress % 10 == 0) { if(progress % 10 == 0){
useEnergy(cost); useEnergy(cost);
} }
if (progress >= fuelScale) { if (progress >= fuelScale)
{
progress = 0; progress = 0;
cookItems(); cookItems();
updateInventory = true; updateInventory = true;
} }
} else { } else
{
progress = 0; progress = 0;
updateState(); updateState();
} }
if (burning != isBurning()) { if (burning != isBurning())
{
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory)
{
markDirty(); markDirty();
} }
} }
public void cookItems() { public void cookItems()
if (this.canSmelt()) { {
if (this.canSmelt())
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == null)
{
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack))
{
getStackInSlot(output).stackSize += itemstack.stackSize; getStackInSlot(output).stackSize += itemstack.stackSize;
} }
if (getStackInSlot(input1).stackSize > 1) { if (getStackInSlot(input1).stackSize > 1)
{
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else
{
setInventorySlotContents(input1, null); setInventorySlotContents(input1, null);
} }
} }
} }
public boolean canSmelt() { public boolean canSmelt()
if (getStackInSlot(input1) == null) { {
if (getStackInSlot(input1) == null)
{
return false; return false;
} else { } else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack == null) if (itemstack == null)
return false; return false;
@ -97,21 +131,26 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
} }
} }
public boolean isBurning() { public boolean isBurning()
{
return getEnergy() > cost; return getEnergy() > cost;
} }
public ItemStack getResultFor(ItemStack stack) { public ItemStack getResultFor(ItemStack stack)
{
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != null) { if (result != null)
{
return result.copy(); return result.copy();
} }
return null; return null;
} }
public void updateState() { public void updateState()
{
IBlockState BlockStateContainer = worldObj.getBlockState(pos); IBlockState BlockStateContainer = worldObj.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, worldObj, pos); blockMachineBase.setActive(progress > 0, worldObj, pos);
@ -119,35 +158,42 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.ElectricFurnace, 1); return new ItemStack(ModBlocks.ElectricFurnace, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
// ISidedInventory // ISidedInventory
<<<<<<< HEAD
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side) {
return new int[] {0, 1}; return new int[] {0, 1};
@ -162,14 +208,61 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
return index == 1; return index == 1;
} }
=======
@Override @Override
public double getMaxPower() { public int[] getSlotsForFace(EnumFacing side)
return 16000; {
return side == EnumFacing.DOWN ? SLOTS_BOTTOM : (side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES);
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex == 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2;
}
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
@Override
public double getMaxPower()
{
return capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }

View file

@ -1,6 +1,10 @@
package techreborn.tiles.teir1; package techreborn.tiles.teir1;
import reborncore.common.IWrenchable;
import reborncore.common.container.RebornContainer;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -8,17 +12,17 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider; import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.container.RebornContainer;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.client.container.ContainerExtractor; import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler; import techreborn.utils.upgrade.UpgradeHandler;
public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider
{
public Inventory inventory = new Inventory(6, "TileExtractor", 64, this); public Inventory inventory = new Inventory(6, "TileExtractor", 64, this);
@ -27,7 +31,9 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
public int capacity = 1000; public int capacity = 1000;
public TileExtractor() { public TileExtractor()
{
super(1);
int[] inputs = new int[1]; int[] inputs = new int[1];
inputs[0] = 0; inputs[0] = 0;
int[] outputs = new int[1]; int[] outputs = new int[1];
@ -37,68 +43,114 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
} }
@Override @Override
<<<<<<< HEAD
public void update() { public void update() {
super.update(); super.update();
crafter.updateEntity(); crafter.updateEntity();
upgradeHandler.tick(); upgradeHandler.tick();
//charge(3); TODO //charge(3); TODO
=======
public void updateEntity()
{
super.updateEntity();
crafter.updateEntity();
// upgrades.tick();
charge(3);
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Extractor, 1); return new ItemStack(ModBlocks.Extractor, 1);
} }
public boolean isComplete() { public boolean isComplete()
{
return false; return false;
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
public int getProgressScaled(int scale) { public int getProgressScaled(int scale)
if (crafter.currentTickTime != 0) { {
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return capacity; return capacity;
} }
public EnumPowerTier getTier() { @Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }

View file

@ -3,6 +3,7 @@ package techreborn.tiles.teir1;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -12,17 +13,21 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider; import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer; import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerGrinder; import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler; import techreborn.utils.upgrade.UpgradeHandler;
import java.util.List;
public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider,
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider, ISidedInventory { IListInfoProvider, IRecipeCrafterProvider, IContainerProvider, ISidedInventory {
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this); public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
public UpgradeHandler upgradeHandler; public UpgradeHandler upgradeHandler;
@ -30,7 +35,9 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
public int capacity = 1000; public int capacity = 1000;
public TileGrinder() { public TileGrinder()
{
super(1);
int[] inputs = new int[1]; int[] inputs = new int[1];
inputs[0] = 0; inputs[0] = 0;
int[] outputs = new int[1]; int[] outputs = new int[1];
@ -40,69 +47,116 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
upgradeHandler.tick(); upgradeHandler.tick();
//charge(3); TODO //charge(3); TODO
charge(3);
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Grinder, 1); return new ItemStack(ModBlocks.Grinder, 1);
} }
public boolean isComplete()
{
return false;
}
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
public int getProgressScaled(int scale) { public int getProgressScaled(int scale)
if (crafter.currentTickTime != 0) { {
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks; return crafter.currentTickTime * scale / crafter.currentNeededTicks;
} }
return 0; return 0;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return capacity; return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW; return EnumPowerTier.LOW;
} }
@Override public void addInfo(List<String> info, boolean isRealTile)
{
info.add("Macerator");
}
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;

View file

@ -9,12 +9,13 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.items.ItemParts; import techreborn.items.ItemParts;
public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory { public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
{
public Inventory inventory = new Inventory(6, "TileRecycler", 64, this); public Inventory inventory = new Inventory(6, "TileRecycler", 64, this);
public int capacity = 1000; public int capacity = 1000;
@ -26,91 +27,118 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInve
public int input1 = 0; public int input1 = 0;
public int output = 1; public int output = 1;
public int gaugeProgressScaled(int scale) { public TileRecycler()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
return (progress * scale) / time; return (progress * scale) / time;
} }
@Override @Override
public void update() { public void updateEntity()
super.update(); {
//charge(3); TODO if(worldObj.isRemote){
if (worldObj.isRemote) {
return; return;
} }
boolean burning = isBurning(); boolean burning = isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (getEnergy() <= cost && canRecycle()) { if (getEnergy() <= cost && canRecycle())
if (getEnergy() > cost) { {
if (getEnergy() > cost)
{
updateInventory = true; updateInventory = true;
} }
} }
if (isBurning() && canRecycle()) { if (isBurning() && canRecycle())
{
updateState(); updateState();
progress++; progress++;
if (progress >= time) { if (progress >= time)
{
progress = 0; progress = 0;
recycleItems(); recycleItems();
updateInventory = true; updateInventory = true;
} }
} else { } else
{
progress = 0; progress = 0;
updateState(); updateState();
} }
if (burning != isBurning()) { if (burning != isBurning())
{
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory)
{
markDirty(); markDirty();
} }
} }
public void recycleItems() { public void recycleItems()
if (this.canRecycle()) { {
if (this.canRecycle())
{
ItemStack itemstack = ItemParts.getPartByName("scrap"); ItemStack itemstack = ItemParts.getPartByName("scrap");
int randomchance = worldObj.rand.nextInt(chance); int randomchance = worldObj.rand.nextInt(chance);
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == null)
{
useEnergy(cost); useEnergy(cost);
if (randomchance == 1) { if (randomchance == 1)
{
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} }
} else if (getStackInSlot(output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack))
{
useEnergy(cost); useEnergy(cost);
if (randomchance == 1) { if (randomchance == 1)
{
getStackInSlot(output).stackSize += itemstack.stackSize; getStackInSlot(output).stackSize += itemstack.stackSize;
} }
} }
if (getStackInSlot(input1).stackSize > 1) { if (getStackInSlot(input1).stackSize > 1)
{
useEnergy(cost); useEnergy(cost);
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else
{
useEnergy(cost); useEnergy(cost);
setInventorySlotContents(input1, null); setInventorySlotContents(input1, null);
} }
} }
} }
public boolean canRecycle() { public boolean canRecycle()
{
return getStackInSlot(input1) != null && hasSlotGotSpace(output); return getStackInSlot(input1) != null && hasSlotGotSpace(output);
} }
public boolean hasSlotGotSpace(int slot) { public boolean hasSlotGotSpace(int slot)
if (getStackInSlot(slot) == null) { {
if (getStackInSlot(slot) == null)
{
return true; return true;
} else if (getStackInSlot(slot).stackSize < getStackInSlot(slot).getMaxStackSize()) { } else if (getStackInSlot(slot).stackSize < getStackInSlot(slot).getMaxStackSize())
{
return true; return true;
} }
return true; return true;
} }
public boolean isBurning() { public boolean isBurning()
{
return getEnergy() > cost; return getEnergy() > cost;
} }
public void updateState() { public void updateState()
{
IBlockState BlockStateContainer = worldObj.getBlockState(pos); IBlockState BlockStateContainer = worldObj.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, worldObj, pos); blockMachineBase.setActive(progress > 0, worldObj, pos);
@ -118,53 +146,94 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInve
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing()
{
return getFacingEnum(); return getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate()
{
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.recycler, 1); return new ItemStack(ModBlocks.recycler, 1);
} }
public boolean isComplete()
{
return false;
}
// ISidedInventory // ISidedInventory
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side)
return new int[] {input1, output}; {
return side == EnumFacing.DOWN ? new int[] { output } : new int[] { input1 };
} }
@Override @Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
return slotIndex == input1; {
if (slotIndex == output)
return false;
return isItemValidForSlot(slotIndex, itemStack);
} }
@Override @Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == output; return slotIndex == output;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower()
{
return capacity; return capacity;
} }
@Override @Override
public EnumPowerTier getTier() { public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM; return EnumPowerTier.MEDIUM;
} }

View file

@ -12,11 +12,7 @@ import techreborn.blocks.transformers.BlockTransformer;
/** /**
* Created by Rushmead * Created by Rushmead
*
* @deprecated ? If wires limited to transfer rate and doesn't burn out, what's use of the transformers?
* TODO: Rewrite, find use or remove
*/ */
@Deprecated
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable
{ {

View file

@ -4,16 +4,16 @@
"transform":"forge:default-block", "transform":"forge:default-block",
"model":"orientable", "model":"orientable",
"textures":{ "textures":{
"particle":"techreborn:blocks/machine/advanced_machines/advanced_machine_side", "particle":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"top":"techreborn:blocks/machine/advanced_machines/machine_top", "top":"techreborn:blocks/machine/advanced_machines/machine_top",
"side":"techreborn:blocks/machine/advanced_machines/advanced_machine_side" "side":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
} }
}, },
"variants":{ "variants":{
"inventory":{ "inventory":{
"transform":"forge:default-block", "transform":"forge:default-block",
"textures":{ "textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side" "front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
} }
}, },
"facing":{ "facing":{
@ -33,22 +33,22 @@
"active":{ "active":{
"true":{ "true":{
"textures":{ "textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side" "front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_on"
} }
}, },
"false":{ "false":{
"textures":{ "textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side" "front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
} }
} }
}, },
"inventory": { "inventory": {
"model": "orientable", "model": "orientable",
"textures": { "textures": {
"particle": "techreborn:blocks/machine/advanced_machines/advanced_machine_side", "particle": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"top": "techreborn:blocks/machine/advanced_machines/machine_top", "top": "techreborn:blocks/machine/advanced_machines/machine_top",
"side": "techreborn:blocks/machine/advanced_machines/advanced_machine_side", "side": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"front": "techreborn:blocks/machine/advanced_machines/advanced_machine_side" "front": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
} }
} }
} }

View file

@ -5,7 +5,7 @@
"model":"orientable", "model":"orientable",
"textures":{ "textures":{
"particle": "techreborn:blocks/machine/generators/lightning_rod_side_off", "particle": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"top": "techreborn:blocks/machine/generators/gas_generator_top", "top": "techreborn:blocks/machine/generators/lightning_rod_top",
"side": "techreborn:blocks/machine/generators/lightning_rod_side_off", "side": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off", "down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front" "front":"techreborn:blocks/machine/generators/plasma_generator_front"
@ -44,7 +44,7 @@
"model": "orientable", "model": "orientable",
"textures": { "textures": {
"particle": "techreborn:blocks/machine/generators/lightning_rod_side_off", "particle": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"top": "techreborn:blocks/machine/generators/gas_generator_top", "top": "techreborn:blocks/machine/generators/lightning_rod_top",
"side": "techreborn:blocks/machine/generators/lightning_rod_side_off", "side": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off", "down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front" "front":"techreborn:blocks/machine/generators/plasma_generator_front"

View file

@ -1,6 +1,6 @@
{ {
"parent": "techreborn:item/techrebornItem", "parent": "techreborn:item/techrebornItem",
"textures": { "textures": {
"layer0": "techreborn:items/tool/energyCrystal" "layer0": "techreborn:items/tool/energyCrystalEmpty"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"parent": "techreborn:item/techrebornItem", "parent": "techreborn:item/techrebornItem",
"textures": { "textures": {
"layer0": "techreborn:items/tool/lapotronCrystal" "layer0": "techreborn:items/tool/lapotronCrystalEmpty"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B