Jump to content

Eilux

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Eilux

  1. That sounds like it will work I am however having trouble finding where Minecraft is instantiated so I can reflect it.
  2. That might work but players could work around it by assigning the attack button to a different key.
  3. setSoundType() is protected and as a result of this I'm unable to set sounds on my blocks without having to create a new class for each of them which is something I would rather not do. The only other solution that comes to mind is the use of some kind of BlockBase class that makes it public but that dose not seem like a good solution either. Dose anyone else have a workaround for this.
  4. It's working now. I was wondering if there is also a way to prevent the animation from happening and the attack speed from reseting. Thank you everyone for your help so far.
  5. I have tried putting the event in an event handler class and registering it but it still isn't working. package eilux.mod.util; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class EventHandler { @SubscribeEvent public void AttackEntityEvent(AttackEntityEvent event) { event.setCanceled(true); } }
  6. heres the rest of my main if that helps: package eilux.mod; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.fml.common.Mod; 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.eventhandler.SubscribeEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION, acceptedMinecraftVersions = Main.MC_VERSION) public class Main { public static final String MODID = "mc_general_expansion"; public static final String NAME = "Minecraft General Expansion"; public static final String VERSION = "0.0"; public static final String MC_VERSION = "[1.12.2]"; public static final Logger LOGGER = LogManager.getLogger(Main.MODID); @Mod.EventHandler public void preInit(FMLPreInitializationEvent event){ } @Mod.EventHandler public void init(FMLInitializationEvent event){ LOGGER.info(Main.NAME + " says it wants functionality."); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event){ } @SubscribeEvent public void AttackEntityEvent(AttackEntityEvent event) { event.setCanceled(true); } }
  7. I created some test code in my Main however it doesn't seem to work. @SubscribeEvent public void AttackEntityEvent(AttackEntityEvent event){ event.setCanceled(true); }
  8. how do you actually cancel the event.
  9. new Block(Material.IRON).setRegistryName("ruby_block").setCreativeTab(CreativeTabs.BUILDING_BLOCKS).setHardness(5.0F).setResistance(10.0F).setHarvestLevel("pickaxe",2);
  10. whenever I add .setHarvestLevel() to the Block class it gives me an incompatible type error: expected: Block, got: void
  11. Is it necessary to make a new class for every block or item added or is it acceptable to make a generic block class that takes in parameters the one that i had been using previously was this. package mod.eilux.mcge.blocks; import mod.eilux.mcge.McGE; import mod.eilux.mcge.init.ModBlocks; import mod.eilux.mcge.init.ModItems; import mod.eilux.mcge.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class BlockBase extends Block implements IHasModel { private static final Map<String, SoundType> soundIndex; private static final Map<String,CreativeTabs> tabIndex; static { Map<String, SoundType> tempSoundIndex = new HashMap<>(); tempSoundIndex.put("metal", SoundType.METAL); tempSoundIndex.put("stone", SoundType.STONE); tempSoundIndex.put("anvil", SoundType.ANVIL); tempSoundIndex.put("cloth", SoundType.CLOTH); tempSoundIndex.put("glass", SoundType.GLASS); tempSoundIndex.put("ground", SoundType.GROUND); tempSoundIndex.put("ladder", SoundType.LADDER); tempSoundIndex.put("plant", SoundType.PLANT); tempSoundIndex.put("sand", SoundType.SAND); tempSoundIndex.put("slime", SoundType.SLIME); tempSoundIndex.put("snow", SoundType.SNOW); tempSoundIndex.put("wood", SoundType.WOOD); soundIndex = Collections.unmodifiableMap(tempSoundIndex); Map<String, CreativeTabs> tempTabIndex = new HashMap<>(); tempTabIndex.put("misc", CreativeTabs.MISC); tempTabIndex.put("brewing", CreativeTabs.BREWING); tempTabIndex.put("building_blocks", CreativeTabs.BUILDING_BLOCKS); tempTabIndex.put("combat", CreativeTabs.COMBAT); tempTabIndex.put("decorations", CreativeTabs.DECORATIONS); tempTabIndex.put("food", CreativeTabs.FOOD); tempTabIndex.put("redstone", CreativeTabs.REDSTONE); tempTabIndex.put("tools", CreativeTabs.TOOLS); tempTabIndex.put("transportation", CreativeTabs.TRANSPORTATION); tabIndex = Collections.unmodifiableMap(tempTabIndex); } public BlockBase(String name, Material material, String tab, String soundType, Float hardness, Float blastRes, String harvestTool, int harvestLevel, Float lightLevel, int opacity){ super(material); setTranslationKey(name); setRegistryName(name); setCreativeTab(tabIndex.get(tab)); setSoundType(soundIndex.get(soundType)); setHardness(hardness); setResistance(blastRes); setHarvestLevel(harvestTool,harvestLevel); setLightLevel(lightLevel); setLightOpacity(opacity); ModBlocks.BLOCKS.add(this); ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName())); } @Override public void registerModels() { McGE.proxy.registerItemRenderer(Item.getItemFromBlock(this),0,"inventory"); } } *I am still in the process of removing IHasModel
  12. Is there somewhere where I could find sample code of this.
  13. After reading several pages on the forums I have realized that my mod uses several bad practices including IHasModel and a weird convoluted way of registering blocks and items it is very confusing to try to fix without a point of reference so I was wondering if anyone could point me to a good example of block and item registration.
  14. Everything basically so it ignores the click entirely .
  15. the function says that it will still consume absorption hearts and armor durability I need a way to prevent this. * Also note that appropriate resources (like armor durability and absorption extra hearths) have already been consumed.<br> ... * If this event is canceled, the Entity is not hurt. Used resources WILL NOT be restored.
  16. I would recommend using MultiMC it us a very helpful when playing with mods it allows you to easily install forge and create new instances of Minecraft.
  17. I need a way to temporarily make it so that a player is not able to punch/attack when they hit left click. I don't have any code yet because I'm unsure of where exactly to start.
  18. I have found the problem i forgot to put minecraft: in front of crafting_shapeless
  19. I have the recipe here done the vanilla way but it doesn't work. { "type": "crafting_shapeless", "ingredients": [ { "item": "minecraft:prismarine_shard" }, { "item": "minecraft:prismarine_shard" }, { "item": "minecraft:prismarine_shard" }, { "item": "minecraft:prismarine_shard" }, { "item": "minecraft:prismarine_crystals" }, { "item": "minecraft:prismarine_crystals" }, { "item": "minecraft:prismarine_crystals" }, { "item": "minecraft:prismarine_crystals" }, { "item": "minecraft:diamond" } ], "result": { "item": "mcge:prismarine_gem", "count": 1 } }
  20. Ok everything seems to be working now thank you for your help.
  21. Ok I am having a difficult time figuring out what exactly I'm supposed to do if somebody could show me some sample code that would be very helpful.
  22. how should I detect wether the user is using silk touch?
  23. what should I override it with?
×
×
  • Create New...

Important Information

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