Skip to content

Commit d916369

Browse files
committed
Added jar texturing, fixed many a bug.
1 parent 8df6937 commit d916369

20 files changed

+417
-159
lines changed

forge2/src/main/java/flaxbeard/thaumicexploration/ThaumicExploration.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
import flaxbeard.thaumicexploration.item.ItemChestSeal;
4242
import flaxbeard.thaumicexploration.item.ItemChestSealLinked;
4343
import flaxbeard.thaumicexploration.item.ItemCrystalArmor;
44-
import flaxbeard.thaumicexploration.item.ItemJarSealLinked;
44+
import flaxbeard.thaumicexploration.item.focus.ItemFocusNecromancy;
4545
import flaxbeard.thaumicexploration.packet.TXPacketHandler;
4646
import flaxbeard.thaumicexploration.research.ModRecipes;
4747
import flaxbeard.thaumicexploration.research.ModResearch;
48+
import flaxbeard.thaumicexploration.tile.TileCrystalAdvanced;
4849
import flaxbeard.thaumicexploration.tile.TileEntityBoundChest;
4950
import flaxbeard.thaumicexploration.tile.TileEntityBoundJar;
50-
import flaxbeard.thaumicexploration.tile.TileCrystalAdvanced;
5151
import flaxbeard.thaumicexploration.tile.TileEntityThinkTankBookshelf;
5252
import flaxbeard.thaumicexploration.wand.WandRodAmberOnUpdate;
5353
import flaxbeard.thaumicexploration.wand.WandRodTransmutationOnUpdate;
5454

5555

56-
@Mod(modid = "ThaumicExploration", name = "Thaumic Exploration", version = "0.0.1", dependencies="required-after:Thaumcraft")
56+
@Mod(modid = "ThaumicExploration", name = "Thaumic Exploration", version = "0.1.1", dependencies="required-after:Thaumcraft")
5757
@NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"tExploration"}, packetHandler = TXPacketHandler.class)
5858
public class ThaumicExploration {
5959

@@ -136,7 +136,7 @@ public void preInit(FMLPreInitializationEvent event) {
136136
public void load(FMLInitializationEvent event) {
137137
//EventHandler
138138
MinecraftForge.EVENT_BUS.register(new TXEventHandler());
139-
139+
140140
//Tiles
141141
GameRegistry.registerTileEntity(TileEntityBoundChest.class, "tileEntityBoundChest");
142142
GameRegistry.registerTileEntity(TileEntityBoundJar.class, "tileEntityBoundJar");
@@ -145,8 +145,9 @@ public void load(FMLInitializationEvent event) {
145145

146146
//Blocks
147147
thinkTankBookshelf = new BlockThinkTankBookshelf(205, Material.wood).setUnlocalizedName("thinkTankBookshelf").setCreativeTab(CreativeTabs.tabBlock);
148-
boundChest = new BlockBoundChest(boundChestID, 0).setUnlocalizedName("boundChest").setCreativeTab(CreativeTabs.tabBlock);
149-
boundJar = new BlockBoundJar(boundJarID).setUnlocalizedName("boundJar").setCreativeTab(CreativeTabs.tabBlock);
148+
boundChest = new BlockBoundChest(boundChestID, 0).setUnlocalizedName("boundChest");
149+
boundJar = new BlockBoundJar(boundJarID).setUnlocalizedName("boundJar");
150+
150151
GameRegistry.registerBlock(boundChest, "boundChest");
151152
GameRegistry.registerBlock(boundJar, "boundJar");
152153
GameRegistry.registerBlock(thinkTankBookshelf, "thinkTankBookshelf");
@@ -159,11 +160,11 @@ public void load(FMLInitializationEvent event) {
159160
chestSeal = (new ItemChestSeal(chestSealID).setCreativeTab(CreativeTabs.tabBlock).setTextureName("thaumicexploration:sealChest").setUnlocalizedName("thaumicexploration:chestSeal"));
160161
chestSealLinked = (new ItemChestSealLinked(chestSealLinkedID).setTextureName("thaumicexploration:sealChest").setUnlocalizedName("thaumicexploration:chestSeal"));
161162
jarSeal = (new ItemChestSeal(jarSealID).setCreativeTab(CreativeTabs.tabBlock).setTextureName("thaumicexploration:sealJar").setUnlocalizedName("thaumicexploration:jarSeal"));
162-
jarSealLinked = (new ItemJarSealLinked(jarSealLinkedID).setTextureName("thaumicexploration:sealJar").setUnlocalizedName("thaumicexploration:jarSeal"));
163+
jarSealLinked = (new ItemChestSealLinked(jarSealLinkedID).setTextureName("thaumicexploration:sealJar").setUnlocalizedName("thaumicexploration:jarSeal"));
163164

164165
armorMaterialCrystal = EnumHelper.addArmorMaterial("CRYSTAL", 25, new int[] { 2, 6, 5, 2 }, 25);
165166
helmetCrystal = (new ItemCrystalArmor(helmetCrystalID, armorMaterialCrystal, 2, 0)).setUnlocalizedName("thaumicexploration:helmetCrystal").setCreativeTab(CreativeTabs.tabBlock).setTextureName("thaumicexploration:rodTransmutation");
166-
chestCrystal = (new ItemCrystalArmor(chestCrystalID, armorMaterialCrystal, 1, 1)).setUnlocalizedName("thaumicexploration:chestCrystal").setCreativeTab(CreativeTabs.tabBlock).setTextureName("thaumicexploration:rodTransmutation");
167+
chestCrystal = (new ItemFocusNecromancy(chestCrystalID)).setUnlocalizedName("thaumicexploration:chestCrystal").setCreativeTab(CreativeTabs.tabBlock).setTextureName("thaumicexploration:rodTransmutation");
167168

168169
//Wands
169170
WAND_ROD_AMBER = new WandRod("amber",75,new ItemStack(ThaumicExploration.amberCore),1,new WandRodAmberOnUpdate(), new ResourceLocation("thaumicexploration:textures/models/rodAmber.png"));

forge2/src/main/java/flaxbeard/thaumicexploration/block/BlockBoundJar.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5,
7474
drop = new ItemStack(ConfigBlocks.blockJar);
7575
}
7676
dropBlockAsItem_do(par1World, par2, par3, par4, drop);
77-
77+
drop = new ItemStack(ThaumicExploration.blankSeal, 1, 15-((TileEntityBoundJar)te).getSealColor());
78+
dropBlockAsItem_do(par1World, par2, par3, par4, drop);
7879
}
7980

8081
//super.breakBlock(par1World, par2, par3, par4, par5, par6);
@@ -110,9 +111,10 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
110111
}
111112
amount = phial.getAspects(helditem).getAmount(aspect);
112113
}
113-
if (helditem != null && jar.amount <= (jar.maxAmount - 8) && (jar.aspect == null || (jar.aspect != null && jar.aspect == aspect && amount >= 8)))
114+
if (helditem != null && jar.amount <= (jar.maxAmount - 8) && ((jar.aspect != null && jar.aspect != aspect && jar.amount == 0) || jar.aspect == null || (jar.aspect != null && jar.aspect == aspect && amount >= 8)))
114115
{
115116
player.getHeldItem().stackSize--;
117+
jar.aspect = aspect;
116118
jar.addToContainer(aspect, amount);
117119
player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence, 1 ,0));
118120
world.playSoundAtEntity(player, "liquid.swim", 0.25F, 1.0F);

forge2/src/main/java/flaxbeard/thaumicexploration/client/ClientProxy.java

+3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
import cpw.mods.fml.client.registry.ClientRegistry;
44
import flaxbeard.thaumicexploration.client.render.TileEntityBoundChestRender;
5+
import flaxbeard.thaumicexploration.client.render.TileEntityBoundJarRender;
56
import flaxbeard.thaumicexploration.client.render.TileEntityThinkTankBookshelfRender;
67
import flaxbeard.thaumicexploration.common.CommonProxy;
78
import flaxbeard.thaumicexploration.tile.TileEntityBoundChest;
9+
import flaxbeard.thaumicexploration.tile.TileEntityBoundJar;
810
import flaxbeard.thaumicexploration.tile.TileEntityThinkTankBookshelf;
911
public class ClientProxy extends CommonProxy
1012
{
1113

1214
@Override
1315
public void registerRenderers()
1416
{
17+
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBoundJar.class, new TileEntityBoundJarRender());
1518
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBoundChest.class, new TileEntityBoundChestRender());
1619
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThinkTankBookshelf.class, new TileEntityThinkTankBookshelfRender());
1720

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,57 @@
11
package flaxbeard.thaumicexploration.client.render;
22

3+
import org.lwjgl.opengl.GL11;
4+
5+
import net.minecraft.entity.passive.EntitySheep;
6+
import net.minecraft.tileentity.TileEntity;
7+
import net.minecraft.util.ResourceLocation;
38
import thaumcraft.client.renderers.tile.TileJarRenderer;
9+
import thaumcraft.common.tiles.TileJar;
10+
import flaxbeard.thaumicexploration.client.render.model.ModelJarOverlay;
11+
import flaxbeard.thaumicexploration.tile.TileEntityBoundJar;
412

513
public class TileEntityBoundJarRender extends TileJarRenderer {
14+
private ModelJarOverlay model = new ModelJarOverlay();
15+
private static final ResourceLocation overlayn = new ResourceLocation("thaumicexploration:textures/blocks/boundchestoverlaynone.png");
16+
private static final ResourceLocation overlay0 = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlay0.png");
17+
private static final ResourceLocation seal = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlayseal.png");
18+
private static final ResourceLocation overlay1 = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlay1.png");
19+
private static final ResourceLocation overlay2 = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlay2.png");
20+
private static final ResourceLocation overlay3 = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlay3.png");
21+
private static final ResourceLocation overlay4 = new ResourceLocation("thaumicexploration:textures/blocks/boundjaroverlay4.png");
22+
private static final ResourceLocation[] overlays = {overlayn,overlay0,overlay1,overlay2,overlay3,overlay4};
23+
public void renderTileEntityAt(TileJar tile, double x, double y, double z, float f)
24+
{
25+
super.renderTileEntityAt(tile, x, y, z, f);
26+
GL11.glPushMatrix();
27+
GL11.glTranslatef((float)x, (float)y+0.5F, (float)z+1);
28+
GL11.glScalef(1.0F, -1.0F, -1.0F);
29+
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
30+
int j = ((TileEntityBoundJar) tile).getSealColor();
31+
float colormod = 1.0F;
32+
GL11.glColor4f(colormod * EntitySheep.fleeceColorTable[j][0], colormod * EntitySheep.fleeceColorTable[j][1], colormod * EntitySheep.fleeceColorTable[j][2], 0.9F);
33+
int ticks = ((TileEntityBoundJar)tile).getAccessTicks();
34+
if (ticks > 0) {
35+
double divisor = (80/6) + 0.0001;
36+
double frame = ((ticks-1) / divisor)-1;
37+
int trueFrame = (int) Math.ceil(frame+0.5);
38+
if (trueFrame > 5) {
39+
trueFrame = 5;
40+
}
41+
if (trueFrame < 0) {
42+
trueFrame = 0;
43+
}
44+
this.bindTexture(overlays[trueFrame]);
45+
}
46+
else
47+
{
48+
this.bindTexture(overlays[0]);
49+
}
50+
this.model.renderAll();
51+
this.bindTexture(seal);
52+
this.model.renderAll();
53+
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
54+
GL11.glPopMatrix();
55+
}
656

757
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package flaxbeard.thaumicexploration.client.render.model;
2+
3+
import net.minecraft.client.model.ModelBase;
4+
import net.minecraft.client.model.ModelRenderer;
5+
import org.lwjgl.opengl.GL11;
6+
7+
public class ModelJarOverlay
8+
extends ModelBase
9+
{
10+
ModelRenderer Core;
11+
ModelRenderer Brine;
12+
ModelRenderer Lid;
13+
14+
public ModelJarOverlay()
15+
{
16+
this.textureWidth = 64;
17+
this.textureHeight = 32;
18+
19+
this.Core = new ModelRenderer(this, 0, 0);
20+
this.Core.addBox(-6.0F, -12.0F, -6.0F, 12, 12, 12);
21+
this.Core.setRotationPoint(0.0F, 0.0F, 0.0F);
22+
this.Core.setTextureSize(64, 32);
23+
this.Core.mirror = true;
24+
25+
this.Lid = new ModelRenderer(this, 0, 24);
26+
this.Lid.addBox(-3.0F, -0.25F, -3.0F, 6, 2, 6);
27+
this.Lid.setRotationPoint(0.0F, -14.0F, 0.0F);
28+
this.Lid.setTextureSize(64, 32);
29+
this.Lid.mirror = true;
30+
}
31+
32+
33+
public void renderAll()
34+
{
35+
this.Lid.render(0.0625F);
36+
this.Core.render(0.0625F);
37+
}
38+
}

forge2/src/main/java/flaxbeard/thaumicexploration/data/BoundJarWorldData.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public void readFromNBT(NBTTagCompound nbt) {
4343
public void writeToNBT(NBTTagCompound nbt) {
4444
nbt.setInteger("myColor", myColor);
4545
nbt.setInteger("aspectAmount", aspectAmount);
46-
nbt.setString("myAspect", myAspect.getTag());
46+
if (myAspect != null) {
47+
nbt.setString("myAspect", myAspect.getTag());
48+
}
4749
}
4850

4951
public void updateJarContents(Aspect aspect, int amount) {

forge2/src/main/java/flaxbeard/thaumicexploration/event/TXEventHandler.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,20 @@
33
import java.io.ByteArrayOutputStream;
44
import java.io.DataOutputStream;
55

6-
import thaumcraft.common.config.ConfigBlocks;
7-
86
import net.minecraft.block.Block;
97
import net.minecraft.entity.ai.EntityAIBase;
108
import net.minecraft.entity.ai.EntityAITaskEntry;
119
import net.minecraft.entity.monster.EntityZombie;
12-
import net.minecraft.item.ItemStack;
13-
import net.minecraft.nbt.NBTTagCompound;
1410
import net.minecraft.network.packet.Packet250CustomPayload;
1511
import net.minecraft.world.World;
1612
import net.minecraftforge.event.ForgeSubscribe;
1713
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
1814
import net.minecraftforge.event.world.WorldEvent;
15+
import thaumcraft.common.config.ConfigBlocks;
16+
import thaumcraft.common.tiles.TileJarFillable;
1917
import cpw.mods.fml.common.network.PacketDispatcher;
20-
import cpw.mods.fml.relauncher.Side;
21-
import cpw.mods.fml.relauncher.SideOnly;
2218
import flaxbeard.thaumicexploration.ThaumicExploration;
2319
import flaxbeard.thaumicexploration.data.TXWorldDataInfoWorldData;
24-
import flaxbeard.thaumicexploration.item.ItemBlankSeal;
2520
import flaxbeard.thaumicexploration.tile.TileEntityBoundChest;
2621
import flaxbeard.thaumicexploration.tile.TileEntityBoundJar;
2722

@@ -73,7 +68,7 @@ else if (event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z) == Th
7368
//System.out.println(event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z) + " " + ThaumicExploration.boundJar.blockID);
7469
if (event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z) == ConfigBlocks.blockJar.blockID && event.entityPlayer.worldObj.getBlockMetadata(event.x, event.y, event.z) == 0) {
7570
//System.out.println("itsa jar mario");
76-
if (event.entityPlayer.inventory.getCurrentItem() != null){
71+
if (event.entityPlayer.inventory.getCurrentItem() != null && ((TileJarFillable)event.entityPlayer.worldObj.getBlockTileEntity(event.x, event.y, event.z)).aspectFilter == null && ((TileJarFillable)event.entityPlayer.worldObj.getBlockTileEntity(event.x, event.y, event.z)).amount == 0){
7772
if (event.entityPlayer.inventory.getCurrentItem().itemID == ThaumicExploration.jarSeal.itemID) {
7873
type = 4;
7974
}
@@ -122,6 +117,7 @@ else if (event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z) == Th
122117
packet.channel = "tExploration";
123118
packet.data = bos.toByteArray();
124119
packet.length = bos.size();
120+
//PacketDispatcher.sendPacketToServer(packet);
125121
PacketDispatcher.sendPacketToAllPlayers(packet);
126122
//System.out.println("sent");
127123
}

forge2/src/main/java/flaxbeard/thaumicexploration/item/ItemJarSealLinked.java

-135
This file was deleted.

0 commit comments

Comments
 (0)