Jump to content

Thaliviel

Forge Modder
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Thaliviel

  1. Okay, I think I begin to understand what I have to do in order to maintain the list: I can only save IntArrays in the NBT, no ArrayLists containing objects. When a player spawns inside a dimension, the NBT will be read (x,y,z) and the ArrayList will be created. When a player adds or removes a MBBlock, the ArrayList is updated and saved to the NBT as 3 IntArrays (containing x,y,z). Am I right so far or did I miss something important?
  2. Thank you. So about Saving/Loading - do I create a new class which extends WorldSavedData, and override readFromNBT() and writeToNBT()? And I cannot use the ArrayList ("mbBlockList") for saving, or can I?
  3. Okay, one question: If I use onBlockAdded() in my custom block's class, will it only be called when I add my custom block, or will it be called everytime I add any block? Edit: I checked it with system message - it only activates when I add the custom block. Problem solved This is my code for the custom block so far: package com.monsterBlocker; import java.util.ArrayList; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.world.World; public class MBBlock extends Block { // A list of all MBBlocks and their location public List mbBlockList = new ArrayList(); public MBBlock (int id) { super(id, Material.iron); this.setUnlocalizedName(MonsterBlocker.mbBlock_unlocalizedName); this.setCreativeTab(CreativeTabs.tabBlock); this.setHardness(5F); this.setResistance(15F); this.setStepSound(Block.soundMetalFootstep); this.setLightValue(2F); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister icon) { blockIcon = icon.registerIcon(MonsterBlocker.AID + ":" + "monsterBlocker"); } @Override public void onBlockAdded(World world, int x, int y, int z) { //CustomWorldData data = CustomWorldData.get(world); //data.addBlock(x, y, z); Position pos = new Position(x, y, z); mbBlockList.add(pos); } }
  4. Yeah, I wanted to do exactly what you suggested right now. My problem is that I don't know how to save the position of my block when it gets added. Could you please explain that a bit more? Maybe with code examples?
  5. Okay, so I created my custom block with a texture and a recipe. Now I'm having problems creating the list of locations. I know that I can use writeToNBT and readFromNBT in order to save additional data, like an array that contains the list of my blocks and their location. But I'm not really sure how and when to use these. I guess I can use BreakEvent when I want to delete blocks from my list. Could you give me some advice how to maintain a list of locations that have this block?
  6. Thank you for the quick and helpful reply!! I'll try that.
  7. Hey there, I haven't done modding in a while, so I'm a bit out of shape, but I know the basics. Is it possible to create a custom block, which prevents the spawning of monsters in a certain radius around it? If someone with great knowledge of modding could help me as a beginner, I'd really appreciate it!
  8. Hello, I'd like to add dragon eggs to dungeon and mineshaft chests. However, I'm not sure if I get the Wight Number right. In dungeons it should have the same probability as saddles, and in mineshafts the same probability as gold ingots. The stack should always consist of 1 dragon egg. import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; public class ChestLoot { public static void addChestItems() { ChestGenHooks chestGenHooksDungeon = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST); chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(Block.dragonEgg), 1, 1, 100)); ChestGenHooks chestGenHooksMineshaft = ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR); chestGenHooksMineshaft.addItem(new WeightedRandomChestContent(new ItemStack(Block.dragonEgg), 1, 1, 5)); } } Is this alright? Regards, Thaliviel
×
×
  • Create New...

Important Information

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