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;
}
event.getToolTip().add(color + ""
+ PowerSystem.getLocalizedPower(
+ PowerSystem.getLocaliszedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getEnergy(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " stored");
event.getToolTip().add(Color.GREEN + ""
+ PowerSystem.getLocalizedPower(
+ PowerSystem.getLocaliszedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxPower(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " max");
event.getToolTip()
.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()))
+ TextFormatting.LIGHT_PURPLE + " /tick in/out");
}

View file

@ -14,7 +14,7 @@ public class ContainerIndustrialGrinder extends ContainerCrafting {
TileIndustrialGrinder tile;
public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player) {
super(tileGrinder.crafter);
super(tileGrinder.getRecipeCrafter());
tile = tileGrinder;
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,
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());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.storedEu) + " ", 10, 30,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerAesu.storedEu) + " ", 10, 30,
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());
}

View file

@ -42,13 +42,15 @@ public class GuiAlloySmelter extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = alloysmelter.getProgressScaled(24);
if (j > 0) {
int j = 0;
j = alloysmelter.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
}
j = (int)(alloysmelter.getEnergy() * 24f / alloysmelter.getMaxPower());
j = alloysmelter.getEnergyScaled(12);
if (j > 0)
{
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;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = assemblingmachine.getProgressScaled(20);
if (j > 0) {
int j = 0;
j = assemblingmachine.getProgressScaled(20);
if (j > 0)
{
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)
{
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;
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)
{
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.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);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752);
}
}

View file

@ -78,15 +78,17 @@ public class GuiBlastFurnace extends GuiContainer
l + 52 + 12 - 0, -1);
}
int j = 0;
this.mc.getTextureManager().bindTexture(texture);
int j = blastfurnace.getProgressScaled(24);
j = blastfurnace.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16);
}
j = (int)(blastfurnace.getEnergy() * 12f / blastfurnace.getMaxPower());
if (j > 0) {
j = blastfurnace.getEnergyScaled(12);
if (j > 0)
{
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;
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)
{
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);
}
j = (int)(centrifuge.getEnergy() * 12f / centrifuge.getMaxPower());
if (j > 0) {
j = centrifuge.getEnergyScaled(12);
if (j > 0)
{
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;
j = (int)(chargebench.getEnergy() * 12f / chargebench.getMaxPower());
if (j > 0) {
j = chargebench.getEnergyScaled(12);
if (j > 0)
{
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);
}
j = (int)(chemicalReactor.getEnergy() * 12f / chemicalReactor.getMaxPower());
if (j > 0) {
j = chemicalReactor.getEnergyScaled(12);
if (j > 0)
{
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;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = compressor.getProgressScaled(24);
if (j > 0) {
int j = 0;
j = compressor.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = (int)(compressor.getEnergy() * 12f / compressor.getMaxPower());
if (j > 0) {
j = compressor.getEnergyScaled(12);
if (j > 0)
{
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_)

View file

@ -49,7 +49,7 @@ public class GuiDieselGenerator extends GuiContainer
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 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);
}
}

View file

@ -34,16 +34,19 @@ public class GuiElectricFurnace extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = furnace.gaugeProgressScaled(24);
if (j > 0) {
int j = 0;
j = furnace.gaugeProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16);
}
j = (int)(furnace.getEnergy() * 12f / furnace.getMaxPower());
if (j > 0) {
j = furnace.getEnergyScaled(12);
if (j > 0)
{
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_)

View file

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

View file

@ -43,8 +43,9 @@ public class GuiGrinder extends GuiContainer
this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16);
}
j = (int)(grinder.getEnergy() * 12f / grinder.getMaxPower());
if (j > 0) {
j = grinder.getEnergyScaled(12);
if (j > 0)
{
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,
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());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.storedEu), 10, 32,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.storedEu), 10, 32,
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());
}

View file

@ -50,11 +50,12 @@ public class GuiImplosionCompressor extends GuiContainer {
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
}
j = (int) (compresser.getEnergy() * 12f / compresser.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
j = compresser.getEnergyScaled(12);
if (j > 0)
{
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_) {
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);
}
j = (int)(eletrolyzer.getEnergy() * 12f / eletrolyzer.getMaxPower());
j = eletrolyzer.getEnergyScaled(12);
if (j > 0)
{
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);
}
}

View file

@ -54,8 +54,15 @@ public class GuiIndustrialSawmill extends GuiContainer
if(!sawmill.tank.isEmpty()) {
drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity());
<<<<<<< HEAD
mc.renderEngine.bindTexture(texture);
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()) {

View file

@ -43,14 +43,14 @@ public class GuiLESU extends GuiContainer
{
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.lesu.name"), 40, 10,
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());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.storedEu), 10, 30,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerLesu.storedEu), 10, 30,
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());
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());
}

View file

@ -45,8 +45,11 @@ public class GuiMFE extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0) {
int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0)
{
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.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);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752);
}
}

View file

@ -45,8 +45,11 @@ public class GuiMFSU extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0) {
int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0)
{
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.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);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752);
}
}

View file

@ -42,7 +42,7 @@ public class GuiRecycler extends GuiContainer
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)
{
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);
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)
{
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);
}
j = (int)(tile.getEnergy() * 12f / tile.getMaxPower());
j = tile.getEnergyScaled(12);
if (j > 0)
{
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);
}
<<<<<<< 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) {
String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");

View file

@ -55,7 +55,8 @@ public class ItemBlockAesu extends ItemBlock
}
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;
}

View file

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

View file

@ -11,7 +11,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.mcmultipart.block.TileMultipartContainer;
@ -27,6 +26,25 @@ import java.util.function.BiFunction;
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)}
@ -156,8 +174,8 @@ public class EnergyUtils {
}
public static PowerNetReceiver getInternalReceiver(TileEntity tileEntity, EnumFacing side) {
if(tileEntity instanceof IEnergyReceiverTile) {
IEnergyReceiverTile energyInterface = (IEnergyReceiverTile) tileEntity;
if(tileEntity instanceof IEnergyInterfaceTile) {
IEnergyInterfaceTile energyInterface = (IEnergyInterfaceTile) tileEntity;
return new PowerNetReceiver(
(energy, simulated) -> {
if(energyInterface.canAcceptEnergy(side))

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -8,13 +7,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
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_STORAGE = ConfigTechReborn.AesuMaxStorage;
@ -24,116 +22,117 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
private double euChange;
private int ticks;
public TileAesu()
{
super(5);
}
@Override
public void update() {
super.update();
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
public void updateEntity()
{
super.updateEntity();
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
{
euChange = -1;
ticks = 0;
} else {
} else
{
ticks++;
euChange += getEnergy() - euLastTick;
if (euLastTick == getEnergy()) {
if (euLastTick == getEnergy())
{
euChange = 0;
}
}
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
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return true;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return getDropWithNBT();
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
public void handleGuiInputFromClient(int id) {
if (id == 0) {
public void handleGuiInputFromClient(int id)
{
if (id == 0)
{
OUTPUT += 256;
}
if (id == 1) {
if (id == 1)
{
OUTPUT += 64;
}
if (id == 2) {
if (id == 2)
{
OUTPUT -= 64;
}
if (id == 3) {
if (id == 3)
{
OUTPUT -= 256;
}
if (OUTPUT > MAX_OUTPUT) {
if (OUTPUT > MAX_OUTPUT)
{
OUTPUT = MAX_OUTPUT;
}
if (OUTPUT <= -1) {
if (OUTPUT <= -1)
{
OUTPUT = 0;
}
}
public double getEuChange() {
if (euChange == -1) {
public double getEuChange()
{
if (euChange == -1)
{
return -1;
}
return (euChange / ticks);
}
public ItemStack getDropWithNBT() {
public ItemStack getDropWithNBT()
{
NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(ModBlocks.Aesu, 1);
writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
return dropStack;
}
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tagCompound.setDouble("euChange", euChange);
tagCompound.setDouble("euLastTick", euLastTick);
@ -142,7 +141,8 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
return tagCompound;
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
public void readFromNBT(NBTTagCompound nbttagcompound)
{
super.readFromNBT(nbttagcompound);
this.euChange = nbttagcompound.getDouble("euChange");
this.euLastTick = nbttagcompound.getDouble("euLastTick");
@ -151,18 +151,38 @@ public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
}
@Override
public double getMaxPower() {
public double getMaxPower()
{
return TileAesu.MAX_STORAGE;
}
@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;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
public double getMaxInput()
{
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.init.ModBlocks;
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider {
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider
{
public int tickTime;
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 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
* furnace burning, or 0 if the item isn't fuel
*/
public static int getItemBurnTime(ItemStack stack) {
if (stack == null) {
public static int getItemBurnTime(ItemStack stack)
{
if (stack == null)
{
return 0;
} else {
} else
{
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);
if (block == Blocks.WOODEN_SLAB) {
if (block == Blocks.WOODEN_SLAB)
{
return 150;
}
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) {
if (block.getMaterial(block.getDefaultState()) == Material.WOOD)
{
return 300;
}
if (block == Blocks.COAL_BLOCK) {
if (block == Blocks.COAL_BLOCK)
{
return 16000;
}
}
@ -81,54 +90,71 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
}
@Override
public void update() {
super.update();
public void updateEntity()
{
super.updateEntity();
boolean flag = this.burnTime > 0;
boolean flag1 = false;
if (this.burnTime > 0) {
if (this.burnTime > 0)
{
--this.burnTime;
}
if (!this.worldObj.isRemote) {
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null) {
if (this.burnTime == 0 && this.canSmelt()) {
if (!this.worldObj.isRemote)
{
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null)
{
if (this.burnTime == 0 && this.canSmelt())
{
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel));
if (this.burnTime > 0) {
if (this.burnTime > 0)
{
flag1 = true;
if (this.getStackInSlot(fuel) != null) {
if (this.getStackInSlot(fuel) != null)
{
decrStackSize(fuel, 1);
}
}
}
if (this.isBurning() && this.canSmelt()) {
if (this.isBurning() && this.canSmelt())
{
++this.cookTime;
if (this.cookTime == 200) {
if (this.cookTime == 200)
{
this.cookTime = 0;
this.smeltItem();
flag1 = true;
}
} else {
} else
{
this.cookTime = 0;
}
}
if (flag != this.burnTime > 0) {
if (flag != this.burnTime > 0)
{
flag1 = true;
// TODO sync on/off
}
}
if (flag1) {
if (flag1)
{
this.markDirty();
}
}
public boolean hasAllInputs(IBaseRecipeType recipeType) {
if (recipeType == null) {
public boolean hasAllInputs(IBaseRecipeType recipeType)
{
if (recipeType == null)
{
return false;
}
for (ItemStack input : recipeType.getInputs()) {
for (ItemStack input : recipeType.getInputs())
{
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,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) {
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize)
{
hasItem = true;
}
}
@ -138,13 +164,18 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
return true;
}
private boolean canSmelt() {
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null) {
private boolean canSmelt()
{
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null)
{
return false;
} else {
} else
{
ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
{
if (hasAllInputs(recipeType))
{
itemstack = recipeType.getOutput(0);
break;
}
@ -158,13 +189,13 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
return false;
int result = getStackInSlot(output).stackSize + itemstack.stackSize;
return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge
// BugFix:
// Make
// it
// respect
// stack
// sizes
// properly.
// BugFix:
// Make
// it
// respect
// stack
// sizes
// 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
* item in the furnace result stack
*/
public void smeltItem() {
if (this.canSmelt()) {
public void smeltItem()
{
if (this.canSmelt())
{
ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
{
if (hasAllInputs(recipeType))
{
itemstack = recipeType.getOutput(0);
break;
}
if (itemstack != null) {
if (itemstack != null)
{
break;
}
}
if (this.getStackInSlot(output) == null) {
if (this.getStackInSlot(output) == null)
{
setInventorySlotContents(output, itemstack.copy());
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) {
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem())
{
decrStackSize(output, -itemstack.stackSize);
}
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
{
boolean hasAllRecipes = true;
if (hasAllInputs(recipeType)) {
if (hasAllInputs(recipeType))
{
} else {
hasAllRecipes = false;
}
if (hasAllRecipes) {
for (ItemStack input : recipeType.getInputs()) {
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
} else
{
hasAllRecipes = false;
}
if (hasAllRecipes)
{
for (ItemStack input : recipeType.getInputs())
{
for (int inputSlot = 0; inputSlot < 2; inputSlot++)
{
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) {
recipeType.useOreDic()))
{
inventory.decrStackSize(inputSlot, input.stackSize);
break;
}
@ -217,48 +262,58 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
/**
* Furnace isBurning
*/
public boolean isBurning() {
public boolean isBurning()
{
return this.burnTime > 0;
}
public int getBurnTimeRemainingScaled(int scale) {
if (this.currentItemBurnTime == 0) {
public int getBurnTimeRemainingScaled(int scale)
{
if (this.currentItemBurnTime == 0)
{
this.currentItemBurnTime = 200;
}
return this.burnTime * scale / this.currentItemBurnTime;
}
public int getCookProgressScaled(int scale) {
public int getCookProgressScaled(int scale)
{
return this.cookTime * scale / 200;
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloyFurnace, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@ -266,6 +321,7 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
public Inventory getInventory() {
return inventory;
}
<<<<<<< HEAD
@Override
public int[] getSlotsForFace(EnumFacing side) {
@ -282,4 +338,6 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
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.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
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 Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this);
public RecipeCrafter crafter;
public int capacity = 1000;
UpgradeHandler upgrades;
public TileAlloySmelter() {
public TileAlloySmelter()
{
super(1);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -35,51 +39,65 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
}
@Override
<<<<<<< HEAD
public void update() {
super.update();
=======
public void updateEntity()
{
super.updateEntity();
>>>>>>> parent of b292fdd... Rewrite to use new RebornCore Power API. Texture fixes.
crafter.updateEntity();
upgrades.tick();
//charge(3); TODO
charge(3);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloySmelter, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
return tagCompound;
@ -95,6 +113,7 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
// }
// }
<<<<<<< HEAD
@Override
public int[] getSlotsForFace(EnumFacing side) {
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) {
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) {
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0) {
@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;
}
>>>>>>> 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 0;
}
@Override
public double getMaxPower() {
return 8000;
public double getMaxPower()
{
return capacity;
}
@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;
}

View file

@ -10,20 +10,23 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerAssemblingMachine;
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 Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this);
public RecipeCrafter crafter;
public TileAssemblingMachine() {
public TileAssemblingMachine()
{
super(2);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -34,52 +37,101 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
}
@Override
public void update() {
super.update();
crafter.updateEntity();
// charge(3);
public void updateEntity()
{
super.updateEntity();
charge(3);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
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 0;
}
@Override
public double getMaxPower() {
return 64000;
public double getMaxPower()
{
return 10000;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
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.LOW;
}
@Override

View file

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

View file

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

View file

@ -9,8 +9,8 @@ import net.minecraft.util.EnumFacing;
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.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
@ -24,6 +24,7 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
public TileChemicalReactor()
{
super(2);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -34,11 +35,11 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
}
@Override
public void update()
public void updateEntity()
{
super.update();
super.updateEntity();
crafter.updateEntity();
//charge(3); TODO
charge(3);
}
@Override
@ -134,7 +135,31 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
@Override
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

View file

@ -6,11 +6,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
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);
@ -19,42 +20,79 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,II
public int euTick = 32;
public TileChunkLoader()
{
super(1);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.ChunkLoader, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public double getMaxPower() {
return 64000;
public double getMaxPower()
{
return 10000;
}
@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;
}

View file

@ -31,9 +31,8 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
public Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this);
@Override
public void update()
public void updateEntity()
{
super.update();
if (!worldObj.isRemote)
{
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.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
@ -24,6 +24,7 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
public TileIndustrialElectrolyzer()
{
super(2);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -37,11 +38,11 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
}
@Override
public void update()
public void updateEntity()
{
super.update();
super.updateEntity();
crafter.updateEntity();
//charge(6); TODO
charge(6);
}
@Override
@ -137,13 +138,37 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
@Override
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
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM;
return EnumPowerTier.LOW;
}
@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.util.Inventory;
public class TileIronFurnace extends TileMachineBase implements IInventoryProvider {
public class TileIronFurnace extends TileMachineBase implements IInventoryProvider
{
public int tickTime;
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
@ -29,14 +30,18 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
int fuelslot = 2;
boolean active = false;
public int gaugeProgressScaled(int scale) {
public int gaugeProgressScaled(int scale)
{
return (progress * scale) / fuelScale;
}
public int gaugeFuelScaled(int scale) {
if (fuelGague == 0) {
public int gaugeFuelScaled(int scale)
{
if (fuelGague == 0)
{
fuelGague = fuel;
if (fuelGague == 0) {
if (fuelGague == 0)
{
fuelGague = fuelScale;
}
}
@ -44,69 +49,88 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
}
@Override
public void update() {
super.update();
public void updateEntity()
{
boolean burning = isBurning();
boolean updateInventory = false;
if (fuel > 0) {
if (fuel > 0)
{
fuel--;
updateState();
}
if (fuel <= 0 && canSmelt()) {
if (fuel <= 0 && canSmelt())
{
fuel = fuelGague = (int) (TileEntityFurnace.getItemBurnTime(getStackInSlot(fuelslot)) * 1.25);
if (fuel > 0) {
if (fuel > 0)
{
if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel
// slot
// slot
{
setInventorySlotContents(fuelslot,
new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
} else if (getStackInSlot(fuelslot).stackSize > 1) {
} else if (getStackInSlot(fuelslot).stackSize > 1)
{
decrStackSize(fuelslot, 1);
} else if (getStackInSlot(fuelslot).stackSize == 1) {
} else if (getStackInSlot(fuelslot).stackSize == 1)
{
setInventorySlotContents(fuelslot, null);
}
updateInventory = true;
}
}
if (isBurning() && canSmelt()) {
if (isBurning() && canSmelt())
{
progress++;
if (progress >= fuelScale) {
if (progress >= fuelScale)
{
progress = 0;
cookItems();
updateInventory = true;
}
} else {
} else
{
progress = 0;
}
if (burning != isBurning()) {
if (burning != isBurning())
{
updateInventory = true;
}
if (updateInventory) {
if (updateInventory)
{
markDirty();
}
}
public void cookItems() {
if (this.canSmelt()) {
public void cookItems()
{
if (this.canSmelt())
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (getStackInSlot(output) == null) {
if (getStackInSlot(output) == null)
{
setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
} else if (getStackInSlot(output).isItemEqual(itemstack))
{
getStackInSlot(output).stackSize += itemstack.stackSize;
}
if (getStackInSlot(input1).stackSize > 1) {
if (getStackInSlot(input1).stackSize > 1)
{
this.decrStackSize(input1, 1);
} else {
} else
{
setInventorySlotContents(input1, null);
}
}
}
public boolean canSmelt() {
if (getStackInSlot(input1) == null) {
public boolean canSmelt()
{
if (getStackInSlot(input1) == null)
{
return false;
} else {
} else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack == null)
return false;
@ -119,21 +143,26 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
}
}
public boolean isBurning() {
public boolean isBurning()
{
return fuel > 0;
}
public ItemStack getResultFor(ItemStack stack) {
public ItemStack getResultFor(ItemStack stack)
{
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != null) {
if (result != null)
{
return result.copy();
}
return null;
}
public void updateState() {
public void updateState()
{
IBlockState BlockStateContainer = worldObj.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != fuel > 0)
blockMachineBase.setActive(fuel > 0, worldObj, pos);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.ScrapboxList;
import techreborn.init.ModBlocks;
@ -17,9 +17,11 @@ import techreborn.init.ModItems;
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 int capacity = 1000;
public int cost = 20;
public int progress;
public int time = 200;
@ -28,71 +30,93 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public int input1 = 0;
public int output = 1;
public int gaugeProgressScaled(int scale) {
public TileScrapboxinator()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
return (progress * scale) / time;
}
@Override
public void update() {
super.update();
public void updateEntity()
{
boolean burning = isBurning();
boolean updateInventory = false;
if (getEnergy() <= cost && canOpen()) {
if (getEnergy() > cost) {
if (getEnergy() <= cost && canOpen())
{
if (getEnergy() > cost)
{
updateInventory = true;
}
}
if (isBurning() && canOpen()) {
if (isBurning() && canOpen())
{
updateState();
progress++;
if (progress >= time) {
if (progress >= time)
{
progress = 0;
recycleItems();
updateInventory = true;
}
} else {
} else
{
progress = 0;
updateState();
}
if (burning != isBurning()) {
if (burning != isBurning())
{
updateInventory = true;
}
if (updateInventory) {
if (updateInventory)
{
markDirty();
}
}
public void recycleItems() {
if (this.canOpen() && !worldObj.isRemote) {
public void recycleItems()
{
if (this.canOpen() && !worldObj.isRemote)
{
int random = new Random().nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy();
if (getStackInSlot(output) == null) {
if (getStackInSlot(output) == null)
{
useEnergy(cost);
setInventorySlotContents(output, out);
}
if (getStackInSlot(input1).stackSize > 1) {
if (getStackInSlot(input1).stackSize > 1)
{
useEnergy(cost);
this.decrStackSize(input1, 1);
} else {
} else
{
useEnergy(cost);
setInventorySlotContents(input1, null);
}
}
}
public boolean canOpen() {
public boolean canOpen()
{
return getStackInSlot(input1) != null && getStackInSlot(output) == null;
}
public boolean isBurning() {
public boolean isBurning()
{
return getEnergy() > cost;
}
public void updateState() {
public void updateState()
{
IBlockState blockState = worldObj.getBlockState(pos);
if (blockState.getBlock() instanceof BlockMachineBase) {
if (blockState.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, worldObj, pos);
@ -100,46 +124,56 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.scrapboxinator, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? new int[]{0, 1, 2} : new int[]{0, 1, 2};
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex == 2)
return false;
if (slotIndex == 1) {
if (itemStack.getItem() == ModItems.scrapBox) {
if (slotIndex == 1)
{
if (itemStack.getItem() == ModItems.scrapBox)
{
return true;
}
}
@ -147,18 +181,45 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
return slotIndex == 2;
}
@Override
public double getMaxPower() {
return 16000;
public double getMaxPower()
{
return capacity;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
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;
}
@ -166,5 +227,4 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public Inventory getInventory() {
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.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import techreborn.api.reactor.FusionReactorRecipe;
@ -16,7 +15,7 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.init.ModBlocks;
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);
@ -32,23 +31,31 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
FusionReactorRecipe currentRecipe = null;
boolean hasStartedCrafting = false;
public TileEntityFusionController()
{
super(4);
}
@Override
public double getMaxPower() {
return 100000000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return hasStartedCrafting;
public boolean canAcceptEnergy(EnumFacing direction)
{
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return !hasStartedCrafting;
public boolean canProvideEnergy(EnumFacing direction)
{
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
}
@Override
public double getMaxOutput() {
public double getMaxOutput()
{
if (!hasStartedCrafting)
{
return 0;
@ -56,10 +63,18 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
return 1000000;
}
@Override
public double getMaxInput() {
if (hasStartedCrafting) {
return 0;
}
return 8192;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.INSANE;
return EnumPowerTier.EXTREME;
}
@Override
@ -137,9 +152,9 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
}
@Override
public void update()
public void updateEntity()
{
super.update();
super.updateEntity();
// TODO improve this code a lot
if (worldObj.getTotalWorldTime() % 20 == 0)
@ -261,29 +276,11 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
if (!worldObj.isRemote && getEnergy() > 0 && hasStartedCrafting) {
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;
}
}
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
//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()
{
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true))
@ -336,7 +333,7 @@ public class TileEntityFusionController extends TilePowerAcceptorProducer implem
@Override
public String getName()
{
return "Fusion Reactor";
return null;
}
@Override

View file

@ -1,6 +1,5 @@
package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -13,7 +12,6 @@ import reborncore.api.fuel.FluidPowerManager;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -21,23 +19,16 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
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 Tank tank = new Tank("TileDieselGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64, this);
@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 TileDieselGenerator()
{
super(ConfigTechReborn.ThermalGeneratorTier);
}
@Override
@ -140,8 +131,8 @@ public class TileDieselGenerator extends TilePowerProducer implements IWrenchabl
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
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
&& FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType())) {
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
if (getMaxPower() - getEnergy() >= powerIn) {
if (getFreeSpace() >= powerIn) {
addEnergy(powerIn, false);
tank.drain(1, true);
}
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower() {
return 64000;
public double getMaxPower()
{
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
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM;
return EnumPowerTier.LOW;
}
@Override
public Inventory getInventory() {
return inventory;
}
}

View file

@ -9,31 +9,25 @@ import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
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 Inventory inventory = new Inventory(3, "TileAlloySmelter", 64, this);
@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 TileDragonEggSiphoner()
{
super(2);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
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);
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Dragoneggenergysiphoner, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public double getMaxPower() {
return 256000;
public double getMaxPower()
{
return 1000;
}
@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;
}

View file

@ -1,31 +1,32 @@
package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
import java.util.HashMap;
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
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);
Map<String, Integer> fluids = new HashMap<>();
@ -34,7 +35,9 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
// amounts.
double pendingWithdraw = 0.0;
public TileGasTurbine() {
public TileGasTurbine()
{
super(ConfigTechReborn.ThermalGeneratorTier);
// TODO: fix this to have Gas Turbine generator values
fluids.put("fluidhydrogen", 15000);
@ -42,103 +45,107 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
}
@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
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Gasturbine, 1);
}
@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);
tank.compareAndUpdate();
return fill;
}
@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);
tank.compareAndUpdate();
return drain;
}
@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);
tank.compareAndUpdate();
return drain;
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid) {
if (fluid != null) {
public boolean canFill(EnumFacing from, Fluid fluid)
{
if (fluid != null)
{
return fluids.containsKey(FluidRegistry.getFluidName(fluid));
}
return false;
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid) {
public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return new FluidTankInfo[]{tank.getInfo()};
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[] { tank.getInfo() };
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
return tagCompound;
}
@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(),
getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound());
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
tank.compareAndUpdate();
@ -166,15 +173,45 @@ public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IF
setInventorySlotContents(2, null);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower() {
return 64000;
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
}
@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;
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -10,42 +9,37 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
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 Inventory inventory = new Inventory(2, "TileGenerator", 64, this);
public int fuelSlot = 0;
public int burnTime;
public int totalBurnTime = 0;
// sould properly use the conversion
// ratio here.
// sould properly use the conversion
// ratio here.
public boolean isBurning;
public boolean lastTickBurning;
ItemStack burnItem;
public static int getItemBurnTime(ItemStack stack) {
public TileGenerator()
{
super(1);
}
public static int getItemBurnTime(ItemStack stack)
{
return TileEntityFurnace.getItemBurnTime(stack) / 4;
}
@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
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote) {
return;
}
@ -75,11 +69,17 @@ public class TileGenerator extends TilePowerProducer implements IWrenchable,IInv
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);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0)
blockMachineBase.setActive(burnTime > 0, worldObj, pos);
@ -87,37 +87,68 @@ public class TileGenerator extends TilePowerProducer implements IWrenchable,IInv
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public double getMaxPower() {
return 8000;
public double getMaxPower()
{
return 100;
}
@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;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer p0) {
public ItemStack getWrenchDrop(EntityPlayer p0)
{
return new ItemStack(ModBlocks.Generator);
}

View file

@ -1,35 +1,30 @@
package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
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;
@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 TileHeatGenerator()
{
super(1);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
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
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.heatGenerator, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public double getMaxPower() {
return 16000;
public double getMaxPower()
{
return 10000;
}
@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;
}
// @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 reborncore.api.power.EnumPowerTier;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils;
public class TileLightningRod extends TilePowerProducer {
public class TileLightningRod extends TilePowerAcceptor {
private int onStatusHoldTicks = -1;
public TileLightningRod() {
super(2);
}
@Override
public void 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() {
@ -64,17 +72,6 @@ public class TileLightningRod extends TilePowerProducer {
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) {
Item itemBlock = Item.getItemFromBlock(worldObj.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
for(ItemStack fence : OreDictionary.getOres("fenceIron")) {
@ -85,17 +82,32 @@ public class TileLightningRod extends TilePowerProducer {
@Override
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
public double getMaxOutput() {
return 32768;
return 2048;
}
@Override
public double getMaxInput() {
return 0;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
return EnumPowerTier.HIGH;
}
}

View file

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

View file

@ -2,9 +2,8 @@ package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.blocks.generator.BlockSolarPanel;
import techreborn.power.EnergyUtils;
@ -13,15 +12,22 @@ import java.util.List;
/**
* 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 lastTickSate = false;
int powerToAdd;
public TileSolarPanel()
{
super(1);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
if (worldObj.getTotalWorldTime() % 60 == 0) {
shouldMakePower = isSunOut();
@ -35,12 +41,19 @@ public class TileSolarPanel extends TilePowerProducer implements ITickable {
}
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
public void addInfo(List<String> info, boolean isRealTile) {
public void addInfo(List<String> info, boolean isRealTile)
{
super.addInfo(info, isRealTile);
if (isRealTile) {
if (isRealTile)
{
// FIXME: 25/02/2016
// info.add(TextFormatting.LIGHT_PURPLE + "Power gen/tick " +
// TextFormatting.GREEN + PowerSystem.getLocalizedPower(
@ -48,30 +61,45 @@ public class TileSolarPanel extends TilePowerProducer implements ITickable {
}
}
@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 isSunOut() {
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
public boolean isSunOut()
{
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
&& worldObj.isDaytime();
}
@Override
public double getMaxPower() {
return 8000;
public double getMaxPower()
{
return 1000;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
public boolean canAcceptEnergy(EnumFacing direction)
{
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;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@ -11,9 +12,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -21,73 +21,79 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
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 Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64, this);
@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 TileThermalGenerator()
{
super(ConfigTechReborn.ThermalGeneratorTier);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.thermalGenerator, 1);
}
@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);
tank.compareAndUpdate();
return fill;
}
@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);
tank.compareAndUpdate();
return drain;
}
@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);
tank.compareAndUpdate();
return drain;
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid) {
if (fluid != null) {
if (fluid == FluidRegistry.LAVA) {
public boolean canFill(EnumFacing from, Fluid fluid)
{
if (fluid != null)
{
if (fluid == FluidRegistry.LAVA)
{
return true;
}
}
@ -95,30 +101,35 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid) {
public boolean canDrain(EnumFacing from, Fluid fluid)
{
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return new FluidTankInfo[]{tank.getInfo()};
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[] { tank.getInfo() };
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
return tagCompound;
}
@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(),
getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound());
@ -126,8 +137,8 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
@Override
// TODO optimise this code
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
for (EnumFacing direction : EnumFacing.values()) {
@ -161,15 +172,46 @@ public class TileThermalGenerator extends TilePowerProducer implements IWrenchab
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower() {
return 16000;
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
}
@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;
}

View file

@ -2,57 +2,84 @@ package techreborn.tiles.generator;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.power.EnergyUtils;
/**
* Created by modmuss50 on 25/02/2016.
*/
public class TileWaterMill extends TilePowerProducer {
public class TileWaterMill extends TilePowerAcceptor
{
int waterblocks = 0;
public TileWaterMill()
{
super(1);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (worldObj.getTotalWorldTime() % 20 == 0) {
checkForWater();
}
if (waterblocks > 0) {
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;
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER) {
for (EnumFacing facing : EnumFacing.HORIZONTALS)
{
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER)
{
waterblocks++;
}
}
}
@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 double getMaxPower()
{
return 1000;
}
@Override
public double getMaxPower() {
return 8000;
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@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;
}
}

View file

@ -1,47 +1,70 @@
package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.power.EnergyUtils;
/**
* Created by modmuss50 on 25/02/2016.
*/
public class TileWindMill extends TilePowerProducer {
public class TileWindMill extends TilePowerAcceptor
{
int basePower = 16;
public TileWindMill()
{
super(2);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (pos.getY() > 64) {
double actualPower = basePower + basePower * worldObj.getThunderStrength(1.0F);
addEnergy(actualPower);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@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 double getMaxPower()
{
return 10000;
}
@Override
public double getMaxPower() {
return 8000;
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@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;
}
}

View file

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

View file

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

View file

@ -3,14 +3,15 @@ package techreborn.tiles.lesu;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils;
import java.util.ArrayList;
public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
public class TileLesu extends TilePowerAcceptor
{// TODO wrench
public int connectedBlocks = 0;
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 maxStorage;
public TileLesu()
{
super(5);
}
@Override
public void update() {
super.update();
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote) {
return;
}
@ -72,44 +77,53 @@ public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
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;
}
}
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
//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;
}
public double getEuChange() {
if (euChange == -1) {
public double getEuChange()
{
if (euChange == -1)
{
return 0;
}
return (euChange / ticks);
}
@Override
public double getMaxPower() {
public double getMaxPower()
{
return maxStorage;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
public boolean canAcceptEnergy(EnumFacing direction)
{
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.common.misc.Location;
import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
@ -26,7 +26,8 @@ import techreborn.init.ModBlocks;
import techreborn.multiblocks.MultiBlockCasing;
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 int tickTime;
@ -34,7 +35,9 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
public RecipeCrafter crafter;
public int capacity = 1000;
public TileBlastFurnace() {
public TileBlastFurnace()
{
super(ConfigTechReborn.CentrifugeTier);
// TODO configs
int[] inputs = new int[2];
inputs[0] = 0;
@ -46,53 +49,65 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
}
@Override
public void update() {
super.update();
public void updateEntity()
{
super.updateEntity();
crafter.updateEntity();
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.BlastFurnace, 1);
}
public int getHeat() {
for (EnumFacing direction : EnumFacing.values()) {
public int getHeat()
{
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 instanceof TileMachineCasing)
{
if (((TileMachineCasing) tileEntity).isConnected()
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) {
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled())
{
MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController();
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
location.modifyPositionFromSide(direction, 1);
int heat = 0;
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
.getBlock() == tileEntity.getBlockType()) {
.getBlock() == tileEntity.getBlockType())
{
return 0;
}
for (IMultiblockPart part : casing.connectedParts) {
for (IMultiblockPart part : casing.connectedParts)
{
BlockMachineCasing casing1 = (BlockMachineCasing) worldObj.getBlockState(part.getPos())
.getBlock();
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()))
.getBlock().getUnlocalizedName().equals("tile.lava")
&& worldObj
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava")) {
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava"))
{
heat += 500;
}
return heat;
@ -115,29 +131,34 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
}
@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(),
getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound());
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
tickTime = tagCompound.getInteger("tickTime");
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
writeUpdateToNBT(tagCompound);
return tagCompound;
}
public void writeUpdateToNBT(NBTTagCompound tagCompound) {
public void writeUpdateToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("tickTime", tickTime);
}
<<<<<<< HEAD:src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java
@Override
public int[] getSlotsForFace(EnumFacing side) {
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) {
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) {
if (crafter.currentTickTime != 0) {
@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;
}
>>>>>>> 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 0;
}
@Override
public double getMaxPower() {
return 512000;
public double getMaxPower()
{
return 10000;
}
@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;
}

View file

@ -10,8 +10,8 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
@ -26,6 +26,7 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
public RecipeCrafter crafter;
public TileImplosionCompressor() {
super(2);
int[] inputs = new int[]{0, 1};
int[] outputs = new int[]{2, 3};
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
@ -117,6 +118,26 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
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
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;

View file

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

View file

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

View file

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

View file

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

View file

@ -1,18 +1,17 @@
package techreborn.tiles.storage;
import reborncore.api.IListInfoProvider;
import reborncore.common.IWrenchable;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.blocks.storage.BlockEnergyStorage;
import techreborn.power.EnergyUtils;
@ -22,7 +21,7 @@ import java.util.List;
/**
* 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 String name;
@ -33,6 +32,7 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
public 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);
this.wrenchDrop = wrenchDrop;
this.tier = tier;
@ -64,8 +64,7 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
}
@Override
public void update() {
super.update();
public void updateEntity() {
if (inventory.getStackInSlot(0) != null) {
ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
@ -93,33 +92,13 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
}
}
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;
}
}
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
//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
public void setFacing(EnumFacing enumFacing) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
@ -140,6 +119,12 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
return maxStorage;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return getFacingEnum() != direction;
}
@Override
public EnumFacing getFacingEnum() {
Block block = worldObj.getBlockState(pos).getBlock();
@ -149,6 +134,21 @@ public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWre
return null;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return getFacing() == direction;
}
@Override
public double getMaxOutput() {
return maxOutput;
}
@Override
public double getMaxInput() {
return maxInput;
}
@Override
public EnumPowerTier getTier() {
return tier;

View file

@ -8,14 +8,15 @@ import net.minecraft.util.EnumFacing;
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.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
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);
@ -24,7 +25,9 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
public int capacity = 1000;
public TileCompressor() {
public TileCompressor()
{
super(1);
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
@ -38,67 +41,108 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
super.update();
crafter.updateEntity();
upgradeHandler.tick();
//charge(3); TODO
charge(3);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Compressor, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public int[] getSlotsForFace(EnumFacing side) {
return new int[] {0, 1};
}
@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
return index == 0;
}
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
return index == 1;
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
{
if (slotIndex == 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
}
public int getProgressScaled(int scale) {
if (crafter.currentTickTime != 0) {
@Override
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 0;
}
@Override
public double getMaxPower() {
public double getMaxPower()
{
return capacity;
}
@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;
}

View file

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

View file

@ -1,6 +1,10 @@
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.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
@ -8,17 +12,17 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks;
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);
@ -27,7 +31,9 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
public int capacity = 1000;
public TileExtractor() {
public TileExtractor()
{
super(1);
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
@ -37,68 +43,114 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
}
@Override
<<<<<<< HEAD
public void update() {
super.update();
crafter.updateEntity();
upgradeHandler.tick();
//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
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
return false;
}
@Override
public EnumFacing getFacing() {
public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.Extractor, 1);
}
public boolean isComplete() {
public boolean isComplete()
{
return false;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
return tagCompound;
}
public int getProgressScaled(int scale) {
if (crafter.currentTickTime != 0) {
public int getProgressScaled(int scale)
{
if (crafter.currentTickTime != 0)
{
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
}
return 0;
}
@Override
public double getMaxPower() {
public double getMaxPower()
{
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;
}

View file

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

View file

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

View file

@ -12,11 +12,7 @@ import techreborn.blocks.transformers.BlockTransformer;
/**
* 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
{

View file

@ -4,16 +4,16 @@
"transform":"forge:default-block",
"model":"orientable",
"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",
"side":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
"side":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
}
},
"variants":{
"inventory":{
"transform":"forge:default-block",
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
}
},
"facing":{
@ -33,22 +33,22 @@
"active":{
"true":{
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_on"
}
},
"false":{
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
}
}
},
"inventory": {
"model": "orientable",
"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",
"side": "techreborn:blocks/machine/advanced_machines/advanced_machine_side",
"front": "techreborn:blocks/machine/advanced_machines/advanced_machine_side"
"side": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"front": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
}
}
}

View file

@ -5,7 +5,7 @@
"model":"orientable",
"textures":{
"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",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front"
@ -44,7 +44,7 @@
"model": "orientable",
"textures": {
"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",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front"

View file

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

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B