Jump to content

pH7

Members
  • Posts

    16
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Personal Text
    e^(iπ)-1

pH7's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. I've sorted myself out so I'm answering this in order for this thread to be closed. All I had to do was to create a boolean isMounted in my entity's model class, and call the doRender() method in my entity's renderer class; where inside I would have checked if the entity isBeingRidden() and change the isMounted boolean accordingly within doRender(). Example: public void doRender(ScorpionEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { boolean state = entity.isBeingRidden(); ScorpionModel<ScorpionEntity> scorpion = this.getEntityModel(); scorpion.isMounted = state; super.doRender(entity, x, y, z, entityYaw, partialTicks); } Works like a charm
  2. Hi, I want to change between two models for an entity I have, depending on whether or not it is being ridden. I was thinking of something like an if(isBeingRidden) statement inside the entity's Model class to change the model, but this is an EntityType, not an EntityModel, method. I tried to see how Minecraft does it (let's say for a Zombie attacking) but as of now, I can't access any vanilla Entity or Render class. I did notice the use of DataParameters in Entity classes; and thus used one to store and update whether or not my entity is being ridden. I'm not sure how, and where to use it, though. Thanks, Kres
  3. I have since stopped using IHasModel. That was not the issue, but I managed to sort it out. Basically: ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName()))); // line 41 should have been: ItemList.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName())); // line 41 Damn syntax mistakes causing trouble ? This thread can now be closed. Thanks for the advice.
  4. Hello, I have been struggling to resolve an "Attempted to set registry name with existing registry name! New: striketheblightmod:planks Old: striketheblightmod:planks" error. Basically, I have a BlockPlank class to register two plank variants using an EnumHandler. I would like to ask if anyone can help find out what's wrong as I couldn't find the culprit. more error details: Caused by: java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: striketheblightmod:planks Old: striketheblightmod:planks at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:71) at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:79) at striketheblight.striketheblightmod.blocks.BlockPlank.<init>(BlockPlank.java:41) at striketheblight.striketheblightmod.init.BlockList.<clinit>(BlockList.java:38) ... 23 more BlockPlank public class BlockPlank extends Block implements IHasModel, IMetaName { public static final PropertyEnum<EnumHandler.EnumType> VARIANT = PropertyEnum.<EnumHandler.EnumType>create("variant", EnumHandler.EnumType.class); private String name; public BlockPlank(String name) { super(Material.WOOD); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(Main.modTab); setSoundType(SoundType.WOOD); setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.WILLOW)); this.name = name; BlockList.BLOCKS.add(this); ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName()))); // line 41 } @Override public int damageDropped(IBlockState state) { return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta(); } @Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { for(EnumHandler.EnumType blockplank$enumtype : EnumHandler.EnumType.values()) { items.add(new ItemStack(this, 1, blockplank$enumtype.getMeta())); } } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, EnumHandler.EnumType.byMetadata(meta)); } @Override public int getMetaFromState(IBlockState state) { return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {VARIANT}); } @Override public String getSpecialName(ItemStack stack) { return EnumHandler.EnumType.values()[stack.getItemDamage()].getName(); } @Override public void registerModels() { for (int i = 0; i < EnumHandler.EnumType.values().length; i++) { Main.proxy.registerVariantRenderer(Item.getItemFromBlock(this), i, EnumHandler.EnumType.values()[i].getName() + "_planks", "inventory"); } } } EnumHandler: public class EnumHandler { public static enum EnumType implements IStringSerializable{ WILLOW(0, "willow"), REDWOOD(1, "redwood"); private static final EnumType[] META_LOOKUP = new EnumType[values().length]; private final int meta; private final String name, unlocalizedName; private EnumType(int meta, String name) { this(meta, name, name); } private EnumType(int meta, String name, String unlocalizedName) { this.meta = meta; this.name = name; this.unlocalizedName = unlocalizedName; } @Override public String getName() { return this.name; } public String getUnlocalizedName() { return this.unlocalizedName; } public int getMeta() { return this.meta; } @Override public String toString() { return this.name; } public static EnumType byMetadata(int meta) { return META_LOOKUP[meta]; } static { for (EnumType enumType : values()) { META_LOOKUP[enumType.getMeta()] = enumType; } } } } line 38 in BlockList (other people call the class BlockInit): public static final Block PLANKS = new BlockPlank("planks"); ItemBlockVariants: public class ItemBlockVariants extends ItemBlock{ public ItemBlockVariants(Block block) { super(block); setHasSubtypes(true); setMaxDamage(0); } @Override public int getMetadata(int damage) { return damage; } @Override public String getUnlocalizedName(ItemStack stack) { return ((IMetaName)this.block).getSpecialName(stack) + "_" + super.getUnlocalizedName(); //e.g.: willow_planks } } I usually resolve errors on my own but this one has me pondering for a while ^^ Thanks in advance, Kris
  5. >.> <.< >.> Indeed... I offset everything to be within bounds and now it is rendered perfectly... I didn't notice that, thanks man
  6. For TheSunCat: I have something like this for a blockstate and my regular blocks render fine As Draco said, do you have the inventory? ------------------------------------------------------------------------------------------------------------- My current jsons for this block are: /variety/blockstates/beach_turtle_shell.json: /variety/models/block/beach_turtle_shell.json: original post /variety/models/item/beach_turtle_shell.json: I have an item icon being displayed as the held item istead of the irregular block. It is what I intended to and it appears fine both in the player's hand, in the inventory and as a dropped item fine and with the correct size. I noticed this in my last fml log: I still get purple and black blocks when placed.
  7. Hey all and happy new year I run into a problem that has been boggling my mind; I made an irregular block that extends my BlockBase class, made textures for it and a json file for its model, but it renders as the purple/black block. This is its class: public class BlockBeachTurtleShell extends BlockBase{ public BlockBeachTurtleShell() { super(Material.ROCK, "beach_turtle_shell"); setHardness(3f); setResistance(5f); setHarvestLevel("pickaxe", 1); setCreativeTab(CreativeTabs.DECORATIONS); setSoundType(SoundType.STONE); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn){ addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.0625F, 0.0F, 0.125F, 0.9375F, 0.3125F, 0.875F)); } @Override public BlockRenderLayer getBlockLayer(){ return BlockRenderLayer.TRANSLUCENT; } } It is there as the collision and its properties work. If I change the its json file to retrieve some random block's texture, it will succeed, leading me to believe that there is something wrong with the json file, but I can't figure out what. This is it: { "textures": { "texture0": "variety:blocks/beach_turtle_shell/beach_turtle_shell0", "texture1": "variety:blocks/beach_turtle_shell/beach_turtle_shell1", "texture2": "variety:blocks/beach_turtle_shell/beach_turtle_shell2", "texture3": "variety:blocks/beach_turtle_shell/beach_turtle_shell3", "texture4": "variety:blocks/beach_turtle_shell/beach_turtle_shell4", "texture5": "variety:blocks/beach_turtle_shell/beach_turtle_shell5", "texture6": "variety:blocks/beach_turtle_shell/beach_turtle_shell6", "texture7": "variety:blocks/beach_turtle_shell/beach_turtle_shell7", "texture8": "variety:blocks/beach_turtle_shell/beach_turtle_shell8", "particle": "variety:blocks/beach_turtle_shell/beach_turtle_shell0" }, "elements": [ { "from": [ 2.0, -24.0, 1.0 ], "to": [ 14.0, -22.0, 15.0 ], "faces": { "down": { "uv": [ 1, 1, 13, 15 ], "texture": "#texture1"}, "up": { "uv": [ 1, 1, 13, 15 ], "texture": "#texture0", "rotation": 180}, "north":{ "uv": [ 1, 5, 13, 7 ], "texture": "#texture3", "rotation": 180}, "south":{ "uv": [ 1, 1, 13, 3 ], "texture": "#texture3"}, "west": { "uv": [ 5, 1, 7, 15 ], "texture": "#texture2", "rotation": 90}, "east": { "uv": [ 1, 1, 3, 15 ], "texture": "#texture2", "rotation": 270} } }, { "from": [ 5.0, -20.0, 4.0 ], "to": [ 11.0, -19.0, 12.0 ], "faces": { "down": { "uv": [ 1, 1, 7, 9 ], "texture": "#texture4"}, "up": { "uv": [ 9, 1, 15, 9 ], "texture": "#texture2", "rotation": 180}, "north":{ "uv": [ 9, 14, 15, 15 ], "texture": "#texture2", "rotation": 180}, "south":{ "uv": [ 9, 11, 15, 12 ], "texture": "#texture2"}, "west": { "uv": [ 12, 1, 13, 9 ], "texture": "#texture4", "rotation": 90}, "east": { "uv": [ 9, 1, 10, 9 ], "texture": "#texture4", "rotation": 270} } }, { "from": [ 3.0, -22.0, 2.0 ], "to": [ 13.0, -21.0, 14.0 ], "faces": { "down": { "uv": [ 1, 1, 11, 13 ], "texture": "#texture6"}, "up": { "uv": [ 1, 1, 11, 13 ], "texture": "#texture5", "rotation": 180}, "north":{ "uv": [ 1, 12, 11, 13 ], "texture": "#texture3", "rotation": 180}, "south":{ "uv": [ 1, 9, 11, 10 ], "texture": "#texture3"}, "west": { "uv": [ 13, 1, 14, 13 ], "texture": "#texture6", "rotation": 90}, "east": { "uv": [ 13, 1, 14, 13 ], "texture": "#texture5", "rotation": 270} } }, { "from": [ 4.0, -21.0, 3.0 ], "to": [ 12.0, -20.0, 13.0 ], "faces": { "down": { "uv": [ 1, 1, 9, 11 ], "texture": "#texture8"}, "up": { "uv": [ 1, 1, 9, 11 ], "texture": "#texture7", "rotation": 180}, "north":{ "uv": [ 1, 14, 9, 15 ], "texture": "#texture4", "rotation": 180}, "south":{ "uv": [ 1, 11, 9, 12 ], "texture": "#texture4"}, "west": { "uv": [ 14, 1, 15, 11 ], "texture": "#texture7", "rotation": 90}, "east": { "uv": [ 11, 1, 12, 11 ], "texture": "#texture7", "rotation": 270} } } ] } Those awful rotations were due to mistakes in orientation during modelling but ignore them, they are fine x) From what I know of json formats, that should work. Does anyone have any idea of where the mistake should be? I'll keep working on it. Thanks in advance.
  8. Sorry for bringing this up again, I just want to add that I found an easier way to set this up (for 1.8 Forge. I've been told told that for 1.7 Forge if(biome instanceof BiomeGenSwamp) { includes the swampland variant, yet this was not the case for me): This effectively adds the seeds as a new drop. Also, by using Biome Dictionary, you also include the Swampland variant (Swamp M in F3) instead of just the Swamp biome. I was lucky that my world had both Swamp and Swamp M side by side to check that by using 'instanceof BiomeGenSwamp'. If one wants to mess around with details then they can code additional lines if they do not want both types of seeds to drop at the same time from the same block of tall grass (or not wanting both types to drop in general). Sorry for necroing, edited some ambiguities and corrected something unnecessary in the code. Thanks Draco18s.
  9. woohoo! if(biome instanceof BiomeGenSwamp && event.state.getBlock() instanceof BlockTallGrass) { //... Indeed I can get the block that way. event.state.getBlock() works to perfection. I read a big tutorial on Events in general so I can know what fields and methods to use on different occasions. This post can finally start sinking down in the forums. Might be useful for someone who is making custom crops and wants to know how to make biome specific seed drops, though. Thanks everyone for helping. May karma be with you. NOW I CAN FINALLY MODEL IN PEACE :3
  10. Yes. Sorry for not being clear on my previous previous post. I did use event.world and event.pos in order to try and find a parameter to help me get the block firing the event, yet I could not find any. I'll try again later on. Again, sorry for bringing this post up again. I know you guys are busy and I appreciate you being helpful. In fact Draco helped me a lot with the code.
  11. I cannot use event.block to check if the block firing the HarvestDropEvent is Grass or not. Sorry if it seems to be asking for help constantly and bringing this post up again and again :< I just have very basic knowledge of java and have trouble figuring stuff out. I stopped working on dropSeed for now, and doing something I'm better at; modeling some mobs in Techne to add later on. I'll try to find a way to get the block type of the block that fires the Event a bit later on.
  12. public HarvestDropsEvent(World world, BlockPos pos, IBlockState state, int fortuneLevel, float dropChance, List<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching) { super(world, pos, state); this.fortuneLevel = fortuneLevel; this.dropChance = dropChance; this.drops = drops; this.isSilkTouching = isSilkTouching; this.harvester = harvester; } forge1.8-11.14.0.1295-1.8
  13. I got it to work. And changed the code some more to alter drop rate in different biomes, for different custom seeds. But one thing is left. I still cannot understand how could you add the block field in your if statement: if(event.block instanceof BlockTallGrass) There is no block field in HarvestDropsEvent. And when I tried to add a Block argument in the dropSeeds constructor, I could not register the event with the event bus of common proxy.
  14. Oh I see. You are creating an array list of ItemStacks to pass on for drops. I do not like replying that I still have a problem but this has been boggling my brain for a couple of hours today. I used the way you used your array and itemstack in a variety of ways, yet I still got problems. Currently it is like this: What I expect from the above is to check when do the custom seeds drop while in not a swamp. Then if they do change the drop to not include them. What I get is only the custom seeds dropping in swamps and no seeds dropping elsewhere. Also, I wanted from before to be able to detect if it is tall grass that is broken. I was surprised to find out that I could not use event.block like you did. I was not sure of what to use instead from the available options, so for my first attempts I put: I removed it. But I cannot understand why does the first spoiler not work. Also minor detail, when the event first fires from the very first seeds (can be either) dropping elsewhere than a swamp, they will drop instead of not. Cute detail.
  15. Thanks for your quick reply, unlike this one. I have been trying for a couple of hours to make this work. Probably someone more experienced could have done this in a matter of a minute. A while back I have managed to make the custom seeds always drop in place of wheat seeds in swamps, and both types dropping anywhere else. I was happy since I figured out how to alter where the seeds drop. But I wanted the custom seeds to only drop in swamp (don't mind if wheat seeds also drop there), i.e. to not drop elsewhere. I altered my code and introduced an Event like so: I also added this to the Init method of CommonProxy: Now I get only the custom seeds to drop everywhere. But I do not understand how does the above not work. Looks like as if it should work. Any heads up? I'll continue working on this. I'll update when I have made progress.
×
×
  • Create New...

Important Information

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