Jump to content

lorizz

Members
  • Posts

    80
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Nuubish nuub!

lorizz's Achievements

Stone Miner

Stone Miner (3/8)

-1

Reputation

  1. EDIT: I found a solution but it returns a NullPointer in the ".applyModifier(modifier);" method: @SubscribeEvent public void onEntityConstructing(EntityConstructing e) { if (e.entity instanceof EntityLiving) { EntityLiving entity = (EntityLiving) e.entity; String entityName = entity.getName(); MepCustomEntityLiving customEntity = MepEntityEnumRegistry.getEntityFromName(entityName); if (customEntity != null) { double newHealth = customEntity.getMaxHealth(); MepAttributeList attributeList = MepMain.ATTRIBUTELIST; if (!attributeList.exists()) { EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().thePlayer; AttributeModifier modifier = new AttributeModifier(entity.getUniqueID(), "maxHealthModifier", newHealth, 0); if (modifier != null) { entity.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth) .applyModifier(modifier); } } } } } EDIT 2: Solved, I just changed the event to LivingSpawnEvent and added a .removeAllModifiers(); method over the .applyModifier(modifier) one.
  2. Actually it works, but yes you're right, I need to change it. I cannot edit the attributes
  3. It's in another code, it works that's why I didn't post it here, I just need to change the attackDamage and maxHealth
  4. Hello, I'm making a huge mod for minecraft and I'm currently stuck at changing vanilla mob attributes, I did something like when a mob spawns, it register it to my custom entity and change the attributes from there, like this: When entity spawns: @SubscribeEvent public void onLivingSpawn(LivingSpawnEvent e) { if (e.entityLiving instanceof EntityMob) { EntityMob entity = (EntityMob) e.entityLiving; String entityName = entity.getDisplayName().getFormattedText().toLowerCase().replace("§r", ""); MepCustomEntityLiving customEntity = MepEntityEnumRegistry .getEntityFromName(entityName); entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(customEntity.getMaxHealth()); // entity.getEntityAttribute(SharedMonsterAttributes.attackDamage) // .setBaseValue(customEntity.getStat("strength")); System.out.println(customEntity.getName().toUpperCase() + " changed successfully"); } } MepCustomEntityLiving: package com.thelorizz.mep.customclass; import com.thelorizz.mep.MepMain; import com.thelorizz.mep.enumeration.MepEntityFunctions; public class MepCustomEntityLiving { public MepEntityFunctions entityFunctions; public double expGiven; public double strength; public double defense; public double maxHealth; public int tier; public String name; public MepCustomEntityLiving(int par1, String par2) { this.tier = par1; this.name = par2; this.expGiven = this.setByTier(tier, "expGiven"); this.strength = this.setByTier(tier, "strength"); this.defense = this.setByTier(tier, "defense"); this.maxHealth = this.setByTier(tier, "maxHealth"); } public double getStat(String par1) { switch (par1) { case "expGiven": return this.expGiven; case "strength": return this.strength; case "defense": return this.defense; default: return 0; } } public String getName() { return this.name; } public double getMaxHealth() { return this.maxHealth; } public int getTier() { return this.tier; } public static double random(int mult, int plus) { MepCustomEntityPlayer player = MepMain.instance.getCustomEntityPlayerInstance(); double levelModifier = player.getCurrentLevel() / 2; return (float) ((Math.random() * mult + plus) + levelModifier); } public static double set(int amount) { MepCustomEntityPlayer player = MepMain.instance.getCustomEntityPlayerInstance(); double levelModifier = player.getCurrentLevel() / 2; return (int) (amount + levelModifier); } public static double setByTier(int par1, String type) { switch (par1) { case 1: switch (type) { case "expGiven": return random(3, 4); case "strength": return random(2, 4); case "defense": return random(1, 4); case "maxHealth": return set(250); } case 2: switch (type) { case "expGiven": return random(7, 4); case "strength": return random(5, 4); case "defense": return random(7, 4); case "maxHealth": return set(400); } case 3: switch (type) { case "expGiven": return random(14, 4); case "strength": return random(16, 4); case "defense": return random(13, 4); case "maxHealth": return set(740); } case 4: switch (type) { case "expGiven": return random(28, 4); case "strength": return random(24, 4); case "defense": return random(21, 4); case "maxHealth": return set(1430); } default: return 0; } } } And the function that register the mob in the registry: public static MepCustomEntityLiving getEntityFromName(String name) { for(int i = 0; i < entities.length; i++) { if (name.equals(entities[i].getName())) { return new MepCustomEntityLiving(entities[i].getTier(), entities[i].getName()); } } return null; } But it doesn't work, it only works the exp given randomly.
  5. Hi guys, how can I attach a part to another part/model so that I don't need to modify the rotation points everytime? I'm making an animated hairs mod and I started with straight long hairs, to make this I divived the part behind the head into more segments so I can manage to animate them better, this is the scheme: |||| -> Head level "HARD" |||| -> Head level "MID" |||| -> Head level "SOFT" |||| -> Head level "END" I made segments for each head level (that's the actual head height from an EntityPlayer), and I want to animate those segments based on the player speed and that's what happens: ||||\ |||| \ |||| \ |||| \ <- this diagonal is how the hairs are animated; when I want something like this: ||||\ |||| | |||| \__ |||| \ <- this is what kind of angles I want, imagine the strong wind in the last level and weak wind in the second one. I think the problem is on the part's offset, since they are all in the same spot according to the orizzontal level, example: In the X level 1 there are 4 segments with all the same offset level on X level 1, each one with a different Y level; In the X level 2 there are 4 segments with all the same offset level on X level 2, each one with a different Y level, etc... And all offsets are at the same Y level. So obviously I thought that using an unique offset for each segments would be good, but If I put a segment in the X level 1 and Y level 1 when I need to animate it, like getting moved from the wind using the method rotateX, they will still be in the same position but with the custom angle INSTEAD of being attached to the previous segment. TL;DR: How to attach a part to another part with an unique offset so that when I animate them they will still be attached to that part? EDIT: "addChild(ModelRenderer yourModel);" is the way
  6. Thanks, I thought I was missing something in that file, if I don't reply it works.
  7. It's always the same, in every version I cannot make the block opening the gui, am I missing something? Main File: package com.thelorizz.advanced; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import com.thelorizz.advanced.handler.ForgeEventHandler; import com.thelorizz.advanced.handler.GuiHandler; import com.thelorizz.advanced.registry.BlockRegistry; import com.thelorizz.advanced.tileentity.TileEntityFusion; @Mod(modid = mod_advanced.MODID, version = mod_advanced.VERSION) public class mod_advanced { public static final String MODID = "thelorizz_advanced"; public static final String VERSION = "Beta"; @Instance(mod_advanced.MODID) public static mod_advanced instance; @SidedProxy(clientSide = "com.thelorizz.advanced.ClientProxy", serverSide = "com.thelorizz.advanced.ServerProxy") public static ServerProxy proxy; @EventHandler public void preinit(FMLPreInitializationEvent e) { MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); } @EventHandler public void init(FMLInitializationEvent e) { BlockRegistry.registerBlocks(); GameRegistry.registerTileEntity(TileEntityFusion.class, "containerFusion"); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); } @EventHandler public void postinit(FMLPostInitializationEvent e) { } } GuiHandler: package com.thelorizz.advanced.handler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import com.thelorizz.advanced.container.ContainerFusion; import com.thelorizz.advanced.gui.GuiFusion; import com.thelorizz.advanced.tileentity.TileEntityFusion; public class GuiHandler implements IGuiHandler { public GuiHandler() { System.out.println("Initialized"); } @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); if (tileEntity instanceof TileEntityFusion) { return new ContainerFusion(player.inventory, (TileEntityFusion) tileEntity); } return null; } // returns an instance of the Gui you made earlier @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); // System.out.println("AIRds:"); if (tileEntity instanceof TileEntityFusion) { // System.out.println("AddsdIR:"); return new GuiFusion(player.inventory, (TileEntityFusion) tileEntity); } return null; } } ContainerFusion: package com.thelorizz.advanced.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 net.minecraft.util.BlockPos; import net.minecraft.world.World; import com.thelorizz.advanced.tileentity.TileEntityFusion; public class ContainerFusion extends Container { protected TileEntityFusion tileEntity; public ContainerFusion(InventoryPlayer inventoryPlayer, TileEntityFusion te) { tileEntity = te; // the Slot constructor takes the IInventory and the slot number in that // it binds to // and the x-y coordinates it resides on-screen addSlotToContainer(new Slot(tileEntity, 30, 123, 57)); addSlotToContainer(new Slot(tileEntity, 31, 370, 57)); addSlotToContainer(new Slot(tileEntity, 32, 246, 162)); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18)); } } // commonly used vanilla code that adds the player's inventory bindPlayerInventory(inventoryPlayer); } protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); // null checks and checks if the item can be stacked (maxStackSize > 1) if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); // merges the item into player inventory since its in the tileEntity if (slot < tileEntity.getSizeInventory()) { if (!this.mergeItemStack(stackInSlot, tileEntity.getSizeInventory(), 36 + tileEntity.getSizeInventory(), true)) { return null; } } // places it into the tileEntity is possible since its in the player // inventory else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } public boolean canInteractWith(EntityPlayer playerIn) { return this.tileEntity.isUseableByPlayer(playerIn); } } GuiFusion: package com.thelorizz.advanced.gui; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.fml.client.FMLClientHandler; import org.lwjgl.opengl.GL11; import com.thelorizz.advanced.mod_advanced; import com.thelorizz.advanced.container.ContainerFusion; import com.thelorizz.advanced.tileentity.TileEntityFusion; public class GuiFusion extends GuiContainer { ResourceLocation texture = new ResourceLocation(mod_advanced.MODID, "textures/gui/gui_fusion.png"); public GuiFusion (InventoryPlayer inventoryPlayer, TileEntityFusion tileEntity) { //the container is instantiated and passed to the superclass for handling super(new ContainerFusion(inventoryPlayer, tileEntity)); } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { //draw text and stuff here //the parameters for drawString are: string, x, y, color fontRendererObj.drawString("Fusion", 8, 6, 4210752); //draws "Inventory" or your regional equivalent fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { //draw your Gui here, only thing you need to change is the path GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(texture); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } BlockFusion: package com.thelorizz.advanced.block; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import com.thelorizz.advanced.mod_advanced; import com.thelorizz.advanced.tileentity.TileEntityFusion; public class BlockFusion extends Block { public BlockFusion(Material materialIn) { super(materialIn); this.setUnlocalizedName("blockFusion"); this.setCreativeTab(CreativeTabs.tabBlock); this.register(); } public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFusion) { playerIn.openGui(mod_advanced.instance, 0, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } } public void register() { GameRegistry .registerBlock(this, this.getUnlocalizedName().substring(5)); } } TileEntityFusion: package com.thelorizz.advanced.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IChatComponent; public class TileEntityFusion extends TileEntity implements IInventory { private ItemStack[] inv; public TileEntityFusion() { inv = new ItemStack[9]; } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int slot) { return inv[slot]; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.pos) != this ? false : player .getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64.0D; } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = (NBTTagList) tagCompound.getTag("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public String getName() { // TODO Auto-generated method stub return "gui_fusion"; } @Override public boolean hasCustomName() { // TODO Auto-generated method stub return true; } @Override public IChatComponent getDisplayName() { // TODO Auto-generated method stub return null; } @Override public void openInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public void closeInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { if (stack.getItem() instanceof ItemSword) { return true; } return false; } @Override public int getField(int id) { // TODO Auto-generated method stub return 0; } @Override public void setField(int id, int value) { // TODO Auto-generated method stub } @Override public int getFieldCount() { // TODO Auto-generated method stub return 0; } @Override public void clear() { // TODO Auto-generated method stub } }
  8. Hi guys, can you explain why I can't my custom block obj model rendering? I used AdvancedModelLoader in the past, and it worked great! But now, since this is one of the worst minecraft version, forge changed the working-on of the AdvanceModelLoader and custom block renderer (blocks and items now doesn't have ID). Those are my classes: Main: TileEntityTestBlock: Just a normal TileEntity's extended class. TileEntityTestBlockRenderer: TestBlockModel: TestBlock: And in my ClientProxy, under "onInit()" method, there is: ClientRegistry.bindTileEntitySpecialRenderer( TileEntityTestBlock.class, new TileEntityTestBlockRenderer()); Why is this not working? Thanks!
  9. Fixed, just extended the Block to BlockContainer and used "createNewTileEntity" instead of "createTileEntity".
  10. It's in the Init, under the method "proxy.initRenderers();".
  11. Hi guys, it's me, lorizz. Yesterday I started creating a mod for the 1.7.2 version and I'm at the point to make a custom Crafting Table, I know how to do it but the problem is. I followed a 1.6.4 tutorial on making a Gui/Container with the GuiHandler class and updated all functions/method to 1.7.2, no errors were found. But the problem is that everytime I try to right click on my custom block, the gui doesn't show, no crash, nothing happens. I searched a lot on this forum and someone found a way to fix it without explaining how. Those are all my classes: Main class: Gui Handler: GuiFoundry: ContainerFoundry: TileEntityFoundry: BlockFoundry: And finally the method I use to register the TileEntity: public void initRenderers() { GameRegistry.registerTileEntity(TileEntityFoundry.class, "alum_te_foundry"); } Why the gui is not working? Thanks!
  12. I got it, I called the Tabs AFTER the game has registered the blocks/items. Now I need only to make a different "GameRegistry" function that will register the blocks/items AFTER the tables has been loaded and AFTER the blocks/items have been initialized! Thanks for all to pointing to the tabs! It helped me very much, thanks!
  13. This may not be your main problem, but your code cannot work as written with IDs. Even if you registered your block before trying to use its ID (which you cannot), you are using deprecated methods which have no purpose in 1.7.2. Using the @deprecated annotation is the same as saying ignore this error. But, there is no reason to cheat like that. I know, those method also are not being called because they doesn't override nothing, just only for purpose. Anyway I removed them, still not working. @coolboy The registry is called in the "preInit" method, even if I try to call it outside the class, doesn't work. I tried making a "testBlock" directly in the preinit method and registered it with a custom creative tabs, IT WORKS! But I don't know why forge doesn't check this extender... Expecially the "setCreativeTab(tab)"....
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.