Jump to content

Mister_

Members
  • Posts

    22
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Mister_'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. The item, on it's own, has special properties when shift clicked in your inventory. You can't do that if it's a block.
  2. I'm... an idiot. Thank you. Solved.
  3. The methods in my InitBlocks class: public static Block remote_explosive; public static Block diamond_reed; public static void init() { diamond_reed=(new BlockDiamondReed()).setHardness(0.0F).setUnlocalizedName("diamond_reed"); } public static void register() { GameRegistry.registerBlock(diamond_reed, diamond_reed.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(diamond_reed); } public static void registerRender(Block block) { Item item=Item.getItemFromBlock(block); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } Then in my main mod class: @EventHandler public void preInit(FMLPreInitializationEvent event) { InitItems.init(); InitItems.register(); InitBlocks.init(); InitBlocks.register(); EntityRegistry.registerModEntity(EntityMagic.class, "Magic", 0, this, 64, 10, true); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new EventHandlerCommon()); }
  4. Yes. It works as a block perfectly if I manually give myself it.
  5. Not straight copied, just the funcationality is copied. In the ItemInit I do pass it my block: diamond_reeds = (new ItemDiamondReed(new BlockDiamondReed())).setUnlocalizedName("diamond_reeds").setCreativeTab(CreativeTabs.tabMaterials); And then I register diamond_reeds.
  6. Follow up question that will solve it: will onPlacedBy for a block trigger if I set a block with my mod or just if a player places a block?
  7. @Draco18s All this code is copied pretty much straight from BlockReed and ItemReed's code.
  8. I have an item, "diamond reeds", that I want to place as the block "diamond reed", which is a separate class and a separate registered block. What I tried to do is have the constructor for diamond reeds the item take a block: public ItemDiamondReed(Block block) { setCreativeTab(CreativeTabs.tabMaterials); setMaxStackSize(1); setMaxDamage(0); this.block = block; } Then have an event handler for the item that on item use places the block (straight out of the code for sugarcane item): Then, in the ItemInit class, define it like so: diamond_reeds = (new ItemDiamondReed(new BlockDiamondReed())).setUnlocalizedName("diamond_reeds").setCreativeTab(CreativeTabs.tabMaterials); And it works, the item shows up. But, when I try to place it, it simply doesn't do anything. It doesn't place the block. The block works fine, and if I manually give myself the block I can place it. But the item doesn't place it. Upon some debugging, I've found the problem is in the following two lines: IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn); if (worldIn.setBlockState(pos, iblockstate1, 3)) { It doesn't error, the if statement just always returns false. Does anyone know why?
  9. I want to create a block where when any one of them is clicked, all of them disappear. So, far, I have a clicked event: public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { delete=1; } But then I'm stuck - how can I make all the other blocks immediately execute some code when delete is 1? There isn't exactly a "when variable is changed" event. A solution without TileEntities would be preferred, though one using them is also perfectly fine.
  10. @diesieben07 Yes! That works! Thank you very much.
  11. @diesieben07 From checking the code, you pass DamageSource.causePlayerDamage a player entity and it returns a damage source of type player. I can then use that in my Event Handler by checking the type of the Damage Source, and if it's player, I know it came from my cursed sword. Is that correct or am I fundamentally misunderstanding this?
  12. @diesieben07 Could you elaborate or give a code example? I'm not really following.
  13. @diesieben07 Ok, I'm trying to set up my Damage Source now. This is all new to me. I have the following class: public class CursedDamage extends EntityDamageSource { public CursedDamage(String str, Entity damageSource) { super(str, damageSource); this.setDamageBypassesArmor(); } public static CursedDamage causeCursedDamage(Entity source) { return new CursedDamage("cursed_sword.item", source); } } Now how can I use this to attack an entity as a damage source?
  14. Awesome! Thank you very much. I'll give that a shot.
  15. I thought of one solution - creating a custom damagesource that I damage the player with for my sword and then just detecting that damage source. Oh wait is that what you meant?
×
×
  • Create New...

Important Information

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