Compare commits

...
3 Commits
Author SHA1 Message Date
Mary Hopson d63329fce2 Move from thaumic tinkerer 2025-10-15 16:33:31 -04:00
551cdf4a93 Soul Beacon Event Handler Cleanup (#93)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-12 23:36:36 +02:00
Martin Robertz 5a14114583 update 2025-10-02 01:51:49 +02:00
23 changed files with 1000 additions and 143 deletions

No files matched your search

+4 -2
View File
@@ -1,9 +1,11 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:Baubles-Expanded:2.1.15-GTNH:dev')
api('com.github.GTNewHorizons:Baubles-Expanded:2.2.0-GTNH:dev')
api('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.461:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.02:dev') {transitive = false}
implementation("com.github.GTNewHorizons:GTNHLib:0.6.38:dev")
}
+1 -1
View File
@@ -45,7 +45,7 @@ enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
@@ -0,0 +1,36 @@
package com.kentington.thaumichorizons.api;
import net.minecraft.item.ItemStack;
import thaumcraft.api.aspects.Aspect;
public class VisweaverRecipe {
private final int centivisCost;
private final Aspect centivisType;
private final ItemStack input;
private final ItemStack output;
VisweaverRecipe(int centivisCost, Aspect centivisType, ItemStack input, ItemStack output) {
this.centivisCost = centivisCost;
this.centivisType = centivisType;
this.input = input;
this.output = output;
}
public int getCentivisCost() {
return centivisCost;
}
public Aspect getCentivisType() {
return centivisType;
}
public ItemStack getInput() {
return input;
}
public ItemStack getOutput() {
return output;
}
}
@@ -0,0 +1,28 @@
package com.kentington.thaumichorizons.api;
import net.minecraft.item.ItemStack;
import com.kentington.thaumichorizons.common.lib.ItemHashStrategy;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import thaumcraft.api.aspects.Aspect;
public class VisweaverRecipeMap {
/*
* Hashmap using a hashing strategy suited to comparing items
*/
private static final Object2ObjectOpenCustomHashMap<ItemStack, VisweaverRecipe> recipeMap = new Object2ObjectOpenCustomHashMap<>(
new ItemHashStrategy());
private VisweaverRecipeMap() {}
public static VisweaverRecipe lookup(ItemStack input) {
return recipeMap.get(input);
}
public static void putRecipe(int centivisCost, Aspect centivisType, ItemStack input, ItemStack output) {
VisweaverRecipe recipe = new VisweaverRecipe(centivisCost, centivisType, input, output);
recipeMap.put(input, recipe);
}
}
@@ -41,6 +41,7 @@ import com.kentington.thaumichorizons.client.gui.GuiSoulExtractor;
import com.kentington.thaumichorizons.client.gui.GuiSoulforge;
import com.kentington.thaumichorizons.client.gui.GuiVat;
import com.kentington.thaumichorizons.client.gui.GuiVisDynamo;
import com.kentington.thaumichorizons.client.gui.GuiVisweaver;
import com.kentington.thaumichorizons.client.renderer.block.BlockBloodInfuserRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockEssentiaDynamoRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockInspiratronRender;
@@ -59,6 +60,7 @@ import com.kentington.thaumichorizons.client.renderer.block.BlockVatMatrixRender
import com.kentington.thaumichorizons.client.renderer.block.BlockVatRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockVatSolidRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockVisDynamoRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockVisweaverRender;
import com.kentington.thaumichorizons.client.renderer.block.BlockVortexStabilizerRender;
import com.kentington.thaumichorizons.client.renderer.entity.BlastPhialRender;
import com.kentington.thaumichorizons.client.renderer.entity.RenderAlchemitePrimed;
@@ -109,6 +111,7 @@ import com.kentington.thaumichorizons.client.renderer.tile.TileTransductionAmpli
import com.kentington.thaumichorizons.client.renderer.tile.TileVatMatrixRender;
import com.kentington.thaumichorizons.client.renderer.tile.TileVatSlaveRender;
import com.kentington.thaumichorizons.client.renderer.tile.TileVisDynamoRender;
import com.kentington.thaumichorizons.client.renderer.tile.TileVisweaverRender;
import com.kentington.thaumichorizons.client.renderer.tile.TileVortexRender;
import com.kentington.thaumichorizons.client.renderer.tile.TileVortexStabilizerRender;
import com.kentington.thaumichorizons.common.CommonProxy;
@@ -159,6 +162,7 @@ import com.kentington.thaumichorizons.common.tiles.TileVat;
import com.kentington.thaumichorizons.common.tiles.TileVatMatrix;
import com.kentington.thaumichorizons.common.tiles.TileVatSlave;
import com.kentington.thaumichorizons.common.tiles.TileVisDynamo;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import com.kentington.thaumichorizons.common.tiles.TileVortex;
import com.kentington.thaumichorizons.common.tiles.TileVortexStabilizer;
@@ -217,6 +221,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileSpike.class, new TileSpikeRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileCloud.class, new TileCloudRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileSlot.class, new TileSlotRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileVisweaver.class, new TileVisweaverRender());
RenderingRegistry.registerEntityRenderingHandler(EntityAlchemitePrimed.class, new RenderAlchemitePrimed());
RenderingRegistry.registerEntityRenderingHandler(EntitySyringe.class, new RenderSyringe());
RenderingRegistry.registerEntityRenderingHandler(EntityBlastPhial.class, new BlastPhialRender());
@@ -316,6 +321,9 @@ public class ClientProxy extends CommonProxy {
case 9 -> {
return new GuiFingers(player.inventory);
}
case 10 -> {
return new GuiVisweaver(player.inventory, (TileVisweaver) world.getTileEntity(x, y, z));
}
}
}
return null;
@@ -364,6 +372,8 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new BlockSpikeRenderer());
ThaumicHorizons.blockSlotRI = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new BlockSlotRender());
ThaumicHorizons.blockVisweaverRI = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new BlockVisweaverRender());
}
@Override
@@ -0,0 +1,76 @@
package com.kentington.thaumichorizons.client.gui;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.kentington.thaumichorizons.common.container.ContainerVisweaver;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiVisweaver extends GuiContainer {
private static final ResourceLocation gui = new ResourceLocation(
"thaumichorizons",
"textures/gui/guivisweaver.png");
public TileVisweaver visweaver;
public List<String> tooltip = new ArrayList<>();
int x, y;
ItemStack lastTickStack;
ItemStack currentStack;
public GuiVisweaver(InventoryPlayer inv, TileVisweaver visweaver) {
super(new ContainerVisweaver(inv, visweaver));
this.visweaver = visweaver;
lastTickStack = visweaver.getStackInSlot(0);
currentStack = visweaver.getStackInSlot(0);
}
@Override
public void initGui() {
super.initGui();
x = (width - xSize) / 2;
y = (height - ySize) / 2;
}
@Override
public void updateScreen() {
currentStack = visweaver.getStackInSlot(0);
lastTickStack = currentStack;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(gui);
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
GL11.glEnable(GL11.GL_BLEND);
if (visweaver.isWorking()) {
int pixels = (int) (67D * ((double) visweaver.getInternalVis() / (double) visweaver.getRequiredVis()));
// Draw aspect color to fill
Color color = new Color(visweaver.getCvType().getColor());
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
drawTexturedModalRect(x + 56, y + 35, 185, 10, pixels, 8);
}
// Draw aspect "container" over progressbar
GL11.glColor3f(1F, 1F, 1F);
drawTexturedModalRect(x + 49, y + 34, 178, 0, 78, 10);
GL11.glDisable(GL11.GL_BLEND);
}
}
@@ -0,0 +1,40 @@
package com.kentington.thaumichorizons.client.renderer.block;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class BlockVisweaverRender implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileVisweaver(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
return false;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return ThaumicHorizons.blockVisweaverRI;
}
}
@@ -0,0 +1,135 @@
package com.kentington.thaumichorizons.client.renderer.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import thaumcraft.api.aspects.Aspect;
public class ModelVisweaver extends ModelBase {
public ModelRenderer base;
public ModelRenderer top;
public ModelRenderer pillar1;
public ModelRenderer pillar2;
public ModelRenderer pillar3;
public ModelRenderer pillar4;
public ModelRenderer orbBase;
public ModelRenderer orbIgnis;
public ModelRenderer orbAqua;
public ModelRenderer orbAer;
public ModelRenderer orbTerra;
public ModelRenderer orbOrdo;
public ModelRenderer orbPerditio;
public ModelRenderer orbCarrier;
public ModelVisweaver() {
this.textureWidth = 64;
this.textureHeight = 36;
this.pillar1 = new ModelRenderer(this, 0, 0);
this.pillar1.setRotationPoint(-7.0F, 14.0F, 5.0F);
this.pillar1.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
this.pillar2 = new ModelRenderer(this, 0, 0);
this.pillar2.setRotationPoint(5.0F, 14.0F, 5.0F);
this.pillar2.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
this.pillar3 = new ModelRenderer(this, 0, 0);
this.pillar3.setRotationPoint(5.0F, 14.0F, -7.0F);
this.pillar3.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
this.pillar4 = new ModelRenderer(this, 0, 0);
this.pillar4.setRotationPoint(-7.0F, 14.0F, -7.0F);
this.pillar4.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
this.top = new ModelRenderer(this, 0, 0);
this.top.setRotationPoint(-8.0F, 12.0F, -8.0F);
this.top.addBox(0.0F, 0.0F, 0.0F, 16, 2, 16, 0.0F);
this.base = new ModelRenderer(this, 0, 18);
this.base.setRotationPoint(-8.0F, 22.0F, -8.0F);
this.base.addBox(0.0F, 0.0F, 0.0F, 16, 2, 16, 0.0F);
this.orbBase = new ModelRenderer(this, 48, 0);
this.orbBase.setRotationPoint(0, 8, 0);
this.orbBase.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbIgnis = new ModelRenderer(this, 56, 4);
this.orbIgnis.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbIgnis.setRotationPoint(0, 8, 0);
this.orbAqua = new ModelRenderer(this, 56, 12);
this.orbAqua.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbAqua.setRotationPoint(0, 8, 0);
this.orbAer = new ModelRenderer(this, 56, 8);
this.orbAer.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbAer.setRotationPoint(0, 8, 0);
this.orbTerra = new ModelRenderer(this, 48, 8);
this.orbTerra.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbTerra.setRotationPoint(0, 8, 0);
this.orbOrdo = new ModelRenderer(this, 48, 12);
this.orbOrdo.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbOrdo.setRotationPoint(0, 8, 0);
this.orbPerditio = new ModelRenderer(this, 48, 4);
this.orbPerditio.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
this.orbPerditio.setRotationPoint(0, 8, 0);
this.orbCarrier = new ModelRenderer(this);
this.orbCarrier.addChild(this.orbBase);
this.orbCarrier.addChild(this.orbIgnis);
this.orbCarrier.addChild(this.orbAqua);
this.orbCarrier.addChild(this.orbAer);
this.orbCarrier.addChild(this.orbTerra);
this.orbCarrier.addChild(this.orbOrdo);
this.orbCarrier.addChild(this.orbPerditio);
}
public void render(boolean isWorking, int tickCounter, Aspect cvType) {
final float scale = 1F / 16F;
if (tickCounter != -1) {
float xyRotate = (float) tickCounter / 20F;
float zRotate = (float) tickCounter / 100F;
orbCarrier.rotationPointX = (float) Math.sin((float) tickCounter / 10.0F) * 2.0F;
float orbitRotation = ((float) tickCounter / 40F) % (2F * (float) Math.PI);
setRotateAngle(orbCarrier, 0F, orbitRotation, 0F);
ModelRenderer toRender = getToRender(isWorking, cvType);
setRotateAngle(toRender, xyRotate, xyRotate, zRotate);
toRender.render(scale);
}
this.pillar3.render(scale);
this.top.render(scale);
this.pillar4.render(scale);
this.base.render(scale);
this.pillar1.render(scale);
this.pillar2.render(scale);
}
private ModelRenderer getToRender(boolean isWorking, Aspect cvType) {
ModelRenderer toRender = orbBase;
if (isWorking) {
if (cvType == Aspect.AIR) {
toRender = orbAer;
} else if (cvType == Aspect.FIRE) {
toRender = orbIgnis;
} else if (cvType == Aspect.ORDER) {
toRender = orbOrdo;
} else if (cvType == Aspect.ENTROPY) {
toRender = orbPerditio;
} else if (cvType == Aspect.WATER) {
toRender = orbAqua;
} else if (cvType == Aspect.EARTH) {
toRender = orbTerra;
}
}
return toRender;
}
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -0,0 +1,46 @@
package com.kentington.thaumichorizons.client.renderer.tile;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.kentington.thaumichorizons.client.renderer.model.ModelVisweaver;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import thaumcraft.client.lib.UtilsFX;
public class TileVisweaverRender extends TileEntitySpecialRenderer {
private static final ResourceLocation modelTex = new ResourceLocation(
"thaumichorizons",
"textures/models/visweaver.png");
ModelVisweaver model = new ModelVisweaver();
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileVisweaver visweaver = (TileVisweaver) tileentity;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef((float) x, (float) y, (float) z);
UtilsFX.bindTexture(modelTex);
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
GL11.glScalef(1F, -1F, -1F);
model.render(visweaver.isWorking(), visweaver.getTickCounter(), visweaver.getCvType());
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glTranslatef(0F, 0F, -0.6F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
@@ -22,6 +22,7 @@ import com.kentington.thaumichorizons.common.container.ContainerSoulExtractor;
import com.kentington.thaumichorizons.common.container.ContainerSoulforge;
import com.kentington.thaumichorizons.common.container.ContainerVat;
import com.kentington.thaumichorizons.common.container.ContainerVisDynamo;
import com.kentington.thaumichorizons.common.container.ContainerVisweaver;
import com.kentington.thaumichorizons.common.items.WandManagerTH;
import com.kentington.thaumichorizons.common.tiles.TileBloodInfuser;
import com.kentington.thaumichorizons.common.tiles.TileInspiratron;
@@ -29,6 +30,7 @@ import com.kentington.thaumichorizons.common.tiles.TileSoulExtractor;
import com.kentington.thaumichorizons.common.tiles.TileSoulforge;
import com.kentington.thaumichorizons.common.tiles.TileVat;
import com.kentington.thaumichorizons.common.tiles.TileVisDynamo;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import com.kentington.thaumichorizons.common.tiles.TileVortex;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -97,6 +99,9 @@ public class CommonProxy implements IGuiHandler {
case 9 -> {
return new ContainerFingers(player.inventory);
}
case 10 -> {
return new ContainerVisweaver(player.inventory, (TileVisweaver) world.getTileEntity(x, y, z));
}
default -> {
return null;
}
@@ -95,6 +95,7 @@ import com.kentington.thaumichorizons.common.blocks.BlockVat;
import com.kentington.thaumichorizons.common.blocks.BlockVatInterior;
import com.kentington.thaumichorizons.common.blocks.BlockVatSolid;
import com.kentington.thaumichorizons.common.blocks.BlockVisDynamo;
import com.kentington.thaumichorizons.common.blocks.BlockVisweaver;
import com.kentington.thaumichorizons.common.blocks.BlockVoid;
import com.kentington.thaumichorizons.common.blocks.BlockVortex;
import com.kentington.thaumichorizons.common.blocks.BlockVortexItem;
@@ -211,6 +212,7 @@ import com.kentington.thaumichorizons.common.tiles.TileVatConnector;
import com.kentington.thaumichorizons.common.tiles.TileVatMatrix;
import com.kentington.thaumichorizons.common.tiles.TileVatSlave;
import com.kentington.thaumichorizons.common.tiles.TileVisDynamo;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import com.kentington.thaumichorizons.common.tiles.TileVortex;
import com.kentington.thaumichorizons.common.tiles.TileVortexStabilizer;
@@ -300,6 +302,7 @@ public class ThaumicHorizons {
public static int blockVortexRI = -1;
public static int blockSpikeRI = -1;
public static int blockSlotRI = -1;
public static int blockVisweaverRI = -1;
public static int potionVisBoostID = -1;
public static int potionVisRegenID = -1;
public static int potionVacuumID = -1;
@@ -391,6 +394,7 @@ public class ThaumicHorizons {
public static Block blockSlot;
public static Block blockPortal;
public static Block blockGateway;
public static Block blockVisweaver;
public static final Material portal;
public static ShapedArcaneRecipe recipeSyringe;
public static ShapedArcaneRecipe recipeLensCase;
@@ -449,7 +453,7 @@ public class ThaumicHorizons {
public static InfusionRecipe recipeEnchantClay;
public static InfusionRecipe recipeKeystone;
public static InfusionRecipe recipeKeystone1;
public static InfusionRecipe recipeVisweaver;
public static InfusionRecipe recipeVortexStabilizer;
public static InfusionRecipe recipeRecombinator;
public static InfusionRecipe recipeSlot;
@@ -537,6 +541,7 @@ public class ThaumicHorizons {
blockSlot = new BlockSlot();
blockPortal = new BlockPortalTH();
blockGateway = new BlockGatewayPortal();
blockVisweaver = new BlockVisweaver();
itemSpawnerEgg = new ItemSpawnerEgg();
itemEggIncubated = new ItemEggIncubated();
itemLensCase = new ItemLensCase();
@@ -623,6 +628,7 @@ public class ThaumicHorizons {
GameRegistry.registerBlock(blockSlot, "slotTH");
GameRegistry.registerBlock(blockPortal, "portalTH");
GameRegistry.registerBlock(blockGateway, "gatewayTH");
GameRegistry.registerBlock(blockVisweaver, "visweaverTH");
GameRegistry.registerItem(itemSpawnerEgg, "spawnerEgg");
GameRegistry.registerItem(itemEggIncubated, "eggIncubated");
GameRegistry.registerItem(itemLensFire, "lensFire");
@@ -749,6 +755,7 @@ public class ThaumicHorizons {
GameRegistry.registerTileEntity(TileSpike.class, "SpikeTH");
GameRegistry.registerTileEntity(TileCloud.class, "CloudTH");
GameRegistry.registerTileEntity(TileSlot.class, "KeystoneReceptacleTH");
GameRegistry.registerTileEntity(TileVisweaver.class, "TileVisweaverTH");
proxy.registerHandlers();
proxy.registerRenderers();
FMLCommonHandler.instance().bus().register(instance);
@@ -1919,6 +1926,30 @@ public class ThaumicHorizons {
vortexStabilizer.setParents("planarTheory");
vortexStabilizer.setConcealed();
ResearchCategories.addResearch(vortexStabilizer);
ResearchItem visweaver = new ResearchItem(
"visweaver",
"ThaumicHorizons",
new AspectList().add(Aspect.MECHANISM, 1).add(Aspect.EXCHANGE, 1).add(Aspect.MAGIC, 1)
.add(Aspect.ENERGY, 1),
-1,
2,
2,
new ItemStack(blockVisweaver));
recipeVisweaver = ThaumcraftApi.addInfusionCraftingRecipe(
"visweaver",
new ItemStack(blockVisweaver),
7,
new AspectList().add(Aspect.EXCHANGE, 40).add(Aspect.MECHANISM, 20).add(Aspect.MAGIC, 20),
new ItemStack(ConfigBlocks.blockTable),
new ItemStack[] { new ItemStack(ConfigItems.itemShard, 1, 6),
new ItemStack(ConfigItems.itemResource, 1, 2), new ItemStack(ConfigItems.itemShard, 1, 6),
new ItemStack(ConfigItems.itemResource, 1, 15), new ItemStack(ConfigItems.itemShard, 1, 6),
new ItemStack(ConfigItems.itemResource, 1, 3), });
ResearchPage visweaver1 = new ResearchPage("visweaver1");
ResearchPage visweaver2 = new ResearchPage(recipeVisweaver);
visweaver.setPages(visweaver1, visweaver2);
visweaver.setParents("shardTrans", "VISPOWER");
ResearchCategories.addResearch(visweaver);
ResearchItem recombinator = new ResearchItem(
"recombinator",
"ThaumicHorizons",
@@ -0,0 +1,87 @@
package com.kentington.thaumichorizons.common.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kentington.thaumichorizons.api.VisweaverRecipeMap;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumcraft.api.aspects.Aspect;
public class BlockVisweaver extends BlockContainer {
public BlockVisweaver() {
super(Material.wood);
setHardness(5F);
setResistance(10F);
this.setBlockName("ThaumicHorizons_visweaver");
this.setBlockTextureName("ThaumicHorizons:visweaver");
VisweaverRecipeMap.putRecipe(25, Aspect.FIRE, new ItemStack(Items.bed), new ItemStack(Items.spider_eye));
VisweaverRecipeMap.putRecipe(50, Aspect.EARTH, new ItemStack(Items.brick), new ItemStack(Items.netherbrick));
}
public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player,
final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_) {
player.openGui(ThaumicHorizons.instance, 10, world, x, y, z);
return true;
}
public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int md) {
final TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof final TileVisweaver tile) {
ItemStack input = tile.getStackInSlot(0);
ItemStack output = tile.getStackInSlot(1);
if (input != null) {
world.spawnEntityInWorld(new EntityItem(world, x, y, z, input));
}
if (output != null) {
world.spawnEntityInWorld(new EntityItem(world, x, y, z, output));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return Blocks.planks.getIcon(0, 1);
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
return createNewTileEntity(world, metadata);
}
@Override
public TileEntity createNewTileEntity(World world, int var2) {
return new TileVisweaver();
}
@Override
public int getRenderType() {
return ThaumicHorizons.blockVisweaverRI;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
}
@@ -0,0 +1,71 @@
package com.kentington.thaumichorizons.common.container;
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;
import com.kentington.thaumichorizons.common.tiles.TileVisweaver;
import thaumcraft.common.container.SlotOutput;
public class ContainerVisweaver extends Container {
TileVisweaver visweaver;
public ContainerVisweaver(InventoryPlayer inv, TileVisweaver visweaver) {
this.visweaver = visweaver;
addSlotToContainer(new Slot(visweaver, 0, 20, 30));
addSlotToContainer(new SlotOutput(visweaver, 1, 140, 30));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack itemstack = null;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack stackInSlot = slot.getStack();
itemstack = stackInSlot.copy();
if (index == 0 || index == 1) {
if (!this.mergeItemStack(stackInSlot, 2, 38, true)) {
return null;
}
slot.onSlotChange(stackInSlot, itemstack);
} else {
if (!this.mergeItemStack(stackInSlot, 0, 1, false)) {
return null;
}
}
if (stackInSlot.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (stackInSlot.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, stackInSlot);
}
return itemstack;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return visweaver.isUseableByPlayer(player);
}
}
@@ -31,7 +31,7 @@ public class EntityAIHurtByTargetTH extends EntityAITargetTH {
this.field_142052_b = this.taskOwner.func_142015_aE();
if (this.entityCallsForHelp) {
final double d0 = this.getTargetDistance();
final List<EntityLiving> list = this.taskOwner.worldObj.getEntitiesWithinAABB(
final List<? extends EntityLiving> list = this.taskOwner.worldObj.getEntitiesWithinAABB(
this.taskOwner.getClass(),
AxisAlignedBB.getBoundingBox(
this.taskOwner.posX,
@@ -5,7 +5,6 @@
package com.kentington.thaumichorizons.common.lib;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -25,7 +24,6 @@ import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
@@ -69,7 +67,8 @@ import com.kentington.thaumichorizons.common.lib.networking.PacketPlayerInfusion
import com.kentington.thaumichorizons.common.tiles.TileSoulBeacon;
import com.kentington.thaumichorizons.common.tiles.TileVat;
import baubles.api.BaublesApi;
import baubles.common.container.InventoryBaubles;
import baubles.common.lib.PlayerHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -82,6 +81,7 @@ import thaumcraft.common.config.ConfigBlocks;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.entities.EntityAspectOrb;
import thaumcraft.common.entities.EntityFollowingItem;
import thaumcraft.common.entities.EntityPermanentItem;
import thaumcraft.common.items.relics.ItemHandMirror;
import thaumcraft.common.lib.network.fx.PacketFXShield;
import thaumcraft.common.lib.utils.EntityUtils;
@@ -678,6 +678,7 @@ public class EventHandlerEntity {
}
if (!event.entity.worldObj.isRemote && event.entity instanceof final EntityPlayer player
&& event.entityLiving.getHealth() - event.ammount <= 0.0f) {
// Clear player infusions
if (prop.tumorWarpPermanent > 0 || prop.tumorWarp > 0 || prop.tumorWarpTemp > 0) {
Thaumcraft.proxy.getPlayerKnowledge()
.addWarpPerm(event.entity.getCommandSenderName(), prop.tumorWarpPermanent);
@@ -687,150 +688,136 @@ public class EventHandlerEntity {
.addWarpTemp(event.entity.getCommandSenderName(), prop.tumorWarpTemp);
}
prop.resetPlayerInfusions();
final IInventory baubles = BaublesApi.getBaubles(player);
for (int a = 0; a < 4; ++a) {
final ItemStack amulet = baubles.getStackInSlot(a);
if (amulet != null) {
if (amulet.getItem() instanceof ItemAmuletMirror) {
boolean transportedSomething = false;
for (int i = 0; i < player.inventory.armorInventory.length; ++i) {
final ItemStack item = player.inventory.armorInventory[i];
if (item != null && ItemHandMirror.transport(amulet, item, player, player.worldObj)) {
transportedSomething = true;
player.inventory.armorInventory[i] = null;
}
}
for (int i = 0; i < player.inventory.mainInventory.length; ++i) {
final ItemStack item = player.inventory.mainInventory[i];
if (item != null && ItemHandMirror.transport(amulet, item, player, player.worldObj)) {
transportedSomething = true;
player.inventory.mainInventory[i] = null;
}
}
for (int b = 0; b < 4; ++b) {
if (a != b && baubles.getStackInSlot(b) != null
&& ItemHandMirror
.transport(amulet, baubles.getStackInSlot(b), player, player.worldObj)) {
transportedSomething = true;
baubles.setInventorySlotContents(b, null);
}
}
if (transportedSomething) {
PacketHandler.INSTANCE.sendToAllAround(
new PacketFXContainment(
player.posX,
player.posY + player.getEyeHeight(),
player.posZ),
new NetworkRegistry.TargetPoint(
player.worldObj.provider.dimensionId,
player.posX,
player.posY,
player.posZ,
32.0));
player.worldObj.playSoundEffect(
// Mirrored Amulet returning items
ItemStack amulet = null;
for (ItemStack bauble : PlayerHandler.getPlayerBaubles(player).stackList) {
if (bauble != null && bauble.getItem() instanceof ItemAmuletMirror) {
amulet = bauble;
break;
}
}
if (amulet != null) {
boolean transportedSomething = false;
for (int i = 0; i < player.inventory.armorInventory.length; ++i) {
final ItemStack item = player.inventory.armorInventory[i];
if (item != null && ItemHandMirror.transport(amulet, item, player, player.worldObj)) {
transportedSomething = true;
player.inventory.armorInventory[i] = null;
}
}
for (int i = 0; i < player.inventory.mainInventory.length; ++i) {
final ItemStack item = player.inventory.mainInventory[i];
if (item != null && ItemHandMirror.transport(amulet, item, player, player.worldObj)) {
transportedSomething = true;
player.inventory.mainInventory[i] = null;
}
}
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
int amuletIndex = 0;
for (int i = 0; i < baubles.stackList.length; ++i) {
final ItemStack item = baubles.stackList[i];
if (item == amulet) {
amuletIndex = i;
} else if (item != null && ItemHandMirror.transport(amulet, item, player, player.worldObj)) {
transportedSomething = true;
baubles.stackList[i] = null;
}
}
PlayerHandler.setPlayerBaubles(player, baubles);
if (transportedSomething) {
baubles.stackList[amuletIndex] = null;
PlayerHandler.setPlayerBaubles(player, baubles);
PacketHandler.INSTANCE.sendToAllAround(
new PacketFXContainment(
player.posX,
player.posY + player.getEyeHeight(),
player.posZ,
"thaumcraft:craftfail",
1.0f,
1.0f);
baubles.setInventorySlotContents(a, null);
player.inventory.markDirty();
baubles.markDirty();
final ItemStack droppedPearl = new ItemStack(ConfigItems.itemEldritchObject, 1, 3);
final EntityItem drop = new EntityItem(
player.worldObj,
player.posZ),
new NetworkRegistry.TargetPoint(
player.worldObj.provider.dimensionId,
player.posX,
player.posY,
player.posZ,
droppedPearl);
player.worldObj.spawnEntityInWorld(drop);
break;
}
break;
}
32.0));
player.worldObj.playSoundEffect(
player.posX,
player.posY + player.getEyeHeight(),
player.posZ,
"thaumcraft:craftfail",
1.0f,
1.0f);
player.inventory.markDirty();
final ItemStack droppedPearl = new ItemStack(ConfigItems.itemEldritchObject, 1, 3);
final EntityPermanentItem drop = new EntityPermanentItem(
player.worldObj,
player.posX,
player.posY,
player.posZ,
droppedPearl);
player.worldObj.spawnEntityInWorld(drop);
}
}
}
if (!event.entity.worldObj.isRemote && event.entityLiving instanceof EntityPlayer
&& event.entityLiving.getHealth() - event.ammount <= 0.0f
&& event.entityLiving.getEntityData().getBoolean("soulBeacon")) {
final EntityPlayer player = (EntityPlayer) event.entity;
final int dim = player.getEntityData().getInteger("soulBeaconDim");
final World world = MinecraftServer.getServer().worldServerForDimension(dim);
final int x = player.getEntityData().getIntArray("soulBeaconCoords")[0];
final int y = player.getEntityData().getIntArray("soulBeaconCoords")[1];
final int z = player.getEntityData().getIntArray("soulBeaconCoords")[2];
if (world.getTileEntity(x, y, z) instanceof TileSoulBeacon
&& world.getTileEntity(x, y - 1, z) instanceof TileVat
&& ((TileVat) world.getTileEntity(x, y - 1, z)).mode == 4) {
event.setCanceled(true);
if (!world.isRemote) {
world.createExplosion(
// Return to Soul Beacon before death
if (player.getEntityData().getBoolean("soulBeacon")) {
final int dim = player.getEntityData().getInteger("soulBeaconDim");
final World beaconWorld = MinecraftServer.getServer().worldServerForDimension(dim);
final World playerWorld = player.worldObj;
final int x = player.getEntityData().getIntArray("soulBeaconCoords")[0];
final int y = player.getEntityData().getIntArray("soulBeaconCoords")[1];
final int z = player.getEntityData().getIntArray("soulBeaconCoords")[2];
if (beaconWorld.getTileEntity(x, y, z) instanceof TileSoulBeacon
&& beaconWorld.getTileEntity(x, y - 1, z) instanceof TileVat vat
&& vat.mode == 4) {
event.setCanceled(true);
event.ammount = 0.0f;
playerWorld.createExplosion(
null,
player.posX,
player.posY + player.getEyeHeight(),
player.posZ,
0.0f,
false);
for (int a2 = 0; a2 < 25; ++a2) {
final int xx = (int) player.posX + world.rand.nextInt(8) - world.rand.nextInt(8);
final int yy = (int) player.posY + world.rand.nextInt(8) - world.rand.nextInt(8);
final int zz = (int) player.posZ + world.rand.nextInt(8) - world.rand.nextInt(8);
if (world.isAirBlock(xx, yy, zz)) {
for (int i = 0; i < 25; ++i) {
final int xx = (int) player.posX + playerWorld.rand.nextInt(8) - playerWorld.rand.nextInt(8);
final int yy = (int) player.posY + playerWorld.rand.nextInt(8) - playerWorld.rand.nextInt(8);
final int zz = (int) player.posZ + playerWorld.rand.nextInt(8) - playerWorld.rand.nextInt(8);
if (playerWorld.isAirBlock(xx, yy, zz)) {
if (yy <= (int) player.posY + 1) {
world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGoo, 8, 3);
playerWorld.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGoo, 8, 3);
} else {
world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGas, 8, 3);
playerWorld.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGas, 8, 3);
}
}
}
}
player.inventory.dropAllItems();
final IInventory baubles2 = BaublesApi.getBaubles(player);
for (int j = 0; j < 4; ++j) {
if (baubles2.getStackInSlot(j) != null) {
final EntityItem bauble = new EntityItem(
world,
player.posX,
player.posY,
player.posZ,
baubles2.getStackInSlot(j));
world.spawnEntityInWorld(bauble);
baubles2.setInventorySlotContents(j, null);
player.inventory.dropAllItems();
for (ItemStack bauble : PlayerHandler.getPlayerBaubles(player).stackList) {
if (bauble == null) {
continue;
}
player.func_146097_a(bauble, true, false);
}
PlayerHandler.clearPlayerBaubles(player);
player.inventory.markDirty();
PacketHandler.INSTANCE.sendTo(new PacketNoMoreItems(), (EntityPlayerMP) player);
player.curePotionEffects(new ItemStack(Items.milk_bucket));
player.heal(Float.MAX_VALUE);
if (dim != player.worldObj.provider.dimensionId) {
player.travelToDimension(dim);
}
player.setPositionAndUpdate(x + 0.5, y - 2.5, z + 0.5);
Thaumcraft.proxy.blockSparkle(beaconWorld, x, y - 2, z, 16777215, 20);
Thaumcraft.proxy.blockSparkle(beaconWorld, x, y - 3, z, 16777215, 20);
beaconWorld.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "thaumcraft:whispers", 1.0f, beaconWorld.rand.nextFloat());
this.applyPlayerInfusions(player, vat);
vat.selfInfusions = new int[12];
vat.mode = 0;
vat.setEntityContained(player);
beaconWorld.getTileEntity(x, y - 1, z).markDirty();
player.worldObj.markBlockForUpdate(x, y - 1, z);
}
baubles2.markDirty();
player.inventory.markDirty();
PacketHandler.INSTANCE.sendTo(new PacketNoMoreItems(), (EntityPlayerMP) player);
player.curePotionEffects(new ItemStack(Items.milk_bucket));
player.heal(999.0f);
if (dim != player.worldObj.provider.dimensionId) {
player.travelToDimension(dim);
}
player.setPositionAndUpdate(x + 0.5, y - 2.5, z + 0.5);
Thaumcraft.proxy.blockSparkle(world, x, y - 2, z, 16777215, 20);
Thaumcraft.proxy.blockSparkle(world, x, y - 3, z, 16777215, 20);
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "thaumcraft:whispers", 1.0f, world.rand.nextFloat());
this.applyPlayerInfusions(player, (TileVat) world.getTileEntity(x, y - 1, z));
((TileVat) world.getTileEntity(x, y - 1, z)).selfInfusions = new int[12];
((TileVat) world.getTileEntity(x, y - 1, z)).mode = 0;
((TileVat) world.getTileEntity(x, y - 1, z)).setEntityContained(player);
world.getTileEntity(x, y - 1, z).markDirty();
player.worldObj.markBlockForUpdate(x, y - 1, z);
}
} else if (event.entity.worldObj.isRemote && event.entityLiving instanceof EntityPlayer
&& event.entityLiving.getHealth() - event.ammount <= 0.0f
&& event.entityLiving.getEntityData().getBoolean("soulBeacon")) {
final EntityPlayer player = (EntityPlayer) event.entity;
Arrays.fill(player.inventory.mainInventory, null);
Arrays.fill(player.inventory.armorInventory, null);
final IInventory baubles3 = BaublesApi.getBaubles(player);
baubles3.setInventorySlotContents(0, null);
baubles3.setInventorySlotContents(1, null);
baubles3.setInventorySlotContents(2, null);
baubles3.setInventorySlotContents(3, null);
}
}
}
void applyPlayerInfusions(final EntityPlayer player, final TileVat tile) {
@@ -0,0 +1,26 @@
package com.kentington.thaumichorizons.common.lib;
import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import it.unimi.dsi.fastutil.Hash;
/*
* Simple hashing strategy that can properly compare items
*/
public class ItemHashStrategy implements Hash.Strategy<ItemStack> {
@Override
public int hashCode(@Nullable ItemStack key) {
return key == null ? 0 : Objects.hash(key.getItem(), key.getItemDamage());
}
@Override
public boolean equals(@Nullable ItemStack key, @Nullable ItemStack value) {
if (key == null || value == null) return false;
return key.isItemEqual(value);
}
}
@@ -5,9 +5,9 @@
package com.kentington.thaumichorizons.common.lib.networking;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.IInventory;
import net.minecraft.client.entity.EntityClientPlayerMP;
import baubles.api.BaublesApi;
import baubles.common.lib.PlayerHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -19,12 +19,9 @@ public class PacketNoMoreItems implements IMessage, IMessageHandler<PacketNoMore
@SideOnly(Side.CLIENT)
public IMessage onMessage(final PacketNoMoreItems message, final MessageContext ctx) {
Minecraft.getMinecraft().thePlayer.inventory.clearInventory(null, -1);
final IInventory baubles = BaublesApi.getBaubles(Minecraft.getMinecraft().thePlayer);
baubles.setInventorySlotContents(0, null);
baubles.setInventorySlotContents(1, null);
baubles.setInventorySlotContents(2, null);
baubles.setInventorySlotContents(3, null);
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
player.inventory.clearInventory(null, -1);
PlayerHandler.clearPlayerBaubles(player);
return null;
}
@@ -231,7 +231,7 @@ public class TileTransductionAmplifier extends TileThaumcraft {
}
}
if (transducers > 1 && this.count % 50 == 0) {
final List<Entity> targets = (List<Entity>) this.worldObj.getEntitiesWithinAABB(
final List<EntityLivingBase> targets = this.worldObj.getEntitiesWithinAABB(
EntityLivingBase.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
@@ -240,7 +240,7 @@ public class TileTransductionAmplifier extends TileThaumcraft {
this.xCoord + 1,
this.yCoord + 1,
this.zCoord + 1).expand(10.0, 10.0, 10.0));
if (targets != null && targets.size() > 0) {
if (targets != null && !targets.isEmpty()) {
for (final Entity target : targets) {
PacketHandler.INSTANCE.sendToAllAround(
new PacketFXBlockZap(
@@ -1048,7 +1048,7 @@ public class TileVat extends TileThaumcraft implements IAspectContainer, IEssent
}
private void inEvZap(final boolean all) {
final List<Entity> targets = (List<Entity>) this.worldObj.getEntitiesWithinAABB(
final List<EntityLivingBase> targets = this.worldObj.getEntitiesWithinAABB(
EntityLivingBase.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
@@ -1057,7 +1057,7 @@ public class TileVat extends TileThaumcraft implements IAspectContainer, IEssent
this.xCoord + 1,
this.yCoord + 1,
this.zCoord + 1).expand(10.0, 10.0, 10.0));
if (targets != null && targets.size() > 0) {
if (targets != null && !targets.isEmpty()) {
for (final Entity target : targets) {
thaumcraft.common.lib.network.PacketHandler.INSTANCE.sendToAllAround(
new PacketFXBlockZap(
@@ -0,0 +1,276 @@
package com.kentington.thaumichorizons.common.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import com.kentington.thaumichorizons.api.VisweaverRecipe;
import com.kentington.thaumichorizons.api.VisweaverRecipeMap;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.visnet.VisNetHandler;
public class TileVisweaver extends TileEntity implements IInventory {
private static final String TAG_INTERNAL_VIS = "internalVis";
private static final String TAG_REQUIRED_VIS = "requiredVis";
private static final String TAG_WORKING = "working";
private static final String TAG_ASPECT = "cvType";
private static final String TAG_INPUT = "currentInput";
private static final String TAG_OUTPUT = "currentOutput";
private int tickCounter = -1;
private int internalVis = 0;
private boolean working = false;
private ItemStack currentOutput;
private ItemStack currentInput;
private Aspect cvType;
private int requiredVis;
ItemStack[] inventorySlots = new ItemStack[2];
@Override
public void updateEntity() {
tickCounter++;
if (worldObj.isRemote) return;
if (working) {
ItemStack currentStack = getStackInSlot(0);
if (currentStack == null || currentInput == null || !currentStack.isItemEqual(currentInput)) {
flushRecipe();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
if (tickCounter % 20 != 0) return;
if (!working) {
recipeCheck();
} else {
internalVis += VisNetHandler.drainVis(this.worldObj, this.xCoord, this.yCoord, this.zCoord, cvType, 500);
progressRecipe();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
private void progressRecipe() {
if (internalVis >= requiredVis) {
internalVis -= requiredVis;
finishRecipe();
}
}
private void flushRecipe() {
internalVis = 0;
requiredVis = 0;
currentOutput = null;
currentInput = null;
cvType = null;
working = false;
}
private void recipeCheck() {
VisweaverRecipe recipe = VisweaverRecipeMap.lookup(getStackInSlot(0));
if (recipe != null) {
ItemStack output = recipe.getOutput();
if (canAddToSlot(output, 1) <= 0) return;
cvType = recipe.getCentivisType();
requiredVis = recipe.getCentivisCost();
currentOutput = output;
currentInput = recipe.getInput();
working = true;
}
}
private void finishRecipe() {
decrStackSize(0, 1);
addToSlot(currentOutput, 1);
ItemStack input = getStackInSlot(0);
if (input != null && currentInput.isItemEqual(input) && canAddToSlot(currentOutput, 1) > 0) {
progressRecipe();
} else {
flushRecipe();
recipeCheck();
}
}
@Override
public int getSizeInventory() {
return inventorySlots.length;
}
@Override
public ItemStack getStackInSlot(int slotIn) {
return inventorySlots[slotIn];
}
@Override
public ItemStack decrStackSize(int i, int j) {
if (inventorySlots[i] != null) {
ItemStack stackAt;
if (inventorySlots[i].stackSize <= j) {
stackAt = inventorySlots[i];
inventorySlots[i] = null;
} else {
stackAt = inventorySlots[i].splitStack(j);
if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null;
}
return stackAt;
}
return null;
}
/**
* Returns the amount of items from the input stack that can be stacked into this slot
*/
public int canAddToSlot(ItemStack input, int slot) {
ItemStack currentStack = getStackInSlot(slot);
if (currentStack == null) return Math.min(64, input.stackSize);
if (!currentStack.isItemEqual(input)) return 0;
return Math.min(input.stackSize, 64 - currentStack.stackSize);
}
public void addToSlot(ItemStack stack, int slot) {
int movable = canAddToSlot(stack, slot);
if (movable == 0) return;
ItemStack currentStack = getStackInSlot(slot);
ItemStack newStack = stack.copy();
if (currentStack == null) {
newStack.stackSize = movable;
setInventorySlotContents(slot, newStack);
} else {
currentStack.stackSize += movable;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack stack) {
inventorySlots[i] = stack;
}
@Override
public String getInventoryName() {
return "container.visweaver";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this
&& entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
}
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
readFromNBT(pkt.func_148857_g());
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
working = par1NBTTagCompound.getBoolean(TAG_WORKING);
internalVis = par1NBTTagCompound.getInteger(TAG_INTERNAL_VIS);
requiredVis = par1NBTTagCompound.getInteger(TAG_REQUIRED_VIS);
cvType = Aspect.getAspect(par1NBTTagCompound.getString(TAG_ASPECT));
currentInput = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag(TAG_INPUT));
currentOutput = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag(TAG_OUTPUT));
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
inventorySlots = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeToNBT(par1NBTTagCompound);
NBTTagCompound input = new NBTTagCompound();
NBTTagCompound output = new NBTTagCompound();
par1NBTTagCompound.setBoolean(TAG_WORKING, working);
par1NBTTagCompound.setInteger(TAG_INTERNAL_VIS, internalVis);
par1NBTTagCompound.setInteger(TAG_REQUIRED_VIS, requiredVis);
if (working) {
par1NBTTagCompound.setString(TAG_ASPECT, cvType.getTag());
par1NBTTagCompound.setTag(TAG_INPUT, currentInput.writeToNBT(input));
par1NBTTagCompound.setTag(TAG_OUTPUT, currentOutput.writeToNBT(output));
}
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
if (inventorySlots[var3] != null) {
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
inventorySlots[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
@Override
public S35PacketUpdateTileEntity getDescriptionPacket() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound);
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0;
}
public boolean isWorking() {
return working;
}
public int getTickCounter() {
return tickCounter;
}
public Aspect getCvType() {
return cvType;
}
public int getInternalVis() {
return internalVis;
}
public int getRequiredVis() {
return requiredVis;
}
}
@@ -231,6 +231,7 @@ tile.ThaumicHorizons_leviathan.name=Primordial Fossil
tile.ThaumicHorizons_gateway.name=Planar Gateway
tile.ThaumicHorizons_evanescent.name=Evanescent
tile.ThaumicHorizons_vatInterior.name=Vat Interior
tile.ThaumicHorizons_visweaver.name=Visweaver
###RESEARCH###
@@ -499,6 +500,9 @@ transductionAmplifier2=Pushing a node beyond its natural capacity has risks. A s
tc.research_name.vortexStabilizer=Vortex Attenuation
tc.research_text.vortexStabilizer=Putting nodes on a diet
vortexStabilizer1=The vast amount of vis present in hungry nodes has lured more than one apprentice to an early grave. Such an embarrassing end would not befit a thaumaturge of your stature, so you have developed a method of temporarily neutralizing such a node's pull.<BR>When provided with a redstone signal, the vortex attenuator projects a cerulean beam which suppresses flows in the thaumic field. Any hungry node struck by the beam will cease absorbing nearby material until the beam is removed.<BR>It is possible that the beam may also disrupt certain other phenomena...
tc.research_name.visweaver=Visweaver
tc.research_text.visweaver=Transmutation with centivis
visweaver1=With a deeper understanding of the primal aspects, you have begun to understand that some seemingly distinct items in the world are near identical in physical composition, made different only by a heavy imbalance of primal essentia.<BR>Using concentrated centivis, it should be possible to "nudge" the essential balance and transmute certain items.
tc.research_name.planarKeystone=Planar Gateways
tc.research_text.planarKeystone=Thinking with portals
planarKeystone1=It takes tremendous effort to create a pocket plane, yet it is all too easy to permanently lose access to your creation. Now you have developed a much more robust method of dimensional transport which no longer relies on the original planar breach remaining open.<BR>This method relies on two crucial components: an object tied to the target dimension, known as a planar keystone, and a gateway inside which a stable portal can form.<BR>A newly created keystone must be imprinted before it will function: right-click with the keystone in hand while you occupy a pocket plane.
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB