feat: implement repairer

This commit is contained in:
LordMZTE 2023-05-26 18:40:04 +02:00
parent 8da2d5551f
commit 684d9e9c9f
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
19 changed files with 856 additions and 80 deletions

View File

@ -9,6 +9,7 @@ import net.anvilcraft.thaummach.gui.GuiArcaneFurnace;
import net.anvilcraft.thaummach.gui.GuiBore;
import net.anvilcraft.thaummach.gui.GuiCondenser;
import net.anvilcraft.thaummach.gui.GuiCrystallizer;
import net.anvilcraft.thaummach.gui.GuiRepairer;
import net.anvilcraft.thaummach.gui.GuiSoulBrazier;
import net.anvilcraft.thaummach.gui.GuiVoidChest;
import net.anvilcraft.thaummach.gui.GuiVoidInterface;
@ -18,6 +19,7 @@ import net.anvilcraft.thaummach.render.tile.TileBoreRenderer;
import net.anvilcraft.thaummach.render.tile.TileCondenserRenderer;
import net.anvilcraft.thaummach.render.tile.TileConduitPumpRenderer;
import net.anvilcraft.thaummach.render.tile.TileCrystallizerRenderer;
import net.anvilcraft.thaummach.render.tile.TileRepairerRenderer;
import net.anvilcraft.thaummach.render.tile.TileSealRenderer;
import net.anvilcraft.thaummach.render.tile.TileVoidChestRenderer;
import net.anvilcraft.thaummach.render.tile.TileVoidInterfaceRenderer;
@ -33,6 +35,7 @@ import net.anvilcraft.thaummach.tiles.TileCrucible;
import net.anvilcraft.thaummach.tiles.TileCrystallizer;
import net.anvilcraft.thaummach.tiles.TileFilter;
import net.anvilcraft.thaummach.tiles.TilePurifier;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.anvilcraft.thaummach.tiles.TileSeal;
import net.anvilcraft.thaummach.tiles.TileSoulBrazier;
import net.anvilcraft.thaummach.tiles.TileVoidChest;
@ -76,6 +79,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.registerTileEntity(TileCondenser.class, "condenser", new TileCondenserRenderer());
ClientRegistry.registerTileEntity(TileConduitPump.class, "conduit_pump", new TileConduitPumpRenderer());
ClientRegistry.registerTileEntity(TileCrystallizer.class, "crystallizer", new TileCrystallizerRenderer());
ClientRegistry.registerTileEntity(TileRepairer.class, "repairer", new TileRepairerRenderer());
ClientRegistry.registerTileEntity(TileSeal.class, "seal", new TileSealRenderer());
ClientRegistry.registerTileEntity(TileVoidChest.class, "voidChest", new TileVoidChestRenderer());
ClientRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface", new TileVoidInterfaceRenderer());
@ -99,6 +103,9 @@ public class ClientProxy extends CommonProxy {
case CRYSTALLIZER:
return new GuiCrystallizer(player.inventory, (TileCrystallizer) te);
case REPAIRER:
return new GuiRepairer(player.inventory, (TileRepairer) te);
case SOUL_BRAZIER:
return new GuiSoulBrazier(player.inventory, (TileSoulBrazier) te);

View File

@ -6,6 +6,7 @@ import net.anvilcraft.thaummach.container.ContainerArcaneFurnace;
import net.anvilcraft.thaummach.container.ContainerBore;
import net.anvilcraft.thaummach.container.ContainerCondenser;
import net.anvilcraft.thaummach.container.ContainerCrystallizer;
import net.anvilcraft.thaummach.container.ContainerRepairer;
import net.anvilcraft.thaummach.container.ContainerSoulBrazier;
import net.anvilcraft.thaummach.container.ContainerVoidChest;
import net.anvilcraft.thaummach.container.ContainerVoidInterface;
@ -21,6 +22,7 @@ import net.anvilcraft.thaummach.tiles.TileCrucible;
import net.anvilcraft.thaummach.tiles.TileCrystallizer;
import net.anvilcraft.thaummach.tiles.TileFilter;
import net.anvilcraft.thaummach.tiles.TilePurifier;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.anvilcraft.thaummach.tiles.TileSeal;
import net.anvilcraft.thaummach.tiles.TileSoulBrazier;
import net.anvilcraft.thaummach.tiles.TileVoidChest;
@ -48,6 +50,7 @@ public class CommonProxy implements IGuiHandler {
GameRegistry.registerTileEntity(TileCrystallizer.class, "crystallizer");
GameRegistry.registerTileEntity(TileFilter.class, "filter");
GameRegistry.registerTileEntity(TilePurifier.class, "purifier");
GameRegistry.registerTileEntity(TileRepairer.class, "repairer");
GameRegistry.registerTileEntity(TileSeal.class, "seal");
GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier");
GameRegistry.registerTileEntity(TileVoidChest.class, "voidChest");
@ -74,6 +77,9 @@ public class CommonProxy implements IGuiHandler {
case CRYSTALLIZER:
return new ContainerCrystallizer(player.inventory, (TileCrystallizer) te);
case REPAIRER:
return new ContainerRepairer(player.inventory, (TileRepairer) te);
case SOUL_BRAZIER:
return new ContainerSoulBrazier(player.inventory, (TileSoulBrazier) te);

View File

@ -5,6 +5,7 @@ public enum GuiID {
BORE,
CONDENSER,
CRYSTALLIZER,
REPAIRER,
SOUL_BRAZIER,
VOID_CHEST,
VOID_INTERFACE;

View File

@ -11,7 +11,9 @@ import net.anvilcraft.thaummach.particles.FXWisp;
import net.anvilcraft.thaummach.render.BlockApparatusRenderer;
import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer;
import net.anvilcraft.thaummach.render.apparatus.apparati.wood.CondenserApparatusRenderer;
import net.anvilcraft.thaummach.render.apparatus.apparati.wood.RepairerAparatusRenderer;
import net.anvilcraft.thaummach.tiles.TileCondenser;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@ -93,6 +95,9 @@ public class BlockApparatusWood extends BlockApparatus {
case CONDENSER:
return CondenserApparatusRenderer.INSTANCE;
case REPAIRER:
return RepairerAparatusRenderer.INSTANCE;
default:
return null;
}
@ -116,6 +121,9 @@ public class BlockApparatusWood extends BlockApparatus {
case CONDENSER:
return new TileCondenser();
case REPAIRER:
return new TileRepairer();
//case DUPLICATOR:
// return new TileDuplicator();
//
@ -199,51 +207,6 @@ public class BlockApparatusWood extends BlockApparatus {
}
}
@Override
public void breakBlock(World world, int i, int j, int k, Block block, int meta_) {
// TODO: not sure if param 6 is meta
MetaVals meta = MetaVals.get(meta_);
if (meta == MetaVals.CONDENSER) {
// TODO: condenser
//TileCondenser tileentityCondenser
// = (TileCondenser) world.getBlockTileEntity(i, j, k);
//if (tileentityCondenser != null && tileentityCondenser.degredation > 0.0F) {
// int at = (int
// ) (25.0F * (4550.0F - tileentityCondenser.degredation) / 4550.0F);
// int auraX = i >> 4;
// int auraZ = k >> 4;
// SIAuraChunk ac = (SIAuraChunk) mod_ThaumCraft.AuraHM.get(
// Arrays.asList(auraX, auraZ, ThaumCraftCore.getDimension(world))
// );
// if (ac != null) {
// ac.taint = (short) (ac.taint + at);
// world.playSoundEffect(
// (double) i,
// (double) j,
// (double) k,
// "random.fizz",
// 0.2F,
// 2.0F + world.rand.nextFloat() * 0.4F
// );
// for (int a = 0; a < at; ++a) {
// world.spawnParticle(
// "largesmoke",
// (double) ((float) i + world.rand.nextFloat()),
// (double) ((float) j + world.rand.nextFloat()),
// (double) ((float) k + world.rand.nextFloat()),
// 0.0,
// 0.0,
// 0.0
// );
// }
// }
//}
}
super.breakBlock(world, i, j, k, block, meta_);
}
@Override
public void onNeighborBlockChange(World world, int i, int j, int k, Block l) {
super.onNeighborBlockChange(world, i, j, k, l);
@ -311,9 +274,11 @@ public class BlockApparatusWood extends BlockApparatus {
// return 72;
// }
//} else if (md == 2) {
// return l <= 1 ? 86 : 87;
//} else if (md == 3) {
//}
else if (md == MetaVals.REPAIRER) {
return l <= 1 ? this.iconRestorerTop : this.iconRestorerSide;
}
//else if (md == 3) {
// return l <= 1 ? 127 : 121 + Math.abs((i + j + k) % 6);
//} else if (md == 4) {
// return l <= 1 ? 143 : 137 + Math.abs((i + j + k) % 6);

View File

@ -0,0 +1,81 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.OutputSlot;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerRepairer extends Container {
public ContainerRepairer(InventoryPlayer inventoryplayer, TileRepairer tileEntity) {
int j;
int k;
for (j = 0; j < 3; ++j) {
for (k = 0; k < 2; ++k) {
this.addSlotToContainer(
new Slot(tileEntity, k + j * 2, 37 + k * 18, 16 + j * 18)
);
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 2; ++k) {
this.addSlotToContainer(
new OutputSlot(tileEntity, 6 + k + j * 2, 90 + k * 18, 16 + j * 18)
);
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 84 + j * 18)
);
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer pl, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 12) {
if (!this.mergeItemStack(itemstack1, 12, 48, true)) {
return null;
}
} else if (i >= 12 && i < 48) {
if (!this.mergeItemStack(itemstack1, 0, 6, false)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 12, 48, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
}
return itemstack;
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
}

View File

@ -3,6 +3,7 @@ package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.TMItems;
import net.anvilcraft.thaummach.container.ContainerCondenser;
import net.anvilcraft.thaummach.tiles.TileCondenser;
import net.anvilcraft.thaummach.utils.UtilsFX;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
@ -40,15 +41,7 @@ public class GuiCondenser extends GuiContainer {
for (int upgIdx = 0; upgIdx <= 1; upgIdx++) {
int upgMeta = this.arcaneCondenser.getUpgrades()[upgIdx];
if (upgMeta >= 0) {
this.drawTexturedModelRectFromIcon(
l + 56 + 48 * upgIdx,
i1 + 56,
TMItems.upgrade.getIconFromDamage(upgMeta),
16,
16
);
}
UtilsFX.renderUpgradeIntoGUI(this, upgMeta, l + 56 + 48 * upgIdx, i1 + 56);
}
}
}

View File

@ -1,12 +1,11 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.TMItems;
import net.anvilcraft.thaummach.container.ContainerCrystallizer;
import net.anvilcraft.thaummach.tiles.TileCrystallizer;
import net.anvilcraft.thaummach.utils.UtilsFX;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@ -47,13 +46,10 @@ public class GuiCrystallizer extends GuiContainer {
}
if (this.crystallizerInventory.getUpgrades()[0] >= 0) {
IIcon itemIcon = TMItems.upgrade.getIconFromDamage(
this.crystallizerInventory.getUpgrades()[0]
);
this.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
this.drawTexturedModelRectFromIcon(j + 8, k + 128, itemIcon, 16, 16);
UtilsFX.renderUpgradeIntoGUI(
this, this.crystallizerInventory.getUpgrades()[0], j + 8, k + 128
);
}
}
}

View File

@ -0,0 +1,47 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.container.ContainerRepairer;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.anvilcraft.thaummach.utils.UtilsFX;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiRepairer extends GuiContainer {
private TileRepairer repairerInventory;
public GuiRepairer(InventoryPlayer inventoryplayer, TileRepairer tileEntity) {
super(new ContainerRepairer(inventoryplayer, tileEntity));
this.repairerInventory = tileEntity;
}
@Override
protected void drawGuiContainerForegroundLayer(int alec1, int alec2) {
super.fontRendererObj.drawString("Restorer", 30, 5, 0x404040);
super.fontRendererObj.drawString("Inventory", 30, super.ySize - 96 + 2, 0x404040);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int qq, int ww) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("thaummach", "textures/guis/repairer.png")
);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
if (this.repairerInventory.boost > 0) {
int i1 = this.repairerInventory.getBoostScaled();
this.drawTexturedModalRect(j + 135, k + 46 - i1, 208, 30 - i1, 7, i1);
}
if (this.repairerInventory.getUpgrades()[0] >= 0) {
super.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
UtilsFX.renderUpgradeIntoGUI(
this, this.repairerInventory.getUpgrades()[0], j + 130, k + 54
);
}
}
}

View File

@ -0,0 +1,104 @@
package net.anvilcraft.thaummach.render.apparatus.apparati.wood;
import net.anvilcraft.thaummach.TMBlocks;
import net.anvilcraft.thaummach.blocks.BlockApparatusMetal;
import net.anvilcraft.thaummach.blocks.BlockApparatusWood;
import net.anvilcraft.thaummach.render.apparatus.ApparatusRenderingHelper;
import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public class RepairerAparatusRenderer implements IApparatusRenderer {
public static final RepairerAparatusRenderer INSTANCE
= new RepairerAparatusRenderer();
@Override
public void renderApparatus(
IBlockAccess w,
RenderBlocks rb,
int x,
int y,
int z,
Block block_,
int meta,
boolean inv
) {
BlockApparatusWood block = (BlockApparatusWood) block_;
if (block.getRenderBlockPass() == 0 || inv) {
rb.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
if (inv) {
ApparatusRenderingHelper.drawFaces(
rb,
block,
block.iconRestorerBottom,
block.iconRestorerBottom,
block.iconRestorerBottom,
block.iconRestorerBottom,
block.iconRestorerBottom,
block.iconRestorerBottom,
false
);
} else {
rb.renderStandardBlock(block, x, y, z);
}
if (!inv) {
rb.renderFaceYPos(
block,
(double) x,
(double) ((float) y - 1.0F + 0.425F),
(double) z,
block.iconRestorerBottom
);
rb.renderFaceYNeg(
block,
(double) x,
(double) ((float) (y + 1) - 0.425F),
(double) z,
block.iconRestorerBottom
);
rb.renderFaceXPos(
block,
(double) ((float) (x - 1) + 0.425F),
(double) y,
(double) z,
block.iconRestorerBottom
);
rb.renderFaceXNeg(
block,
(double) ((float) (x + 1) - 0.425F),
(double) y,
(double) z,
block.iconRestorerBottom
);
rb.renderFaceZPos(
block,
(double) x,
(double) y,
(double) ((float) (z - 1) + 0.425F),
block.iconRestorerBottom
);
rb.renderFaceZNeg(
block,
(double) x,
(double) y,
(double) ((float) (z + 1) - 0.425F),
block.iconRestorerBottom
);
} else {
rb.setRenderBounds(0.01F, 0.01F, 0.01F, 0.99F, 0.99F, 0.99F);
ApparatusRenderingHelper.drawFaces(
rb,
block,
((BlockApparatusMetal) TMBlocks.apparatusMetal)
.iconArcaneFurnaceInside,
false
);
}
}
rb.overrideBlockTexture = null;
rb.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}

View File

@ -0,0 +1,56 @@
package net.anvilcraft.thaummach.render.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelGear extends ModelBase {
ModelRenderer Shape1;
ModelRenderer Shape2;
ModelRenderer Shape3;
public ModelGear() {
super.textureWidth = 64;
super.textureHeight = 32;
this.Shape1 = new ModelRenderer(this, 0, 0);
this.Shape1.addBox(-2.0F, -6.0F, -6.0F, 4, 12, 12);
this.Shape1.setRotationPoint(0.0F, 0.0F, 0.0F);
this.Shape1.setTextureSize(64, 32);
this.Shape1.mirror = true;
this.setRotation(this.Shape1, 0.0F, 0.0F, 0.0F);
this.Shape2 = new ModelRenderer(this, 0, 0);
this.Shape2.addBox(-2.0F, -6.0F, -6.0F, 4, 12, 12);
this.Shape2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.Shape2.setTextureSize(64, 32);
this.Shape2.mirror = true;
this.setRotation(this.Shape2, 0.5235988F, 0.0F, 0.0F);
this.Shape3 = new ModelRenderer(this, 0, 0);
this.Shape3.addBox(-2.0F, -6.0F, -6.0F, 4, 12, 12);
this.Shape3.setRotationPoint(0.0F, 0.0F, 0.0F);
this.Shape3.setTextureSize(64, 32);
this.Shape3.mirror = true;
this.setRotation(this.Shape3, -0.5235988F, 0.0F, 0.0F);
}
@Override
public void
render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.Shape1.render(f5);
this.Shape2.render(f5);
this.Shape3.render(f5);
}
public void render() {
this.Shape1.render(0.0625F);
this.Shape2.render(0.0625F);
this.Shape3.render(0.0625F);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -31,21 +31,6 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
GL11.glRotatef(angleS, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.25f, 0.25f, 0.0F);
GL11.glScalef(-0.5f, -0.5f, 1f);
// TODO: rüssel
//ThaumCraftRenderer.renderItemFromTexture(
// mc,
// "/thaumcraft/resources/items.png",
// 16,
// 43 + cr.focus,
// 0.4F,
// 1.5F + jitter,
// true,
// 1.0F,
// 1.0F,
// 1.0F,
// 220,
// 771
//);
if (cr.boreItemStacks[0] != null) {
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);

View File

@ -0,0 +1,60 @@
package net.anvilcraft.thaummach.render.tile;
import net.anvilcraft.thaummach.render.model.ModelGear;
import net.anvilcraft.thaummach.tiles.TileRepairer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class TileRepairerRenderer extends TileEntitySpecialRenderer {
private ModelGear model = new ModelGear();
public void renderEntityAt(TileRepairer rp, double x, double y, double z, float fq) {
int count = Minecraft.getMinecraft().thePlayer.ticksExisted;
int angle = 0;
if (rp.worked) {
angle = count % 360;
}
this.bindTexture(new ResourceLocation("thaummach", "textures/models/gear.png"));
GL11.glEnable(2977);
GL11.glEnable(3042);
GL11.glPushMatrix();
GL11.glEnable(32826);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
GL11.glPushMatrix();
GL11.glScalef(0.43F, 0.94F, 0.94F);
GL11.glRotatef((float) angle, 1.0F, 0.0F, 0.0F);
this.model.render();
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(0.94F, 0.94F, 0.43F);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float) angle, 1.0F, 0.0F, 0.0F);
this.model.render();
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(0.94F, 0.43F, 0.94F);
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef((float) angle, 1.0F, 0.0F, 0.0F);
this.model.render();
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
GL11.glDisable(32826);
GL11.glPopMatrix();
GL11.glDisable(3042);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public void
renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f) {
this.renderEntityAt((TileRepairer) te, d, d1, d2, f);
}
}

View File

@ -151,6 +151,9 @@ public class TileConduitTank extends TileEntity implements IConnection {
> ent.getVisSuction(new HelperLocation(this))
|| this.getTaintSuction((HelperLocation) null)
> ent.getTaintSuction(new HelperLocation(this)))) {
this.worldObj.markBlockForUpdate(
this.xCoord, this.yCoord, this.zCoord
);
float[] results = ent.subtractVis(Math.min(
this.fillAmount,
stackmaxVis - (stackpureVis + stacktaintedVis)

View File

@ -0,0 +1,448 @@
package net.anvilcraft.thaummach.tiles;
import java.util.stream.IntStream;
import dev.tilera.auracore.api.machine.IUpgradable;
import dev.tilera.auracore.api.machine.TileVisUser;
import dev.tilera.auracore.aura.AuraManager;
import net.anvilcraft.thaummach.GuiID;
import net.anvilcraft.thaummach.ITileGui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import thaumcraft.api.IRepairable;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
public class TileRepairer extends TileVisUser implements ISidedInventory, IUpgradable, ITileGui {
private ItemStack[] repairerItemStacks = new ItemStack[12];
public float sucked = 0.0F;
public float currentVis = 0.0F;
public float maxVis = 5.0F;
public int boost = 0;
private byte[] upgrades = new byte[] { -1 };
public boolean worked;
int boostDelay = 20;
int soundDelay = 0;
@Override
public GuiID getGuiID() {
return GuiID.REPAIRER;
}
@Override
public int getSizeInventory() {
return this.repairerItemStacks.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return this.repairerItemStacks[i];
}
@Override
public ItemStack decrStackSize(int i, int j) {
if (this.repairerItemStacks[i] != null) {
ItemStack itemstack1;
if (this.repairerItemStacks[i].stackSize <= j) {
itemstack1 = this.repairerItemStacks[i];
this.repairerItemStacks[i] = null;
return itemstack1;
} else {
itemstack1 = this.repairerItemStacks[i].splitStack(j);
if (this.repairerItemStacks[i].stackSize == 0) {
this.repairerItemStacks[i] = null;
}
return itemstack1;
}
} else {
return null;
}
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
this.repairerItemStacks[i] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName() {
return "Thaumic Repairer";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10);
this.repairerItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1
= (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
byte byte0 = nbttagcompound1.getByte("SlotDuplicator");
if (byte0 >= 0 && byte0 < this.repairerItemStacks.length) {
this.repairerItemStacks[byte0]
= ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.upgrades = nbttagcompound.getByteArray("upgrades");
this.currentVis = nbttagcompound.getFloat("currentVis");
this.maxVis = nbttagcompound.getFloat("maxVis");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setByteArray("upgrades", this.upgrades);
nbttagcompound.setFloat("currentVis", this.currentVis);
nbttagcompound.setFloat("maxVis", this.maxVis);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.repairerItemStacks.length; ++i) {
if (this.repairerItemStacks[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("SlotDuplicator", (byte) i);
this.repairerItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit() {
return 64;
}
public int getBoostScaled() {
return Math.round(0.1F + (float) this.boost / 2.0F) * 6;
}
@Override
public void updateEntity() {
super.updateEntity();
this.worked = false;
if (!super.worldObj.isRemote) {
boolean flag1 = false;
for (int a = 0; a < 6; ++a) {
boolean isVisRepair = false;
try {
isVisRepair
= this.repairerItemStacks[a].getItem() instanceof IRepairable;
} catch (Exception var6) {}
if (this.repairerItemStacks[a] != null
&& this.repairerItemStacks[a].isItemDamaged()
&& this.repairerItemStacks[a].getItemDamage() > 0
&& (this.repairerItemStacks[a].getItem().isRepairable() || isVisRepair
)) {
float ra = 1.0f;
ra *= this.hasUpgrade((byte) 1) ? 0.8F : 1.0F;
if (this.repairerItemStacks[a].isItemEnchanted()) {
ra *= 1.5F;
}
if (this.currentVis >= ra) {
this.worldObj.markBlockForUpdate(
this.xCoord, this.yCoord, this.zCoord
);
this.currentVis -= ra;
flag1 = true;
this.repairerItemStacks[a].setItemDamage(
this.repairerItemStacks[a].getItemDamage() - 1
);
this.worked = true;
if (!this.hasUpgrade((byte) -1)) {
// TODO: FX
//switch (super.worldObj.rand.nextInt(4)) {
// case 0:
// ThaumCraftCore.createSmallGreenFlameFX(
// super.worldObj,
// (float) super.xCoord + 0.25F,
// (float) super.yCoord + 1.15F,
// (float) super.zCoord + 0.25F
// );
// break;
// case 1:
// ThaumCraftCore.createSmallGreenFlameFX(
// super.worldObj,
// (float) super.xCoord + 0.25F,
// (float) super.yCoord + 1.15F,
// (float) super.zCoord + 0.75F
// );
// break;
// case 2:
// ThaumCraftCore.createSmallGreenFlameFX(
// super.worldObj,
// (float) super.xCoord + 0.75F,
// (float) super.yCoord + 1.15F,
// (float) super.zCoord + 0.25F
// );
// break;
// case 3:
// ThaumCraftCore.createSmallGreenFlameFX(
// super.worldObj,
// (float) super.xCoord + 0.75F,
// (float) super.yCoord + 1.15F,
// (float) super.zCoord + 0.75F
// );
//}
}
}
}
if (this.repairerItemStacks[a] != null
&& !this.repairerItemStacks[a].isItemDamaged()) {
this.moveRepairedItem(a);
}
}
float suckLimit = 0.5F + 0.05F * (float) this.boost
+ (this.hasUpgrade((byte) 0) ? 0.5F : 0.0F);
for (int i = 0; i < 6; ++i) {
if (this.repairerItemStacks[i] != null) {
if (this.currentVis + suckLimit <= this.maxVis) {
this.currentVis += this.getAvailablePureVis(suckLimit);
}
break;
}
}
if (flag1 && this.soundDelay <= 0) {
this.soundDelay = 50;
super.worldObj.playSoundEffect(
(double) ((float) super.xCoord + 0.5F),
(double) ((float) super.yCoord + 0.5F),
(double) ((float) super.zCoord + 0.5F),
"thaummach:tinkering",
0.5F,
1.0F
);
AuraManager.addFluxToClosest(
this.worldObj,
this.xCoord,
this.yCoord,
this.zCoord,
new AspectList().add(Aspect.TAINT, 1)
);
}
if (this.soundDelay > 0) {
--this.soundDelay;
}
// TODO: magic boost
//if (this.boostDelay <= 0 || this.boostDelay == 10) {
// auraX = super.xCoord >> 4;
// auraZ = super.zCoord >> 4;
// ac = (SIAuraChunk) mod_ThaumCraft.AuraHM.get(Arrays.asList(
// auraX, auraZ, ThaumCraftCore.getDimension(super.worldObj)
// ));
// if (ac != null && this.boost < 10 && ac.boost > 0) {
// ++this.boost;
// --ac.boost;
// }
//}
//
//if (this.boostDelay <= 0) {
// if (this.boost > 0) {
// --this.boost;
// }
// this.boostDelay = 20;
//} else {
// --this.boostDelay;
//}
}
}
private void moveRepairedItem(int stack) {
ItemStack itemstack = new ItemStack(
this.repairerItemStacks[stack].getItem(),
1,
this.repairerItemStacks[stack].getItemDamage()
);
for (int j = 6; j < 12; ++j) {
if (this.repairerItemStacks[j] == null) {
this.repairerItemStacks[j] = itemstack.copy();
this.repairerItemStacks[j].setTagCompound(
this.repairerItemStacks[stack].getTagCompound()
);
--this.repairerItemStacks[stack].stackSize;
if (this.repairerItemStacks[stack].stackSize <= 0) {
this.repairerItemStacks[stack] = null;
}
break;
}
}
}
// public int getStartInventorySide(int side) {
// return side != 0 && side != 1 ? 6 : 0;
// }
//
// public int getSizeInventorySide(int side) {
// return 6;
// }
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return true;
}
@Override
public boolean getConnectable(ForgeDirection face) {
return true;
}
@Override
public boolean canAcceptUpgrade(byte upgrade) {
if (upgrade != 0 && upgrade != 1) {
return false;
} else {
return !this.hasUpgrade(upgrade);
}
}
@Override
public int getUpgradeLimit() {
return 1;
}
@Override
public byte[] getUpgrades() {
return this.upgrades;
}
@Override
public boolean hasUpgrade(byte upgrade) {
if (this.upgrades.length < 1) {
return false;
} else {
for (int a = 0; a < this.getUpgradeLimit(); ++a) {
if (this.upgrades[a] == upgrade) {
return true;
}
}
return false;
}
}
@Override
public boolean setUpgrade(byte upgrade) {
for (int a = 0; a < this.getUpgradeLimit(); ++a) {
if (this.upgrades[a] < 0 && this.canAcceptUpgrade(upgrade)) {
this.upgrades[a] = upgrade;
return true;
}
}
return false;
}
@Override
public boolean clearUpgrade(int index) {
if (this.upgrades[index] >= 0) {
this.upgrades[index] = -1;
return true;
} else {
return false;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
if (this.repairerItemStacks[var1] != null) {
ItemStack var2 = this.repairerItemStacks[var1];
this.repairerItemStacks[var1] = null;
return var2;
} else {
return null;
}
}
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
// TODO: WTF
return true;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
// output for top/bottom, else input
int offset = side == 0 || side == 1 ? 6 : 0;
return IntStream.range(offset, 6 + offset).toArray();
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side) {
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side) {
ItemStack curStack = this.repairerItemStacks[slot];
return curStack != null && curStack.isItemEqual(stack)
&& curStack.stackSize - stack.stackSize > 0;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("sucked", this.sucked);
nbt.setFloat("currentVis", this.currentVis);
nbt.setFloat("maxVis", this.maxVis);
nbt.setInteger("boost", this.boost);
nbt.setByteArray("upgrades", this.upgrades);
nbt.setBoolean("worked", this.worked);
return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.sucked = nbt.getFloat("sucked");
this.currentVis = nbt.getFloat("currentVis");
this.maxVis = nbt.getFloat("maxVis");
this.boost = nbt.getInteger("boost");
this.upgrades = nbt.getByteArray("upgrades");
this.worked = nbt.getBoolean("worked");
}
}

View File

@ -1,7 +1,9 @@
package net.anvilcraft.thaummach.utils;
import dev.tilera.auracore.client.FXSparkle;
import net.anvilcraft.thaummach.TMItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import thaumcraft.client.fx.particles.FXWisp;
@ -272,4 +274,17 @@ public class UtilsFX {
tes.draw();
}
/**
* Draws an upgrade into the GuiContainer.
*/
public static void
renderUpgradeIntoGUI(GuiContainer gui, int upgrade, int x, int y) {
if (upgrade < 0)
return;
gui.drawTexturedModelRectFromIcon(
x, y, TMItems.upgrade.getIconFromDamage(upgrade), 16, 16
);
}
}

View File

@ -44,6 +44,15 @@
}
]
},
"tinkering": {
"category": "block",
"sounds": [
{
"name": "tinkering",
"stream": false
}
]
},
"upgrade": {
"category": "master",
"sounds": [

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B