Jump to content

Turbin

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by Turbin

  1. If I'm not mistaken, 

    e.isSilkTouching()

    checks if the block is being dropped in its original state as the result of a silk touch material. So it returns true if for example I'm mining a grass block with a silk touch tool. But it returns false if I'm mining a spawner with a silk touch tool, because the spawner is not being naturally dropped.

     

    I don't think e.isSilkTouching() can explicitly check if I'm holding a Silk Touch tool or not.

  2. @diesieben07 Thanks! I still don't know how to make a spawner though. I looked online and for 1.7 it's TileEntityMobSpawner, but that doesn't exist anymore. So far, I figured out how to check if the tool has silk touch or not. I don't know how to retrieve the block that is being broken, and I don't know how to determine whether it is a spawner or not. How would I check if the block is a spawner, what kind of spawner it is, and finally add the spawner to the list of drops?

     

    Also I am unable to check whether I have silk touch or not... the ID value always returns 10 regardless of the enchantment for some reason.

    Quote
    
    @SubscribeEvent
    	public void silkMiner(HarvestDropsEvent e) {
    		if (e.getHarvester() != null) {
    			EntityPlayer p = e.getHarvester();
    			ItemStack item = p.inventory.getCurrentItem();
    			if (item != null) {
    				NBTTagList enchants = item.getEnchantmentTagList();
    				boolean silk = false;
    				for (int i = 0; i < enchants.tagCount(); i++) {
    					if (enchants.get(i).getId() == 33) {
    						silk = true;
    						break;
    					}
    				}
    				if (silk) {
    					p.sendMessage(new TextComponentTranslation("nice"));
    				}
    			}
    		}
    	}

     

     

  3. How would I go about doing this? I would assume that I have to use the block breaking event. Then, I know what I need to do, but I don't know the correct syntax for doing so. I think I need to

     

    1. Check if the item the player is holding has the silk touch enchantment

    2. Check if the block broken is a spawner

    3. Spawn a dropped itemstack of the spawner at the location where the block was broken

     

    Could someone please help me figure out how to write code for checking a tool's enchantments, checking if a block is a spawner (and what kind), and dropping the spawner as an item on the ground?

     

     

  4. Could you clarify what you meant by the EntityTag part? I have experience in Java and Bukkit plugin programming, but I'm new to modding, sorry :(

     

    I take it that you don't mean to do

    EntityItem item = new EntityItem(p.world, x, y, z, new ItemStack(Items.SPAWN_EGG, 1, EntityList.getKey(en)));

     

  5. Thanks again! It compiles now, but does nothing when I throw an egg at a sheep.

     

    I want the player to lose a level and the mob to disappear, replaced by its spawn egg. None of that happens though.

     

    The sheep doesn't disappear. The spawn egg doesn't drop. The player doesn't lose a level. However, if the player is below level 40, it sends my message so at least that works.

     

    @SubscribeEvent
    	public void eggCatcher(LivingHurtEvent e) {
    		if (e.getEntity() == null) {
    			return;
    		}
    		if (e.getSource().getDamageType().equals("thrown")) {
    			if (e.getSource().getSourceOfDamage() instanceof EntityEgg) {
    				if (e.getSource().getEntity() instanceof EntityPlayer) {
    					EntityPlayer p = (EntityPlayer) e.getSource().getEntity();
    					Entity en = e.getEntity();
    					double x = en.posX;
    					double y = en.posY;
    					double z = en.posZ;
    					if (p.experienceLevel > 40) {
    						if (en instanceof EntitySheep) {
    							p.addExperienceLevel(-1);
    							p.world.removeEntity(en);
    							EntityItem item = new EntityItem(p.world, x, y, z, new ItemStack(Items.SPAWN_EGG, 1, 91));
    							p.world.spawnEntity(item);
    						}
    					}
    					else {
    						p.sendMessage(new TextComponentTranslation("\247bYou must be at least level 40 to capture mobs"));
    					}
    				}
    			}
    		}
    	}

     

  6. Thanks @Choonster! One little issue. How would I check if it is a Player that has thrown the egg? I tried

    if (e.getSource().getEntity() instanceof Player) {
    	[todo]
    }

    But it won't compile because Player and Entity are apparently incompatible types. 

     

    Even if I skip this check (which would probably lead to crashes later on if some other entity threw an egg), I can't define a player variable because I can't cast the Entity as a Player. How can I solve this problem?

  7. I get the following error:

    [10:57:41] [Client thread/ERROR] [FML]: Exception loading model for variant turbin:itemcheese#inventory for item "turbin:itemcheese", normal location exception: 
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model turbin:item/itemcheese with loader VanillaLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:336) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:156) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:26) [start/:?]
    Caused by: java.io.FileNotFoundException: turbin:models/item/itemcheese.json
    	at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:126) ~[ModelLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:937) ~[ModelLoader$VanillaLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 20 more
    [10:57:41] [Client thread/ERROR] [FML]: Exception loading model for variant turbin:itemcheese#inventory for item "turbin:itemcheese", blockstate location exception: 
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model turbin:itemcheese#inventory with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:344) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:156) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:26) [start/:?]
    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1253) ~[ModelLoader$VariantLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 20 more

     

    Here is my itemcheese.json

    {
        "parent": "builtin/generated",
        "textures": {
            "layer0": "turbin:items/cheese"
        }
        "display": {
            "thirdperson": {
                "rotation": [ -90, 0, 0 ],
                "translation": [ 0, 1, -3 ],
                "scale": [ 0.55, 0.55, 0.55 ]
            },
            "firstperson": {
                "rotation": [ 0, -135, 25 ],
                "translation": [ 0, 4, 2 ],
                "scale": [ 1.7, 1.7, 1.7 ]
            }
        }
    }

     

    Here is my en_US.lang

    item.cheese.name=Cheese

     

    Here is my ItemCheese.java

    package items;
    
    import net.minecraft.item.Item;
    
    import com.turbin.ezpvp.Reference;
    
    public class ItemCheese extends Item {
    	
    	public ItemCheese() {
    		setUnlocalizedName(Reference.CustomItems.CHEESE.getUnlocalizedName());
    		setRegistryName(Reference.CustomItems.CHEESE.getRegistryName());
    	}
    	
    }

     

    ModItems.java

    package init;
    
    import com.turbin.ezpvp.Reference;
    
    import items.ItemCheese;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.block.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    public class ModItems {
    	
    	public static Item cheese;
    	
    	public static void init() {
    		cheese = new ItemCheese();
    	}
    	
    	public static void register() {
    		GameRegistry.register(cheese);
    	}
    	
    	public static void registerRenders() {
    		registerRender(cheese);
    	}
    	
    	private static void registerRender(Item item) {
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(cheese, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    	}
    	
    }

     

    My main class, Ezpvp.java

    package com.turbin.ezpvp;
    
    import init.ModItems;
    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 com.turbin.ezpvp.proxy.CommonProxy;
    
    @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.MCVERSIONS)
    public class Ezpvp {
    
    	@Instance
    	public static Ezpvp instance;
    
    	@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
    	public static CommonProxy proxy;
    
    	@EventHandler
    	public void preInit(FMLPreInitializationEvent event) {
    		ModItems.init();
    		ModItems.register();
    	}
    
    	@EventHandler
    	public void init(FMLInitializationEvent event) {
    		proxy.init();
    	}
    
    	@EventHandler
    	public void postInit(FMLPostInitializationEvent event) {
    	}
    
    }

     

    I have attached a screenshot of what the item looks like.

    2017-02-26_11.00.30.png

    Nice.png

×
×
  • Create New...

Important Information

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