Jump to content

cmchenry

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by cmchenry

  1. My item damages for ONE SECOND and then goes right back to being damaged. You'd think it has something to do with client server syncing but it isn't as it is called on both sides.

     

    object ItemWateringCan extends Item {
    
      setRegistryName(DrugMod.modid, "watering_can")
      setUnlocalizedName(DrugMod.modid + ":watering_can")
      setCreativeTab(CreativeTabs.TOOLS)
      setMaxDamage(20)
    
      override def onItemUse(player: EntityPlayer, world: World, pos: BlockPos, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): EnumActionResult = {
    //    if(!world.isRemote) {
    //      val blockState = world.getBlockState(pos)
    //      if(blockState.getBlock == Blocks.WATER) {
    //      } else if (blockState.getBlock == BlockCropPot) {
    //        world.setBlockState(pos, BlockCropPot.getDefaultState.withProperty(BlockFarmland.MOISTURE, 7:java.lang.Integer))
    //      }
    //    }
        println(player.getHeldItem(hand).isItemStackDamageable)
        if(!world.isRemote) {
          player.getHeldItem(hand).damageItem(1, player)
        }
          super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ)
      }
    
    }
    
  2. So to fully fix all clipping in my block class I had to add 

     

    override def shouldSideBeRendered(blockState: IBlockState, blockAccess: IBlockAccess, pos: BlockPos, side: EnumFacing): Boolean = true
    
    override def isOpaqueCube(state: IBlockState): Boolean = false
    
    override def isFullCube(state: IBlockState): Boolean = false
    

     

    And then in blender I had to of course fix the normals like in the video above, and then I had to render without Triangulating Faces, but sometimes that may fix it.

     

    Final JSON

    {
      "forge_marker" : 1,
      "defaults" : {
        "textures" : {
          "#material" : "drug:block/crop_pot_dry"
        },
        "custom": { "flip-v": true },
        "model" : "drug:crop_pot.obj",
        "transform": "forge:default-item"
      },
      "variants": {
        "normal": [{
          "model": "drug:block/crop_pot"
        }],
        "inventory": [{
          "model": "drug:block/crop_pot"
        }],
        "moisture": {
          "0": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "1": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "2": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "3": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "4": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "5": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "6": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "7": { "textures": { "#material":"drug:block/crop_pot_wet" } }
        }
      }
    }
  3. Okay I got the textures to load, but for some reason it doesn't show properly in MC on the model. Is it because I triangulated the faces?

     

    {
      "forge_marker" : 1,
      "defaults" : {
        "textures" : {
          "#material" : "drug:block/crop_pot_dry"
        },
        "model" : "drug:crop_pot.obj",
        "transform": "forge:default-block"
      },
      "variants": {
        "normal": [{
          "model": "drug:block/crop_pot"
        }],
        "inventory": [{
          "model": "drug:block/crop_pot"
        }],
        "moisture": {
          "0": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "1": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "2": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "3": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "4": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "5": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "6": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "7": { "textures": { "#material":"drug:block/crop_pot_wet" } }
        }
      }
    }
  4. {
      "forge_marker" : 1,
      "defaults" : {
        "textures" : {
          "material" : "drug:block/crop_pot_dry"
        },
        "model" : "drug:crop_pot.obj",
        "transform": "forge:default-block"
      },
      "variants": {
        "normal": [{
          "model": "drug:block/crop_pot",
          "textures": {
            "material":"drug:block/crop_pot_dry"
          }
        }],
        "inventory": [{
          "model": "drug:block/crop_pot",
          "textures": {
            "material":"drug:block/crop_pot_dry"
          }
        }],
        "moisture": {
          "0": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "1": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "2": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "3": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "4": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "5": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "6": { "textures": { "material":"drug:block/crop_pot_dry" } },
          "7": { "textures": { "material":"drug:block/crop_pot_wet" } }
        }
      }
    }

     

    Textures still don't work.

  5. In Client Proxy PreInit

     

    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlockCropPot), 0, new ModelResourceLocation(BlockCropPot.getRegistryName, "inventory"))
    

     

    The JSON

    {
      "forge_marker" : 1,
      "defaults" : {
        "textures" : {
          "#material" : "drug:block/crop_pot_dry"
        },
        "model" : "drug:crop_pot.obj",
        "transform": "forge:default-block"
      },
      "variants": {
        "normal": [{
          "model": "drug:block/crop_pot",
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        }],
        "inventory": [{
          "model": "drug:block/crop_pot",
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        }],
        "moisture": {
          "0": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "1": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "2": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "3": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "4": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "5": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "6": { "textures": { "#material":"drug:block/crop_pot_dry" } },
          "7": { "textures": { "#material":"drug:block/crop_pot_wet" } }
        }
      }
    }
    

     

    This contains no errors. Only problem now is that the block is a purple/black block (ya know, the one that's missing its model) and the model has no texture. Also how do I disable culling? It seems to be culling the OBJ=NOT GOOD.

     

  6. I've googled around and read the forums for approximately 1 hour. I will not research any further. Can I please receive help on why I am getting this error?

     

    Called in ClientProxy init

     

    registerItemModel(BlockCropPot, 0)
    
    def registerItemModel(block: Block, meta: Int): Unit = {
      val item = Item.getItemFromBlock(block)
      val model = new ModelResourceLocation(getRegistryName.toString, "inventory")
      ModelBakery.registerItemVariants(item, model)
      Minecraft.getMinecraft.getRenderItem.getItemModelMesher.register(item, meta, model)
    }

    Called in Client Proxy PreInit

    OBJLoader.INSTANCE.addDomain(DrugMod.modid)
    

     

    object BlockCropPot extends BlockFarmland {
    
      setRegistryName(DrugMod.modid, "crop_pot")
      setUnlocalizedName(DrugMod.modid + ":crop_pot")
      setCreativeTab(CreativeTabs.FOOD)
    
    }

     

     

    {
      "forge_marker" : 1,
      "defaults" : {
        "textures" : {
          "#material" : "drug:block/crop_pot_dry"
        },
        "model" : "drug:crop_pot.obj",
        "transform": "forge:default-block"
      },
      "variants": {
        "inventory": { "model": "drug:crop_pot.obj" },
        "moisture=0": {
            "textures": {
              "#material":"drug:block/crop_pot_dry"
            }
        },
        "moisture=1": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=2": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=3": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=4": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=5": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=6": {
          "textures": {
            "#material":"drug:block/crop_pot_dry"
          }
        },
        "moisture=7": {
          "textures": {
            "#material":"drug:block/crop_pot_wet"
          }
        }
      }
    }

     

    The .mtl file

     

    # Blender MTL File: 'None'
    # Material Count: 1
    
    newmtl material
    Ns 96.078431
    Ka 1.000000 1.000000 1.000000
    Kd 0.640000 0.640000 0.640000
    Ks 0.500000 0.500000 0.500000
    Ke 0.000000 0.000000 0.000000
    Ni 1.000000
    d 1.000000
    illum 2
    

     

    Last but not least, the error log.

     Exception loading model for variant drug:crop_pot#moisture=5 for blockstate "drug:crop_pot[moisture=5]"
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model drug:crop_pot#moisture=5 with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:121) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	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_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:25) [start/:?]
    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 21 more
    [16:39:25] [main/ERROR]: Exception loading model for variant drug:crop_pot#moisture=6 for blockstate "drug:crop_pot[moisture=6]"
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model drug:crop_pot#moisture=6 with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:121) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	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_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:25) [start/:?]
    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 21 more
    [16:39:25] [main/ERROR]: Exception loading model for variant drug:crop_pot#moisture=3 for blockstate "drug:crop_pot[moisture=3]"
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model drug:crop_pot#moisture=3 with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:121) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	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_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:25) [start/:?]
    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 21 more
    [16:39:25] [main/ERROR]: Exception loading model for variant drug:crop_pot#moisture=4 for blockstate "drug:crop_pot[moisture=4]"
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model drug:crop_pot#moisture=4 with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:121) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	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_144]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:25) [start/:?]
    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?]
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    	... 21 more

     

  7. I'm trying to register an ItemBlock for my custom block. It's just not appearing in the creative tab for whatever reason or from what I can tell in the game at all. All other items register fine, just not the ItemBlock. PS: I'm coding in Scala

     

    @SubscribeEvent
    def registerItems(e: RegistryEvent.Register[Item]): Unit = {
      e.getRegistry.registerAll(ItemHempBud, ItemHempSeed, ItemHempBioManipulator)
    }

     

    object BlockHempBioManipulator extends BlockContainer(Material.IRON) {
    
      var PROP_TOP: IProperty[java.lang.Integer] = _
    
      setRegistryName(DrugMod.modid, "hemp_bio_manipulator")
      setUnlocalizedName(DrugMod.modid + ":hemp_bio_manipulator")
      setDefaultState(this.blockState.getBaseState.withProperty(PROP_TOP, 0: java.lang.Integer))
    
      override def createNewTileEntity(worldIn: World, meta: Int): TileEntity = new TileEntityHempBioManipulator
    
      override def getRenderType(state: IBlockState): EnumBlockRenderType = EnumBlockRenderType.MODEL
    
      override def getStateFromMeta(meta: Int): IBlockState = getDefaultState.withProperty(PROP_TOP, meta: java.lang.Integer)
    
      override def getMetaFromState(state: IBlockState): Int = state.getValue(PROP_TOP)
    
      override def createBlockState(): BlockStateContainer = {
        PROP_TOP = PropertyInteger.create("top", 0, 1)
        new BlockStateContainer(this, PROP_TOP)
      }
    
      override def onBlockActivated(worldIn: World, pos: BlockPos, state: IBlockState, playerIn: EntityPlayer, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
        if (!worldIn.isRemote) playerIn.openGui(DrugMod, GuiHandler.GUI_HEMP_BIO_MANIPULATOR, worldIn, pos.getX, pos.getY, pos.getZ)
        super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ)
      }
    
    }
    
    object HempBioManipulatorStateMapper extends StateMapperBase {
      override def getModelResourceLocation(state: IBlockState): ModelResourceLocation = new ModelResourceLocation(state.getBlock.getRegistryName, "top=" + state.getValue(BlockHempBioManipulator.PROP_TOP))
    }
    
    object ItemHempBioManipulator extends ItemBlock(BlockHempBioManipulator) {
      setRegistryName(DrugMod.modid, "hemp_bio_manipulator")
      setUnlocalizedName(DrugMod.modid + ":hemp_bio_manipulator")
      setCreativeTab(CreativeTabs.BREWING)
    }

     

    EDIT: So it is registering, just not in the creative tabs at all.

  8. 5 hours ago, diesieben07 said:

    As far as I can tell Scala will not automatically box things into java.lang.Integer, because java.lang.Integer and int are treated uniformly as Int from Scala's perspective. You might need to box your Ints explicitly using Int.box.

    But I am by no means a Scala expert, so this is just a guess.

    Thank both of you for trying to help. I really want to figure this out, not just for forge but any type of Scala code that I do that needs Java API that uses implicit types.

     

    Not sure what you mean by Int.box? That isn't a thing that I am aware of. I tried using Integer instead of Int, such as this... and still get the same error.

     

    Error:(42, 38) inferred type arguments [Any,Int] do not conform to method withProperty's type parameter bounds [T <: Comparable[T],V <: T]
        worldIn.setBlockState(pos, state.withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)
    Error:(42, 51) type mismatch;
     found   : net.minecraft.block.properties.IProperty[Integer]
     required: net.minecraft.block.properties.IProperty[T]
        worldIn.setBlockState(pos, state.withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)

     

    val PROP_FEMALE:IProperty[java.lang.Integer] = PropertyInteger.create("female", 0, 1)
    
  9. Any help with this error?

    Error:(42, 38) inferred type arguments [Any,Int] do not conform to method withProperty's type parameter bounds [T <: Comparable[T],V <: T]
        worldIn.setBlockState(pos, state.withProperty(BlockCrops.AGE, newAge).withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)
    Error:(42, 62) type mismatch;
     found   : net.minecraft.block.properties.PropertyInteger
     required: net.minecraft.block.properties.IProperty[T]
        worldIn.setBlockState(pos, state.withProperty(BlockCrops.AGE, newAge).withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)
    Error:(42, 67) type mismatch;
     found   : Int
     required: V
        worldIn.setBlockState(pos, state.withProperty(BlockCrops.AGE, newAge).withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)

     

    val PROP_FEMALE = PropertyInteger.create("female", 0, 1)

     

    override def grow(worldIn: World, pos: BlockPos, state: IBlockState): Unit = {
      if (!canBlockStay(worldIn, pos, state)) return
    
      var newAge = getAge(state) + getBonemealAgeIncrease(worldIn)
      newAge = if (newAge > getMaxAge) getMaxAge else newAge
    
      val isFemale = state.getValue(PROP_FEMALE) == 1
      worldIn.setBlockState(pos, state.withProperty(BlockCrops.AGE, newAge).withProperty(PROP_FEMALE, if (isFemale) 1 else 0), 2)
    
      if (newAge == getMaxAge && worldIn.isAirBlock(pos.up()))
        worldIn.setBlockState(pos.up(), BlockHempCropTop.getDefaultState.withProperty(PROP_FEMALE, state.getValue(PROP_FEMALE)))
    }
  10. Any idea on what's wrong with this code? The cop doesn't attack a nearby player like a zombie does.

     

    public class EntityCop extends EntityMob {
    
        public EntityCop(World worldIn) {
            super(worldIn);
        }
    
        @Override
        protected void initEntityAI() {
            this.tasks.addTask(8, new EntityAILookIdle(this));
            this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D));
            this.tasks.addTask(6, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    //        this.tasks.addTask(9, new AICop(this));
        }
    
        @Override
        protected void applyEntityAttributes() {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);
            this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
            this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);
            this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D);
        }
    
    }

     

  11. 45 minutes ago, Draco18s said:

    I am not sure how the multistate format works, so I'm going to suggest going the rout of a custom state mapper.

     

    I have a value that is only true for some states, otherwise, its ignored. So here's the state-mapper:

    https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/flowers/states/StateMapperFlowers.java

    And the resulting blockstate files:

    https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/oreflowers/blockstates/oreflowers1.json

    https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/oreflowers/blockstates/oreflowers1_tall.json

     

    Notice all of the "oreflowers:items/na" entries? Those will never ever be seen. I know that, but Minecraft doesn't, and so rather than specifying a bunch of state pairs that'll never be used, I used the one value to split the states out into two different files.

     

    You'd do the same thing on your FEMALE value, and the two files will be 99% the same, but one will have the "stage 7" be different.

     

    Don't forget to register your custom state mapper on the client.

    Thanks for the respond! I think this will help a lot of people, but the issue was storing the correct metadata with storing two values in an integer. Here is the code for that.

     

    @Override
    public int getMetaFromState(IBlockState state) {
        int i = 0;
        i = i | state.getValue(FEMALE);
        i = i | state.getValue(AGE) << 1;
        return i;
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta) {
        int female = meta & 1;
        int age = Integer.valueOf((meta & 15) >> 1);
        return withAge(age).withProperty(FEMALE, female);
    }
  12. package com.minelife.drugs.block;
    
    import com.minelife.Minelife;
    import com.minelife.drugs.ModDrugs;
    import net.minecraft.block.BlockCrops;
    import net.minecraft.block.properties.IProperty;
    import net.minecraft.block.properties.PropertyBool;
    import net.minecraft.block.properties.PropertyInteger;
    import net.minecraft.block.state.BlockStateContainer;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.item.Item;
    import net.minecraft.util.EnumBlockRenderType;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class BlockHempCrop extends BlockCrops {
    
        public static final PropertyInteger FEMALE = PropertyInteger.create("female", 0, 1);
    
        public BlockHempCrop() {
            setRegistryName(Minelife.MOD_ID, "hemp_crop");
            setUnlocalizedName(Minelife.MOD_ID + ":hemp_crop");
            setTickRandomly(true);
            setCreativeTab(null);
            setHardness(0.0F);
            disableStats();
        }
    
        // TODO: Still grows in non farmland
    
        @Override
        public void grow(World worldIn, BlockPos pos, IBlockState state) {
            super.grow(worldIn, pos, state);
    //        if(getAge(state) == 7)
                worldIn.setBlockState(pos, this.withAge(7).withProperty(FEMALE, 1));
    
            System.out.println(worldIn.getBlockState(pos).getProperties().get(FEMALE));
        }
    
        @Override
        protected BlockStateContainer createBlockState() {
            return new BlockStateContainer(this, new IProperty[] {AGE, FEMALE});
        }
    
        @Override
        protected Item getCrop() {
            return ModDrugs.itemHempBuds;
        }
    
        @Override
        protected Item getSeed() {
            return ModDrugs.itemHempSeed;
        }
    
    }
    

     

    {
      "multipart": [
        {
          "when": { "age": 0 },
          "apply": { "model": "minelife:hemp_stage0"}
        },
        {
          "when": { "age": 1 },
          "apply": { "model": "minelife:hemp_stage1"}
        },
        {
          "when": { "age": 2 },
          "apply": { "model": "minelife:hemp_stage1"}
        },
        {
          "when": { "age": 3 },
          "apply": { "model": "minelife:hemp_stage2"}
        },
        {
          "when": { "age": 4 },
          "apply": { "model": "minelife:hemp_stage2"}
        },
        {
          "when": { "age": 5 },
          "apply": { "model": "minelife:hemp_stage3"}
        },
        {
          "when": { "age": 6 },
          "apply": { "model": "minelife:hemp_stage4"}
        },
        {
          "when": { "age": 7, "female": 1 },
          "apply": { "model": "minelife:hemp_stage4"}
        },
        {
          "when": { "age": 7, "female": 0 },
          "apply": { "model": "minelife:hemp_male_stage4"}
        }
      ]
    }

     

    For some reason, no matter what it always renders as the female=0 scenario for age 7. What am I doing wrong?

  13. Low and behold, it didn't work.

     

    package com.minelife.drug.item;
    
    import com.minelife.Minelife;
    import com.minelife.drug.ModDrugs;
    import com.minelife.util.server.Callback;
    import com.minelife.util.server.NameFetcher;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.EntityPlayerMP;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.EnumChatFormatting;
    
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.*;
    
    public class ItemDrugTest extends Item {
    
        public static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
        public ItemDrugTest() {
            setUnlocalizedName("drug_test");
            setTextureName(Minelife.MOD_ID + ":drug_test");
            setCreativeTab(ModDrugs.tab_drugs);
        }
    
        @Override
        public boolean itemInteractionForEntity(ItemStack item_stack, EntityPlayer player, EntityLivingBase entity_clicked) {
            if (!(entity_clicked instanceof EntityPlayer)) return false;
            if (player.worldObj.isRemote) return true;
    
            if (ModDrugs.check_for_cocaine((EntityPlayer) entity_clicked))
                player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Cocaine detected!"));
            else
                player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Cocaine not detected."));
    
    
            if (ModDrugs.check_for_marijuana((EntityPlayer) entity_clicked))
                player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Marijuana detected!"));
            else
                player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Marijuana not detected."));
    
    
            add_drug_test_results(item_stack, (EntityPlayer) entity_clicked);
            player.inventoryContainer.detectAndSendChanges();
            ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
            return true;
        }
    
        @Override
        public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
            if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("player") && stack.stackTagCompound.hasKey("player_name")) {
                try {
                    list.add("Player: " + stack.stackTagCompound.getString("player_name"));
                    Date now = Calendar.getInstance().getTime();
    
                    if (stack.stackTagCompound.hasKey("marijuana")) {
                        list.add(EnumChatFormatting.RED + "Tested POSITIVE for marijuana " + ModDrugs.convert_to_mc_days(now, df.parse(stack.stackTagCompound.getString("marijuana"))) + " days ago.");
                    } else {
                        list.add(EnumChatFormatting.GREEN + "Tested NEGATIVE for marijuana.");
                    }
    
                    if (stack.stackTagCompound.hasKey("cocaine")) {
                        list.add(EnumChatFormatting.RED + "Tested POSITIVE for cocaine " + ModDrugs.convert_to_mc_days(now, df.parse(stack.stackTagCompound.getString("cocaine"))) + " days ago.");
                    } else {
                        list.add(EnumChatFormatting.GREEN + "Tested NEGATIVE for cocaine.");
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }
    
            }
        }
    
        private void add_drug_test_results(ItemStack item_stack, EntityPlayer player) {
            NBTTagCompound tag_compound = item_stack.hasTagCompound() ? item_stack.stackTagCompound : new NBTTagCompound();
    
            tag_compound.setString("player", player.getUniqueID().toString());
            tag_compound.setString("player_name", player.getDisplayName());
    
            if (ModDrugs.check_for_marijuana(player))
                tag_compound.setString("marijuana", df.format(Calendar.getInstance().getTime()));
            if (ModDrugs.check_for_cocaine(player))
                tag_compound.setString("cocaine", df.format(Calendar.getInstance().getTime()));
    
            item_stack.stackTagCompound = tag_compound;
    
            // thread the NameFetcher class so that it doesn't cause lag
    //        new Thread(new FetchName(this, item_stack, player.getUniqueID())).start();
        }
    
    //
    //    @Override
    //    public void callback(Object... objects) {
    //        ItemStack stack = (ItemStack) objects[0];
    //        UUID player_uuid = (UUID) objects[1];
    //        String player_name = (String) objects[2];
    //        stack.stackTagCompound.setString("player_name", player_name);
    //        System.out.println(stack.stackTagCompound.getString("player") + stack.stackTagCompound.getString("player_name"));
    //    }
    
    //    class FetchName implements Runnable {
    //
    //        Callback callback;
    //        ItemStack stack;
    //        UUID player;
    //        String name;
    //
    //        public FetchName(Callback callback, ItemStack stack, UUID player) {
    //            this.callback = callback;
    //            this.stack = stack;
    //            this.player = player;
    //        }
    //
    //        @Override
    //        public void run() {
    //            name = NameFetcher.get(player);
    //            callback.callback(stack, player, name);
    //        }
    //    }
    }

     

    2017-08-26_12.53.30.png

×
×
  • Create New...

Important Information

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