Jump to content

moonlyer

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by moonlyer

  1. I do save data to the world and i change registry values on world startup if data differs from default state. I just undo this changes every time client disconnects. It is probably unnecessary, but I feel comfortable to know that when no world is loaded - the registries have default values.
  2. Hi, I'm trying to make a global world winter. Basically I change biome values in the registries using reflection to make it snow everywhere. I've almost made it work as intended. But there's one issue: If I quit the world during winter (when biome values are changed), and create a new world - then new world will be generated with snow everywhere (cause I never changed back the registry values). I've fixed this issue in singleplayer scenario by subscribing to onServerStopping event and restoring default registry values there, but when dealing with the dedicated server idk to what event I should subscribe. I've tried onPlayerLoggedOut event, but it never runs on the client side, and packets from server do not reach client (cause the player already logged out). I was thinking about onWorldUnload - but it seems that this event can fire during the game (when dimensions switches), and idk how to determine if the world unloads "for the last time". Is there an event for me to subscribe to?
  3. Yeah, I think I'll just wait. In 1.13 will also be Dolphis grace effect, which also solves the problem.
  4. Hi, modders. I'm making a hero class system or sort of, and I want to increase swim speed for one of my hero types. I know that there is a Depth Strider enchantment, but my goal is to make this as an innate ability (without the need of any items). I tried straight increasing movement speed (with attribute modifiers), but it seems that EntityLivingBase.travel() completely ignores any movement speed bonuses, if there is no Depth strider enchantment present. So, my questions are: Is there a way to make minecraft think that player has Depth Strider enchantment without any items equipped? if not, how could I increase player swim speed apart from depth strider enchantment (maybe somehow modify motion vector)?
  5. You do pos.getY() where should be pos.getZ()
  6. Sry, didn't want to be mean. Just meant that this type of mistakes easily handled with a little bit of patience and attention. And about isOn. You're right. I've looked at BlockRedstoneOre and it does the same thing. But I really don't see the point to have it, cause it does never change, and does absolutely nothing. Just like if (true)
  7. Well, if something's not working - then you're doing it wrong. Here's your mistake. You spawn your particles not at your block's position. Minecraft.getMinecraft().effectRenderer.addEffect(UraniumOreParticles.CreateParticle(worldIn, pos.getX(), pos.getY(), pos.getY(), 1f, 0, 0, 1)); I did not check your if statements, but without them your code runs perfectly fine. And about your isOn variable. The way you have it right now means that every block in the world would try to spawn particle if isOn is true. If you want your blocks to spawn particles independently - you probably should make isOn as boolean property.
  8. @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } I think this should do the trick.
  9. Of course it's undefined. ParticleRedstone has a different constructor. Carefully examine ParticleRedstone class and change things accordingly. It's constructor is ParticleRedstone(World, double, double, double, float, float, float)
  10. I recently did something similar. I believe it's pretty tricky to get the right color with default particles, if possible at all. My solution was to create custom particle that extends the particle you want to render (in my case ParticleSpell), and then change colors in CreateParticle method. This way you have almost complete control of the particle. My code: public class ParticleEndlessDust extends ParticleSpell { protected ParticleEndlessDust(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i1229_8_, double ySpeed, double p_i1229_12_) { super(worldIn,xCoordIn,yCoordIn,zCoordIn,p_i1229_8_,ySpeed,p_i1229_12_); } @Override public boolean shouldDisableDepth() { return false; } public static ParticleEndlessDust CreateParticle(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) { ParticleEndlessDust particle = new ParticleEndlessDust(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); ((ParticleSpell)particle).setBaseSpellTextureIndex(144); float f = worldIn.rand.nextFloat() * 0.05F +0.95F; particle.setRBGColorF(1.0F * f, 0.91F * f, 0.46F * f); return particle; } } And then you can spawn it with ParticleManager.addEffect() @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { Minecraft.getMinecraft().effectRenderer.addEffect(ParticleEndlessDust.CreateParticle(worldIn, pos.getX()+0.5, pos.getY(), pos.getZ()+0.5, 0, 0, 0)); }
  11. It is possible to override vanilla sand and gravel in the registry and replace them with your own versions of sand and gravel. I believe thats the only way to stop them from falling with Forge.
  12. If someone interested, I managed to generate tall grass realtime without overriding vanilla blocks by accesing chunk in ChunkEvent.Load event, and generating needed blocks, like worldgen does. I haven't noticed much perfomance drops. @SubscribeEvent public void onChunkLoad (ChunkEvent.Load event) { if (!event.getWorld().isRemote) { //Get random x,z in chunk; Search for surface y; Check if possible to place; Places block Elcraft.elcraftRealtimeGenerator.GenDustInChunk(event.getChunk()); } }
  13. Thanks. I think I got it. It's really easy to get lost if you don't understand completely how minecraft classes interact with each other. P.S. My second issue (inablility to have different models for Block and it's ItemBlock) was solved by registering ItemBlock with a different registry name, and creating anoter blockstate .json. Previously I used the same registry name for block and ItemBlock.
  14. Right. But the problem is that UNREFINED_DUST is not an ItemBlock and does not have reference to a multistate block. So there's no way I could know every meta that I need to register in registerItemModels other than manually code it. Is there a way to drop UNREFINED_DUST with meta 0 regardless of WILD_DUST meta?
  15. Well there is some misunderstanding. WILD_DUST - my ItemBlock UNREFINED_DUST - my Item that's just referenced in my override of Block.getItemDropped That's how I register my items: public class ElcraftItems { //Item Variables to be registered public static final Item DUST_COIN= new DustCoin(); public static final Item UNREFINED_DUST=new UnrefinedDust(); public static final Item WILD_DUST= new WildDustItemBlock(ElcraftBlocks.WILD_DUST).setRegistryName(ElcraftBlocks.WILD_DUST.getRegistryName()); public static void Register(IForgeRegistry<Item> reg) { ArrayList<Item> itemsToBeInitialized=new ArrayList<Item>(); itemsToBeInitialized.add(DUST_COIN); itemsToBeInitialized.add(WILD_DUST); itemsToBeInitialized.add(UNREFINED_DUST); //Register Items for (Item i:itemsToBeInitialized) { reg.register(i); Elcraft.proxy.registerItemModels(i); } } } @Override public void registerItemModels(Item item) { StateMapperBase b = new DefaultStateMapper(); Block block; try { block=((ItemBlock)item).getBlock(); } catch (ClassCastException x) { block=null; } BlockStateContainer bsc; //If ItemBlock if (block!=null) { //if (item.getHasSubtypes()) //{} bsc = block.getBlockState(); ImmutableList<IBlockState> values = bsc.getValidStates(); for(IBlockState state : values) { String str = b.getPropertyString(state.getProperties()); ModelResourceLocation res = new ModelResourceLocation(item.getRegistryName(), str); //System.out.println(res.getResourcePath()); ModelLoader.setCustomModelResourceLocation(item,block.getMetaFromState(state),res); } } else { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory")); ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName(),"inventory")); } } So, do you suggest that i still need to register item model that is completely unrelated to my block with block's variant string?
  16. Yeah, I get that part. That line above refers to the item that only dropped by my block. That item is not my item block. My item block is registered right as you suggest.
  17. Hi modders, I have a custom Block with two states (for example meta 0, and meta 1). I've created and registered ItemBlock for this Block, just to have both variants in creative for testing. I've also made override of Block.getItemDropped so that my block could drop another item when destroyed. Everything is working fine except for models. I have 2 issues: 1. When my block with meta 1 is destroyed - my item gets dropped with placeholder model (item model that drops from block with meta 0 is fine). I've managed to fix this by adding another line like this: ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory")); ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName(),"inventory"));//new line But it feels not right to manually add models to every meta state. Ideally I want to call setCustomModelResourceLocation only once for my Item. How should I fix this? Should I drop my Item in onBlockDestroyedByPlayer instead? 2. Two ItemStacks, that got generated from my ItemBlock, have auto-generated icons in the inventory. I want to change them to custom icons. I guess I should do something with .json files, but I was not able to find the solution. What should my actions be in general if I want to add custom icons to ItemBlock?
  18. Thanks, I thought so. Well, time to do some code shenanigans then , maybe it will get me somewhere.
  19. It's something like crops growing. To be precise i want to do exactly the same like tall grass and flowers spawning randomly on the grass while the game is running, but on other already existing blocks too (vanilla or other mods). The most obvious way for me is too override existing blocks in the registry with my custom class. public class CustomBlockSand extends BlockSand { CustomBlockSand() { super(); this.setTickRandomly(true); this.setRegistryName("minecraft:sand"); this.setUnlocalizedName("sand"); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { //My tallgrass/flower spawning code } } But I feel overriding existing blocks will ruin compatibility with other mods, so I'm looking for a better way to do this.
  20. Hi modders, My goal is to make some block generate on the surface realtime with some probability, just like tall grass on dirt block. For example, make dead bush appear on sand. Vanilla minecraft does this generation on tick, when block's random tick is set to true. But for sand it is false. I could override vanilla sand block and make it randomly tick, but it seems this way would have compatibility issues (if some other mod overrides basic sand too). Another option that I see - is to listen to some chunk event (for example load chunk), get access to that chunk, check if surface block is sand and with some probability - generate dead bush. This way I do not need to override any blocks, but I'm not sure about perfomance. Is there a better way to achieve my goal, or I should stick to my options?
×
×
  • Create New...

Important Information

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