Jump to content

Lyeoj

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Lyeoj

  1. So, I've been adding natural spawning code for a bunch of mobs in my mod, and it has been working for the most part. The exception, however is in my mobs that should spawn in water. So I tried adding this line of code to make a water mob spawn: EntityRegistry.addSpawn(EntityGiantSquid.class, 100, 1, 1, EnumCreatureType.WATER_CREATURE, BiomeDictionary.getBiomes(Type.OCEAN).toArray(new Biome[0])); I will note that this entity is not an extension of EntityWaterMob, but I have given it all the functionality of one, and I don't think that should matter because Guardians aren't extensions of it either. So I did a bit of research and I found a past thread on here with this exact same issue, but that thread never got a definite resolution. If someone could figure out what is going on here then that would be appreciated. <Alternative solution> So instead of using the above method to spawn my water mobs, there is another way that I'm trying, but it has a few issues as well. If anyone knows a way to fix this method then that would work just as well. Instead of spawning the mob using the normal spawning mechanics, I have tried to use the EventHandler with the LivingSpawnEvent to replace an occasional squid with my new mob like so: @SubscribeEvent public static void onLivingSpawn(LivingSpawnEvent event) { EntityLivingBase entity = event.getEntityLiving(); if(entity instanceof EntitySquid) { if(entity.world.getBiome(new BlockPos(entity)) == Biomes.OCEAN && entity.world.getDifficulty() != EnumDifficulty.PEACEFUL && !entity.world.isRemote) { if(entity.getRNG().nextInt(100) == 1) { EntityGiantSquid squid = new EntityGiantSquid(entity.world); squid.copyLocationAndAnglesFrom(entity); entity.world.spawnEntity(squid); System.out.println("Spawning giant squid"); entity.setDead(); } } } } So this method kinda works, but there is also some unpredictable behavior. Every time a giant squid replaces a regular one, there is a message printed to the console. Well when I move around in the ocean, I see waaay more giant squids than debug messages. There was one instance where I saw more giant squids than regular ones, but there should be only one giant squid per 100 squid spawned on average. Think I might be using this event improperly or just using the wrong one.
  2. Alright, so I have some custom potions that I want to be brewed using some custom items in the vanilla brewing stand. So I've figured out how to make custom brewing recipes using BrewingRecipeRegistry.addRecipe, but when I try this: BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(AMItems.SHOCK_STONE), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), AMPotionTypes.ZAPPED)); the recipe will be brewed but it also will brew no matter what kind of potion is in the brewing stand when the ingredient is present. So I did a bit of research and found a past forum post here that mentioned that the recipes ignore NBT so a custom recipe implementation would need to be created. That sounded like it wouldn't be fun to do, and since the post was from 1.9.4, I was wondering if there was a better way to do this since then. So I then went and found almost what I was looking for: PotionHelper.addMix(PotionTypes.AWKWARD, AMItems.ITEM_SILVER_SHELL, AMPotionTypes.AMFATIGUE); This works great for the custom potions I have that use a PotionType, but for various reasons, I have created a bunch of custom potions that are just custom items instead of PotionTypes. I still want them to be brewed using vanilla potions but the end result will be an item that isn't derived from a PotionType. Here's an example of what I want to do: BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(AMItems.ITEM_HUNGRY_SLIMEBALL_BIG), new ItemStack(AMItems.ITEM_NUTRIENTS)); But of course, this puts me back in the situation where I was before where it won't matter what kind of potion is used in the brewing. So I'm just wondering if there is some nice way I can add this recipe, or will I just have to implement custom recipes?
  3. Well I did some looking through the code and found the reason for one of my issues. So the HUD effect not showing up is due to a check in the GuiIngame class, as the call to the Forge renderHUDEffect is within a conditional block that checks if the potion shows particles. I haven't found the place where the potion's liquid color is set for the potion item, but I assume that it will also check if the potion shows particles when setting the liquid color as well. Regardless of the reason for the liquid color, I think I won't be able to just turn off the particles in the constructor and still get the desired behavior for my potion effects. The only thing I can think of to do now is make a bunch of brand new items to mimic the vanilla potions, although it will be annoying since I want to give them splash and lingering variants as well. If anyone has an idea on a better way to do this, it would be appreciated.
  4. So I thought that constructor was just what I was looking for, but then I tried using it to make a custom PotionType, and setting showParticlesIn to false turns the liquid color to black. This PotionType shows particles and has a colored liquid: public static final PotionType FROZEN = new PotionType(new PotionEffect[] {new PotionEffect(AMPotion.FROZEN, 600, 0, false, true)}).setRegistryName("frozen"); And this one doesn't show particles but has a black liquid: public static final PotionType FROZEN = new PotionType(new PotionEffect[] {new PotionEffect(AMPotion.FROZEN, 600, 0, false, false)}).setRegistryName("frozen"); Additionally, setting the particles to false messes with another aspect of my potion effect. So this particular effect has an overlay drawn on the screen that is called using an overridden renderHUDEffect from the Potion class and it is no longer visible using the new PotionEffect constructor with showParticlesIn set to false. This seems odd.
  5. Alright, so I have a bunch of cool potion effects that I have made, but I don't like the potion particles showing up when they are active. The easiest way I could find to make the potions not display particles was to set the liquid color to pure black (0). However, I have now decided that I want to register a bunch of my potion effects as PotionTypes so I can make them into drinkable or splash potions relatively easily. For these potions, I want them to have a liquid color that isn't just pure black, but changing the color would make them display particles again. So I want to know if there is an easy way to turn off the potion particles while still having a colored potion liquid.
  6. After a bit of trial and error, it looks like I have fixed the problem. Although all the tutorial code included it, I removed the !world.isRemote check from my book item since I figured the proxies already were handling the side checks. Upon removing it, I now can see my mouse when opening the book!
  7. Sure thing, here's the book GUI, mostly copied: The book item: And finally the method in the client proxy to draw the GUI: public void drawMonsterBook() { Minecraft.getMinecraft().displayGuiScreen(new GuiMonsterBook()); }
  8. Alright, so I want to make a custom book item to serve as a manual for my mod. So I looked up a tutorial and got a simple book functioning simply by copying most of the code. Despite being for an older version of Minecraft, I only had to make a few small changes to get the code to work for 1.12. However, there is one minor problem that is bugging me quite a bit. When I open the book, the mouse cursor can be moved around but isn't visible. This can be fixed by moving the cursor outside the window and then back in, but it's still quite annoying. For reference, the tutorial I copied can be found here: http://jabelarminecraft.blogspot.com/p/minecraft-modding-block-with-simple-gui.html The only changes I really made were the paths to the textures, and a few variable names were changed to work with 1.12. I also cross-referenced the vanilla GuiScreenBook class and my book seems to be consistent with it. Also, the tutorial is for drawing the book Gui when right clicking on a block, but I just changed that to the onRightClick method of my book item.
  9. Hey, that fixed it! Thanks a bunch! I had initially copied the .json file from a tutorial which had that "/" there, but it had slightly different package layouts and was also a few versions outdated. I tried a bunch of different combinations for the pathname such as including "/assets" and the file extension, and even removed the leading forward slash for a few combinations. I do feel a bit silly that I hadn't tried this simplest combination, but thanks again for the help!
  10. Hello, So I haven't done much modding since 1.7.10 but am starting to get back into it and figure out how 1.12 works and I am attempting to add a custom sound. So I think I've figured out the new registry stuff and have registered a soundEvent. Just in case, here's what my soundEvent looks like: public static final SoundEvent SNIPER_SHOOT = new SoundEvent(new ResourceLocation(ApexMobs.MODID, "sniperskeleton.shoot")).setRegistryName("snipershoot"); and the register entry: @SubscribeEvent public static void registerSoundEvents(RegistryEvent.Register<SoundEvent> event) { event.getRegistry().register(AMSoundEvents.SNIPER_SHOOT); } Next up, here's my sounds.json file, this is the part most unfamiliar to me: { "sniperskeleton.shoot": { "category": "master", "sounds": [ { "name": "apexmobs:/sniper/sniperbow","stream":false } ] } } When I attempt to play the sound through an item in the game, I get a console error: [main/WARN]: Unable to play empty soundEvent: apexmobs:sniperskeleton.shoot The part where I think something has most likely gone wrong is the .json file. I am always confused as to what parts of the pathname need to be included and what parts don't. For context, my sound file is "sniperbow.ogg" located in the package "assets.apexmobs.sounds.sniper". Any help is appreciated, thanks in advance.
  11. Alright then, I have changed absolutely nothing since yesterday, but upon attempting another build today, it worked just fine with no problems. I don't even...
  12. So I was trying to build a new version of my mod, which I had been able to do without problems plenty of times before, and I received this error. C:\Users\Lyeoj\Desktop\MC Modding>gradlew build FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Lyeoj\Desktop\MC Modding\build.gradle' line: 25 * What went wrong: A problem occurred evaluating root project 'MC Modding'. > No such version exists! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 5.469 secs This is my gradle.build file, even though the only thing I had changed in it since the last time I made a new build was the mod version: buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } apply plugin: 'forge' version = "1.7.10-Beta-1.2.5" group= "lyeoj.deadlyfeesh.mod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Deadly Feesh" minecraft { version = "1.7.10-10.13.4.1490-1.7.10" runDir = "eclipse" } dependencies { // you may put jars on which you depend on in ./libs // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // for more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } } I know that my forge is out of date, but even upon trying to update forge, gradle would give the exact same error. I also downloaded a fresh copy of the forge src and made sure my gradle.build file was the same as its. I even tried to run gradlew setupDecompWorkspace with the fresh forge src and it still failed with the exact same error.
  13. Thanks! Was looking through the Forge events but forgot about the client ones.
  14. Ok, so I want to make some custom visual effect appear on the player's screen, such as a fog similar to the nightvision or blindness potions. I managed to trace this effect to the EntityRenderer class, which seems to control things like fog or shader effects. The only problem is that there is almost no way to externally control it, since all of the potion effects that change the screen are built into the class. How can I make an effect appear on the screen? Is there a way to hook into the class, or do I need to make my own renderer, or something else? (To specify what exactly I want to do, I just want to make a colored fog appear on the screen when I have a custom potion active)
  15. Making the color very light wouldn't make it transparent at all, you need to add alpha channel to tell the game that a certain texture should be transparent. I have added alpha to my textures already, my problem is getting the Renderer to be able to read the alpha channel, which it doesn't do by default. As for changing the light level of the mob, I don't even.
  16. Update: I have looked into the topic some more and found that the RenderSlime code has what I am looking for. However, I am not quite sure how to properly incorporate it into my Renderer, because the slime code is designed to render the outer transparent layer, then the inner opaque layer. I'm pretty sure I should modify my shouldRenderPass method, which currently only returns -1, to contain some of the code from the RenderSlime shouldRenderPass method. My first attempt was just copying the RenderSlime code and removing the line "this.setRenderPassModel(this.scaleAmount);" because I think that is the part that handles the inner and outer layers. That left me with this code: protected int shouldRenderPass(EntityGhost p_77032_1_, int p_77032_2_, float p_77032_3_) { if (p_77032_1_.isInvisible()) { return 0; } else if (p_77032_2_ == 0) { GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); return 1; } else { if (p_77032_2_ == 1) { GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } return -1; } } Upon testing, the mob still failed to render as transparent and my console was constantly spammed with errors until I killed it.
  17. So I've been trying to make a ghost-like mob that is semi-transparent. For its texture, I added a partial transparency mask, and I know I have done it right because I have gotten blocks to render in as semi-transparent. However, with blocks, there is a getRenderBlockPass method that lets you tell it to render as alpha. I haven't found a way to do this with entities though.
  18. I'm almost afraid to post this because I know I've screwed up even worse now. So I made some changes to my TickHandler and IEEP, and I seem to be on the right track, because I can get the counter to continue to properly increment upon relogging. What's weird now is that my print statements print out twice and the second one resets when I relog while the first one remains correct. (So for example, it prints out "Days alive from NBT: 3" twice, then I relog and increment one more day, so it then prints out "Days alive from NBT: 4" and then prints out "Days alive from NBT: 1"). My new code is as follows: TickHandler: public class PlayerTickHandler { public PlayerTickHandler() { } @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { ExtendedPlayer dayInfo = ExtendedPlayer.get((EntityPlayer) event.player); if(dayInfo.getWorldInfo().getWorldTime() >= 13000 ) { if(!dayInfo.getNight()) { dayInfo.makeNight(); dayInfo.addDay(); System.out.println("(Night)Days alive from NBT: " + dayInfo.getDaysAlive()); } } else { if(dayInfo.getNight()) { dayInfo.makeDay(); System.out.println("(Day)Days alive from NBT: " + dayInfo.getDaysAlive()); } } } } ExtendedPlayer public class ExtendedPlayer implements IExtendedEntityProperties{ public final static String DAY_INFO = "ExtendedPlayer"; private final EntityPlayer player; private World world; private WorldInfo worldInfo; private int daysAlive; private boolean isNight; public ExtendedPlayer(EntityPlayer player) { this.player = player; this.daysAlive=0; this.world = player.worldObj; this.worldInfo = world.getWorldInfo(); } public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedPlayer.DAY_INFO, new ExtendedPlayer(player)); } public static final ExtendedPlayer get(EntityPlayer player) { return (ExtendedPlayer) player.getExtendedProperties(DAY_INFO); } public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.setInteger("DaysAlive", this.daysAlive); properties.setBoolean("IsNight", this.isNight); compound.setTag(DAY_INFO, properties); } public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(DAY_INFO); this.daysAlive = properties.getInteger("DaysAlive"); this.isNight = properties.getBoolean("IsNight"); System.out.println("Days alive from NBT: " + this.daysAlive); } public void init(Entity entity, World world) { } public void addDay() { this.daysAlive++; } //Not exactly necessary since NBTData is cleared upon death public void resetDays() { this.daysAlive=0; } public int getDaysAlive() { return this.daysAlive; } public void makeDay() { this.isNight=false; } public void makeNight() { this.isNight=true; } public boolean getNight() { return this.isNight; } public World getWorld() { return this.world; } public WorldInfo getWorldInfo() { return this.worldInfo; } }
  19. Alright, so I am trying to keep track of the amount of days each player has been alive, so I set up a TickHandler and registered an ExtendedPlayer class implementing IExtendedEntityProperties. I'm not too familiar with how NBTData works so I pretty much followed a tutorial to set up the ExtendedPlayer class. When testing my code, it successfully kept track of the amount of days a player was alive and reset when the player died (I simply took advantage of NBTData clearing upon death). However, when relogging with that player, the counter would remain frozen at its current number and no longer increment each day. My code is as follows: My TickHandler code: public class PlayerTickHandler { private Minecraft mc; public World world; public EntityPlayer player; public ChatStyle style = new ChatStyle(); public WorldInfo worldInfo; public boolean night; public ExtendedPlayer props; public int counter; public PlayerTickHandler(Minecraft mc) { this.mc = mc; } @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { if (this.player == null) { this.player = event.player; this.world = player.worldObj; this.worldInfo = world.getWorldInfo(); this.props = ExtendedPlayer.get((EntityPlayer) event.player); } if (counter < 500) { counter++; } else { counter=0; System.out.println("(Counter)Days alive from NBT: " + props.getDaysAlive()); } if(worldInfo.getWorldTime() >= 13000 ) { if(!props.getNight()) { props.makeNight(); props.addDay(); System.out.println("(Night)Days alive from NBT: " + props.getDaysAlive()); } } else { if(props.getNight()) { props.makeDay(); System.out.println("(Day)Days alive from NBT: " + props.getDaysAlive()); } } } } My ExtendedPlayer code: public class ExtendedPlayer implements IExtendedEntityProperties{ public final static String PROP_NAME = "ExtendedPlayer"; private final EntityPlayer player; private int daysAlive; private boolean isNight; public ExtendedPlayer(EntityPlayer player) { this.player = player; this.daysAlive=0; } public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedPlayer.PROP_NAME, new ExtendedPlayer(player)); } public static final ExtendedPlayer get(EntityPlayer player) { return (ExtendedPlayer) player.getExtendedProperties(PROP_NAME); } public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.setInteger("DaysAlive", this.daysAlive); properties.setBoolean("IsNight", this.isNight); compound.setTag(PROP_NAME, properties); } public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(PROP_NAME); this.daysAlive = properties.getInteger("DaysAlive"); this.isNight = properties.getBoolean("IsNight"); System.out.println("Days alive from NBT: " + this.daysAlive); } public void init(Entity entity, World world) { } public void addDay() { this.daysAlive++; } //Not exactly necessary since NBTData is cleared upon death public void resetDays() { this.daysAlive=0; } public int getDaysAlive() { return this.daysAlive; } public void makeDay() { this.isNight=false; } public void makeNight() { this.isNight=true; } public boolean getNight() { return this.isNight; } } I used the print statements for debugging, printing out the number of saved days. They would increment properly each day and reset to 0 upon dying. Upon relogging, they would continuously print out the same number they were at when I logged out.
  20. So I may be missing something pretty obvious, but I can't seem to find a way to easily grab the current World and EntityPlayer classes so I can manually spawn a mob via a PlayerTickEvent. To elaborate on what exactly I'm trying to do, I want to keep track of the number of days a player has been alive, and if a certain number is reached, a mob is spawned near that player. I may be wrong to use a PlayerTickEvent for this, so feel free to correct me on that, but my main question is simply how to get the info of the current world and player so I can actually spawn the mob. As another note, my TickHandler does have access to the current instance of Minecraft, since I heard it was a good way to give it access to world and player info, but I was unable to find anything useful in the Minecraft class itself.
×
×
  • Create New...

Important Information

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