Skip to content

Commit

Permalink
Invisible menu bug attempt take 2; better altar rendering; code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sirolf2009 committed Jun 16, 2013
1 parent 62fae2e commit 452d75c
Show file tree
Hide file tree
Showing 22 changed files with 591 additions and 222 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
set ANT_HOME=C:\Program Files (x86)\Java\apache-ant-1.9.1
ant release >> build_log.txt
ant release
pause
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dir.development=../../
dir.release=C:\Users\Floris\Dropbox\Public\necromancy\releases
dir.release=C:/Users/Floris/Dropbox/Public/necromancy/releases
2 changes: 2 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

<target name="release">
<!-- Prep for the build -->
<record name="log.txt" action="start"/>
<input message="Mod version:" addproperty="release.mod.version" />
<input message="Minecraft version:" addproperty="release.minecraft.version" />
<antcall target="clean" />
Expand All @@ -88,5 +89,6 @@

<!-- Clean up the MCP source now that we are done -->
<antcall target="clean" />
<record name="log.txt" action="stop"/>
</target>
</project>
27 changes: 16 additions & 11 deletions common/com/sirolf2009/necromancy/Necromancy.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public class Necromancy {
public static int maxSpawn = -1;
public static boolean Christmas = false;
public static boolean renderSpecialScythe = false;
public static boolean renderModelScythe = false;
public static boolean renderModelNecronomicon = false;

public static Item apprenticeArmorHead;
public static Item apprenticeArmorTorso;
Expand Down Expand Up @@ -180,24 +182,27 @@ public void preInit(FMLPreInitializationEvent event) {

BucketBloodID = config.getItem("BloodStationary", 2621).getInt();
ScytheID = config.getItem("Scythe", 2622).getInt();
ItemID = config.getItem("main items", "item", 2623).getInt();
NecronomiconID = config.getItem("necronomicon", "item", 2624).getInt();
OrgansID = config.getItem("organs", "item", 2625).getInt();
BodyPartID = config.getItem("bodyparts", "item", 2626).getInt();
IsaacsHeadID = config.getItem("Isaac's Severed Head", "armor", 2627).getInt();
SpawnerID = config.getItem("spawner", "item", 2628).getInt();

Christmas = config.get("Other", "christmas hats", false).getBoolean(false);
renderSpecialScythe = config.get("Other", "special scythes (only for a select number of people)", true).getBoolean(false);
NecroVillagerID = config.get("Other", "NecroVillagerID", 666).getInt();
ItemID = config.getItem("item", "main items", 2623).getInt();
NecronomiconID = config.getItem("item", "necronomicon", 2624).getInt();
OrgansID = config.getItem("item", "organs", 2625).getInt();
BodyPartID = config.getItem("item", "bodyparts", 2626).getInt();
SpawnerID = config.getItem("item", "spawner", 2628).getInt();

IsaacsHeadID = config.getItem("armor", "Isaac's Severed Head", 2627).getInt();

renderModelNecronomicon = config.get("rendering", "Render Necronomicon Model", true).getBoolean(true);
renderModelNecronomicon = config.get("rendering", "Render Scythe Model", true).getBoolean(true);
Christmas = config.get("rendering", "christmas hats", false).getBoolean(false);

renderSpecialScythe = config.get("special scythes (only for a select number of people)", "Other", true).getBoolean(false);
NecroVillagerID = config.get("NecroVillagerID", "Other", 666).getInt();
if (config.hasChanged()) {
config.save();
}

NecroEntityBase.organID = OrgansID;

MinecraftForge.EVENT_BUS.register(eventHandler);


LanguageRegistry.instance().addStringLocalization("itemGroup.Necromancy", "en_US", "Necromancy");
LanguageRegistry.instance().addStringLocalization("itemGroup.BodyParts", "en_US", "Bodyparts");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sirolf2009.necromancy.client.model;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

import org.lwjgl.opengl.GL11;

/**
* @author Fabiulu Permission to use this model has been lend to sirolf2009 for
* the necromancy mod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.model.ModelBook;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

import com.sirolf2009.necromancy.Necromancy;
import com.sirolf2009.necromancy.client.model.ModelNecronomicon;
import com.sirolf2009.necromancy.item.ItemNecronomicon;
import com.sirolf2009.necromancy.lib.Reference;
Expand All @@ -16,54 +16,36 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


@SideOnly(Side.CLIENT)
public class ItemNecronomiconRenderer implements IItemRenderer {

public ModelNecronomicon modelInteractive = new ModelNecronomicon();
public ModelNecronomicon modelStatic = new ModelNecronomicon();
public ModelBook modelBook = new ModelBook();
public boolean isFancyBookSupported = true;

public String[] leftPageContent = {}, rightPageContent = {};

FontRenderer font = Minecraft.getMinecraft().fontRenderer;

public ItemNecronomiconRenderer() {

}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
return Necromancy.renderModelNecronomicon;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
return Necromancy.renderModelNecronomicon;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if(!isFancyBookSupported) {
if(type.equals(ItemRenderType.ENTITY)) {
renderNecronomiconStatic(0F, 0.2F, 0F, 180F, 1F, 1F, 0.004F);
} else if(type.equals(ItemRenderType.EQUIPPED)) {
renderNecronomiconInteractive(0.8F, 1.3F, 0.6F, 180F, 180F, 0F, 0.009F, (ItemNecronomicon) item.getItem());
} else if(type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
renderNecronomiconInteractive(0.8F, 1F, -1F, 20F, 100F, 160F, 0.01F, (ItemNecronomicon) item.getItem());
} else if(type.equals(ItemRenderType.INVENTORY)) {
renderNecronomiconStatic(-0.2F, 0.2F, 0.2F, 100F, -20F, -20F, 0.007F);
}
} else {
GL11.glPushMatrix();
GL11.glScalef(2F, 2F, 2F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Reference.LOC_RESOURCES_TEXTURES_MODELS + "/necronomicon.png");
modelBook.render(null, 111.29507F, 0.10000038F, 0.9000004F, 0F, 0, 0.0625F);
GL11.glPopMatrix();
}
if(isFancyBookSupported && GL11.glGetError() != GL11.GL_NO_ERROR) {
isFancyBookSupported = false;
if (type.equals(ItemRenderType.ENTITY)) {
renderNecronomiconStatic(0F, 0.2F, 0F, 180F, 1F, 1F, 0.004F);
} else if (type.equals(ItemRenderType.EQUIPPED)) {
renderNecronomiconInteractive(0.8F, 1.3F, 0.6F, 180F, 180F, 0F, 0.009F, (ItemNecronomicon) item.getItem());
} else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
renderNecronomiconInteractive(0.8F, 1F, -1F, 20F, 100F, 160F, 0.01F, (ItemNecronomicon) item.getItem());
} else if (type.equals(ItemRenderType.INVENTORY)) {
renderNecronomiconStatic(-0.2F, 0.2F, 0.2F, 100F, -20F, -20F, 0.007F);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sirolf2009.necromancy.client.renderer;

import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
Expand All @@ -10,30 +9,27 @@
import com.sirolf2009.necromancy.Necromancy;
import com.sirolf2009.necromancy.client.model.ModelScythe;
import com.sirolf2009.necromancy.client.model.ModelScytheSpecial;
import com.sirolf2009.necromancy.core.proxy.ClientProxy;
import com.sirolf2009.necromancy.lib.Reference;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ItemScytheRenderer implements IItemRenderer {

public static final int blockRenderId = RenderingRegistry.getNextAvailableRenderId();
public ModelScythe model = new ModelScythe();
public ModelScytheSpecial modelSpecial = new ModelScytheSpecial();
boolean isSpecial = false;

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
return Necromancy.renderModelNecronomicon;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
return Necromancy.renderModelNecronomicon;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;

import com.sirolf2009.necromancy.entity.EntityIsaacBlood;
import com.sirolf2009.necromancy.entity.EntityIsaacNormal;

public class RenderIsaacRanged extends RenderLiving {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ public void renderTileEntityAt(TileEntity tileentity, double d, double d1, doubl
private void renderAltar(TileEntityAltar entity, double x, double y, double z, float f) {
bindTextureByName(Reference.LOC_RESOURCES_TEXTURES_MODELS + "/altarTexture.png");
GL11.glPushMatrix();
GL11.glEnable(32826);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x, (float) y + 2.0F, (float) z + 1.0F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
Expand Down Expand Up @@ -168,17 +166,17 @@ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Ran
if (metadata == 1) {
d0 = par2 + .2F;
d1 = par3 + 0.7F;
d2 = par4 + 0.5F;
d2 = par4 + 0.2F;
}
if (metadata == 2) {
d0 = par2 + .2F;
d0 = par2 + .8F;
d1 = par3 + 0.7F;
d2 = par4 + 0.5F;
d2 = par4 + 0.2F;
}
if (metadata == 3) {
d0 = par2 + .2F;
d0 = par2 + .8F;
d1 = par3 + 0.7F;
d2 = par4 + 0.5F;
d2 = par4 + 0.8F;
}
double d3 = 0.5D;
double d4 = 0.27000001072883606D;
Expand Down
48 changes: 24 additions & 24 deletions common/com/sirolf2009/necromancy/command/CommandMinion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import java.util.ArrayList;
import java.util.List;

import cpw.mods.fml.common.network.PacketDispatcher;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.PacketDispatcher;

public class CommandMinion extends CommandBase {

Expand All @@ -21,55 +21,55 @@ public String getCommandName() {

@Override
public void processCommand(ICommandSender var1, String[] var2) {
if(var2.length >= 2) {
if (var2.length >= 2) {
EntityPlayerMP player = func_82359_c(var1, var1.getCommandSenderName());
NBTTagCompound nbt = player.getEntityData();
Packet250CustomPayload packet = null;
if(var2[0].equals("set")) {
if(var2[1].equals("aggressive")) {
if (var2[0].equals("set")) {
if (var2[1].equals("aggressive")) {
nbt.setBoolean("aggressive", true);
packet = new Packet250CustomPayload("NecromancyMod", new byte[] {0, 1});
packet = new Packet250CustomPayload("NecromancyMod", new byte[] { 0, 1 });
var1.sendChatToPlayer("Minions are set to aggressive");
} else if(var2[1].equals("passive")) {
} else if (var2[1].equals("passive")) {
nbt.setBoolean("aggressive", false);
packet = new Packet250CustomPayload("NecromancyMod", new byte[] {0, 0});
packet = new Packet250CustomPayload("NecromancyMod", new byte[] { 0, 0 });
var1.sendChatToPlayer("Minions are set to passive");
} else {
} else
throw new WrongUsageException("minion", new Object[0]);
}
} else if(var2[0].equals("friend")) {
} else if (var2[0].equals("friend")) {
nbt.setString(var2[1], "friend");
packet = new Packet250CustomPayload("NecromancyMod", new byte[] {1, (byte) func_82359_c(var1, var2[1]).entityId});
var1.sendChatToPlayer(var2[1]+ " is now a friend");
} else if(var2[0].equals("enemy")) {
packet = new Packet250CustomPayload("NecromancyMod", new byte[] { 1, (byte) func_82359_c(var1, var2[1]).entityId });
var1.sendChatToPlayer(var2[1] + " is now a friend");
} else if (var2[0].equals("enemy")) {
nbt.setString(var2[1], "enemy");
packet = new Packet250CustomPayload("NecromancyMod", new byte[] {2, (byte) func_82359_c(var1, var2[1]).entityId});
var1.sendChatToPlayer(var2[1]+ " is now an enemy");
} else {
packet = new Packet250CustomPayload("NecromancyMod", new byte[] { 2, (byte) func_82359_c(var1, var2[1]).entityId });
var1.sendChatToPlayer(var2[1] + " is now an enemy");
} else
throw new WrongUsageException("minion", new Object[0]);
}
PacketDispatcher.sendPacketToAllPlayers(packet);
}
}


@Override
public List<String> addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
List<String> result = new ArrayList<String>();
if(par2ArrayOfStr.length == 1) {
if (par2ArrayOfStr.length == 1) {
result.add("set");
result.add("friend");
result.add("enemy");
} else if(par2ArrayOfStr.length == 2) {
if(par2ArrayOfStr[0].equals("set")) {
} else if (par2ArrayOfStr.length == 2) {
if (par2ArrayOfStr[0].equals("set")) {
result.add("aggressive");
result.add("passive");
} else if(par2ArrayOfStr[0].equals("friend") || par2ArrayOfStr[0].equals("enemy")) {
for(int i = 0; i < getPlayers().length; i++)
} else if (par2ArrayOfStr[0].equals("friend") || par2ArrayOfStr[0].equals("enemy")) {
for (int i = 0; i < getPlayers().length; i++) {
result.add(getPlayers()[i]);
}
}
}
return result;
}

protected String[] getPlayers() {
return MinecraftServer.getServer().getAllUsernames();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class EventHandler {

@ForgeSubscribe
public void LivingDropsEvent(LivingDeathEvent evt) {
if (evt.entity instanceof EntityLiving && !evt.entity.worldObj.isRemote && rand.nextInt(100) <= 6-1) {
if (evt.entity instanceof EntityLiving && !evt.entity.worldObj.isRemote && rand.nextInt(100) <= 6 - 1) {
switch (rand.nextInt(7)) {
case 0:
evt.entity.entityDropItem(new ItemStack(Necromancy.organs, 1, 0), 1);
Expand Down
17 changes: 7 additions & 10 deletions common/com/sirolf2009/necromancy/core/handler/PacketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.List;
import java.util.Random;

import org.bouncycastle.util.encoders.Hex;

import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
Expand Down Expand Up @@ -94,14 +91,14 @@ public void onSmelting(EntityPlayer player, ItemStack item) {

@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
if(packet.data[0] == 0) {
if (packet.data[0] == 0) {
ClientProxy.mc.thePlayer.getEntityData().setBoolean("aggressive", packet.data[1] == 1);
} else if(packet.data[0] == 1) { //we're making friends :D
} else if (packet.data[0] == 1) { // we're making friends :D
EntityPlayer playerEntity = (EntityPlayer) ClientProxy.mc.theWorld.getEntityByID(packet.data[1] & 0xFF);
playerEntity.getEntityData().setString(playerEntity.username, "friend");
} else if(packet.data[0] == 2) { //who needs friends anyway
} else if (packet.data[0] == 2) { // who needs friends anyway
EntityPlayer playerEntity = (EntityPlayer) ClientProxy.mc.theWorld.getEntityByID(packet.data[1] & 0xFF);
System.out.println("player found by packet data "+playerEntity);
System.out.println("player found by packet data " + playerEntity);
playerEntity.getEntityData().setString(playerEntity.username, "enemy");
}
}
Expand All @@ -126,8 +123,8 @@ public Object buildComponent(StructureVillagePieceWeight villagePiece, Component
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
recipeList.add(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Item.book), new ItemStack(Necromancy.necronomicon)));
recipeList.add(new MerchantRecipe(new ItemStack(Item.emerald, new Random().nextInt(3)), null, new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size()-1))));
recipeList.add(new MerchantRecipe(new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size()-1)), null, new ItemStack(Item.emerald, new Random().nextInt(3))));
recipeList.add(new MerchantRecipe(new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size()-1)), null, new ItemStack(Item.emerald, new Random().nextInt(3))));
recipeList.add(new MerchantRecipe(new ItemStack(Item.emerald, new Random().nextInt(3)), null, new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size() - 1))));
recipeList.add(new MerchantRecipe(new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size() - 1)), null, new ItemStack(Item.emerald, new Random().nextInt(3))));
recipeList.add(new MerchantRecipe(new ItemStack(Necromancy.bodyparts, 1, random.nextInt(ItemBodyPart.necroEntities.size() - 1)), null, new ItemStack(Item.emerald, new Random().nextInt(3))));
}
}
Loading

0 comments on commit 452d75c

Please sign in to comment.