Jump to content

Bloopers

Forge Modder
  • Posts

    77
  • Joined

  • Last visited

Posts posted by Bloopers

  1. Aha! Jabelar was extending the reach of a sword, not extending the mouse event class. Go back and take a closer look at the tutorial and then start over.

    I removed the part that makes it extend MouseEvent, and then tried launching again and it's the same result. Is there a reason that I should start over?

  2. Hello. I've created a custom event with a tutorial from jabelar, that extends MouseEvent

     

    Welp, there's your problem.  You're not supposed to extend the event classes.  You're supposed to create a single function that takes a single parameter (of any

    Event

    subtype) and mark it with an

    @EventHandler

    annotation.

     

    Can you please link the tutorial you were using?

    http://jabelarminecraft.blogspot.com/p/minecraft-modding-extending-reach-of.html

     

  3. Hello. I've created a custom event with a tutorial from jabelar, that extends MouseEvent, and I've managed to get rid of all error(as the tutorial was for 1.8, there were plenty of errors) - but when I load the game it just doesn't do anything. I think it has to do with the actual registering of the event.

     

    In my CommonProxy's init method, I put in

    MouseEventHandler handler = new MouseEventHandler();
        	MinecraftForge.EVENT_BUS.register(handler); 

     

    Is there a different way to register events in 1.10? I'm a complete noob when it comes to events, only done very basic things with them.

  4. How am I supposed to use the Outline/Object Hierarchy and Type Hierarchy to find a new name for things? There are two things that eclipse is telling me don't exist anymore. "MovingObjectPosition" and "getMouseOverExtended"

     

    It helps if the new stuff is in the same class. Like if you're following a tutorial that used the BlockModelRenderer.renderModelStandard() method and saw it wasn't available any more then you could look at the methods listed in the same class (BlockModelREnderer) and you'll notice that there is a method called BlockModelRenderer.renderModelFlat() and if you look at that method you can guess that it is used in the same way.

     

    However, Type Hierarchy won't help you for the two issues you have because a) geMouseOverExtended() is a method from my tutorial so has nothing to do with version, and b) MovingObjectPosition is a class not a method or field.

     

    Assuming you copied all my code, you actually have the getMouseOverExtended() method already. However, Eclipse might be complaining about it because it returns a MovingObjectPosition value which it doesn't recognize so then it also won't recognize the method.

     

    So actually you only need to fix the MovingObjectPosition and that should also fix the getMouseOverExtended() as well.

     

    Now when a whole class gets changed, it means there was a more extensive change that probably needs more thought and can be tricky to figure out. The best way to figure it out is to compare the source code from the older version and the newer version. For example, load a project in 1.8 into Eclipse and check where MovingObjectPosition is used in the Minecraft source. Then also look at your the 1.10 source and look in the same place and see what is now there. It is usually pretty obvious.

     

    Anyway, that is what I just did. And I found that MovingObjectPosition has been renamed RayTraceResult. I haven't looked further to see if the class itself has changed, and I'll do that when I get time, but this should give you a good clue on how to fix it.

    Thank you so much! I have one more question, which I don't think only has to do with the extended reach, but it might be useful to use in other things later on.

     

    The ModClass.network thing. In this area

    if (mov.entityHit != thePlayer )
                                {
                                    SpearMod.network.sendToServer(new MessageExtendedReachAttack(
                                          mov.entityHit.getEntityId()));
                                }
    

     

    "network" is underlined. It cannot be resolved or is not a field. But, I already have

    public static SimpleNetworkWrapper network;	
    

     

    in my main mod class.

    Quick fix tells me to create a field or a constant in my main mod class, but it's already there? If I tell it to do either of those, it'll create

    	public static final String network = null;
    

    or

    	public static Object network;	
    

     

    But it should already be identified as

    	public static SimpleNetworkWrapper network;
    

    as it is in your tutorial?

  5. Double click on a class to open it and look at the object hierarchy window.

    Where is the object hierarchy window?

    In eclipse it is called the outline

    Thank you.

     

    How am I supposed to use the Outline/Object Hierarchy and Type Hierarchy to find a new name for things? There are two things that eclipse is telling me don't exist anymore. "MovingObjectPosition" and "getMouseOverExtended"

  6. Hey, I'm just in the process of updating my mods (and tutorial information).

     

    In general there are some simple tricks to use your IDE (like Eclipse) to help you find the new names and approaches to things when the versions change.

     

    For example, if it says that a method doesn't exist then often by looking at the Type Hierarchy for the class that used to have the method you can see a method that has similar name that is probably the new one. Also, often the classes in the new version are written in fairly close order to the previous version so you can just open a project in the old version and compare that class with the new one and it is usually obvious what the replacement is. In cases where they have deprecated a method, they often provide a comment to explain which method you should use now.

    Where in the Type Hierarchy would I see stuff with a similar name? This is what I see:

    18efbd2b2e967cdbc4f53b4ea592f96f.png

     

    You can also look at vanilla classes and see how they are now doing whatever you want to do.

     

    Sometimes it is a bit more complicated, where a whole system is replaced -- like how Extended Entity Properties is replaced with Capability. In that case it is best to look up tutorials and search the forums. Most of the questions have already been answered.

     

    Anyway, I can look at the extended reach tutorial over next couple days and see what is required to update. But don't wait for me, see if you can figure it out on your own -- I'll just have to do the same thing you will need to do!

     

    Sorry, my message got put inside the quote. I said:

     

    Where in the Type Hierarchy would I see stuff with a similar name? This is what I see:

    18efbd2b2e967cdbc4f53b4ea592f96f.png

  7. Hey, I'm just in the process of updating my mods (and tutorial information).

     

    In general there are some simple tricks to use your IDE (like Eclipse) to help you find the new names and approaches to things when the versions change.

     

    For example, if it says that a method doesn't exist then often by looking at the Type Hierarchy for the class that used to have the method you can see a method that has similar name that is probably the new one. Also, often the classes in the new version are written in fairly close order to the previous version so you can just open a project in the old version and compare that class with the new one and it is usually obvious what the replacement is. In cases where they have deprecated a method, they often provide a comment to explain which method you should use now.

    Where in the Type Hierarchy would I see stuff with a similar name? This is what I see:

    18efbd2b2e967cdbc4f53b4ea592f96f.png

     

    You can also look at vanilla classes and see how they are now doing whatever you want to do.

     

    Sometimes it is a bit more complicated, where a whole system is replaced -- like how Extended Entity Properties is replaced with Capability. In that case it is best to look up tutorials and search the forums. Most of the questions have already been answered.

     

    Anyway, I can look at the extended reach tutorial over next couple days and see what is required to update. But don't wait for me, see if you can figure it out on your own -- I'll just have to do the same thing you will need to do!

  8. Why do you have this

    ItemPrimitiveSpearTool

    class which you never use?

    Why do you have this

    ToolMaterial

    parameter in the

    ItemPrimitiveSpear

    constructor, which you never do anything with? What did you expect this to do?

    Oh! I meant to have ItemPrimitiveSpear extend ItemPrimitiveSpearTool. Do I not even need the ItemPrimitiveSpearTool class?

     

    I expect ToolMaterial to be able to set the durability, enchantability etc using the "primitive" tool material that I have, in the SpearItems class.

  9. Hello. I just added a tool to my mod, and I set the attack damage and attack speed, but when I launch the game and grab the item, it has no attributes, as if it were just a basic item. Here are the classes I used:

     

    package bloopers.spearmod.items;
    
    import java.util.Set;
    
    import com.google.common.collect.Sets;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.SoundEvents;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.ItemTool;
    import net.minecraft.util.EnumActionResult;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.SoundCategory;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.World;
    
    public class ItemPrimitiveSpearTool extends ItemTool
    {
        private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.SPONGE});
    
        public ItemPrimitiveSpearTool(Item.ToolMaterial material)
        {
            super(1.5F, -3.0F, material, EFFECTIVE_ON);
        }
    }
    

     

    package bloopers.spearmod.items;
    
    import net.minecraft.item.Item;
    
    public class ItemPrimitiveSpear extends Item {
    
    public ItemPrimitiveSpear(ToolMaterial material) {
    	this.setMaxStackSize(1);
    }
    }
    
    

     

    And then my item init class:

    package bloopers.spearmod.init;
    
    import bloopers.spearmod.items.ItemPrimitiveSpear;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.block.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    import net.minecraftforge.client.model.ModelLoader;
    import net.minecraftforge.common.util.EnumHelper;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    public class SpearItems {
    
    /**********|DECLARE|**********/
    public static ItemPrimitiveSpear primitive_spear;
    
    public static final Item.ToolMaterial primitive = EnumHelper.addToolMaterial("primitive", 1, 300, 6.0F, 1.0F, 1);
    
    
    public static void init() {
    /*********************************|INIT ITEMS|***************************************/
    	//primitive_spear = new ItemPrimitiveSpear(primitive);
    
    	primitive_spear = (ItemPrimitiveSpear)(new ItemPrimitiveSpear(primitive).setUnlocalizedName("primitive_spear"));
    
    }
    /***********************************************************************************/
    
    public static void register() {	
    /*********************************|REGISTER ITEMS|***************************************/
    primitive_spear.setRegistryName("primitive_spear");
    GameRegistry.register(primitive_spear);	
    
    }
    /***********************************************************************************/
    
    public static void registerRenders() {
    /*********************************|RENDER ITEMS|***************************************/
    registerRender(primitive_spear);
    
    }
    /***********************************************************************************/
    
    
    private static void registerRender(Item item) {
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
    			new ModelResourceLocation("spear" + ":" + item.getUnlocalizedName()
    			.substring(5), "inventory"));
    }
    }
    

  10. Was there a crash, or error printes out in the console, did the removing of the recipe just not work?

    Actually, now that I look at it, the mod doesn't seem to load at all. It just says 3 mods loaded when I click run. (Mincraft Coder Pack, Forge Mod Loader and Minecraft Forge)

     

    ...and I found out what was happening, too! In my "acceptedMinecraftVersions" in the main mod file, I set it to: "[1.10],[1.10.1],1.10.2]"

     

    For some reason, it doesn't like whatever I put in and acted as if the mod didn't exist at all. So instead, I replaced it with: "[1.10.2]" only. Now that I launch, the recipe is removed!

     

    Do I really need to allow for 1.10, 1.10.1 and 1.10.2 to use this mod, or will it allow it anyway?

  11. I picked up a mod that I had been working on a couple months ago in 1.8 and updated it to 1.10.2. This mod just removed the bed recipe(and added my own, to make it harder to craft) - it worked perfectly in 1.8, but after I update to 1.10.2, it just does the normal bed recipe. This is how I removed the recipes(from a tutorial video)

     

    package bloopers.harderbeds;
    
    import java.util.Iterator;
    import java.util.List;
    
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.crafting.CraftingManager;
    import net.minecraft.item.crafting.IRecipe;
    
    public class RecipeRemover
    {
    public static void removeRecipe(Item item)
    {
    
    	List<IRecipe> recipies = CraftingManager.getInstance().getRecipeList();
    
    	Iterator<IRecipe> remover = recipies.iterator();
    
    	while (remover.hasNext())
    	{
    		ItemStack itemstack = remover.next().getRecipeOutput();
    
    		if(itemstack != null && itemstack.getItem() == item)
    		{
    			remover.remove();
    		}
    
    
    	}
    
    }
    
    public static void removeRecipe(Block block)
    {
    
    	List<IRecipe> recipies = CraftingManager.getInstance().getRecipeList();
    
    	Iterator<IRecipe> remover = recipies.iterator();
    
    	while (remover.hasNext())
    	{
    		ItemStack itemstack = remover.next().getRecipeOutput();
    
    		if(itemstack != null && itemstack.getItem() == Item.getItemFromBlock(block))
    		{
    			remover.remove();
    		}
    
    
    	}
    
    }
    }

     

    Then, in my PostInit, I put this:

    		RecipeRemover.removeRecipe(Items.BED);
    

     

     

     

    Is there a new way to remove recipes, or is there something outdated in this code? Any help is appreciated!

  12. You cannot just add arbitrary parameters to event handler methods. A method annotated with

    @SubscribeEvent

    must take a single parameter: the event.

    PlayerInteractEvent

    has several sub-events, you should choose one, don't just subscribe to one.

    And why do you need an event handler here at all? If it's your item, you can use the callback methods in the Item class.

    How would I go about using a callback method for this?

  13. I'm trying to create a method that, when holding an item(climbing_hook), the player may be able to "hook" onto walls while crouching and having the hook in hand. This is my event class:

     

    package bloopers.climbing.eventhandeler;
    
    import com.sun.media.jfxmedia.events.PlayerEvent;
    
    import bloopers.climbing.init.ClimbingItems;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.world.World;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    
    public class EventOnHeld
    {
    
    @SubscribeEvent
    public void HeldItem(PlayerInteractEvent event, EntityPlayer player, World world)
    {		
    
    		if (player.getHeldItemMainhand() != null)
    		{
    			Item item = player.getHeldItemMainhand().getItem();
    				if (item == ClimbingItems.climbing_hook)
    				{
    					if (player.isSneaking()) {
    						if (player.isCollidedVertically) {
    							player.setVelocity(0.0F, 0.0F, 0.0F);
    						}
    					}
    				}
    
    		}
    	}
    }
    

     

     

    And this is how I am registering it:

    MinecraftForge.EVENT_BUS.register(new EventOnHeld());

     

    Whenever I launch the game, it loads up and crashes before it reaches the home screen. If I comment out the register thing, minecraft launches fine, but the event can't be registered.

  14. I'd like to make it so that the block I have created will only work if there is a block above it(it's meant to hang from the ceiling)

     

    I've looked into classes like carpet and plants since the only work if a block is UNDER them but I can't figure out how to make it so that it will be destroyed/can't be placed unless there is a block above.

     

    This is the class I have right now:

     

    package bloopers.climbing.blocks;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.MapColor;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockAccess;
    
    public class BlockRope extends Block {
    
        public static final AxisAlignedBB PILLAR_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.5D, 0.625D);
    
    
    public BlockRope(Material blockMaterialIn, MapColor blockMapColorIn) {
    	super(Material.CLOTH, blockMapColorIn.BROWN);
    }
    
        public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
        {
    	return PILLAR_AABB;
    
        }
    
        /**
         * Used to determine ambient occlusion and culling when rebuilding chunks for render
         */
        public boolean isOpaqueCube(IBlockState state)
        {
            return false;
        }
    
        public boolean isFullCube(IBlockState state)
        {
            return false;
        }
    
        @Override
        public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return true; }
    
        
    
    }
    
    

×
×
  • Create New...

Important Information

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