Jump to content

Recommended Posts

Posted

Update : Updating forge fixed the problem of the event not firing at all. But now I am trying to work the logic to disable right clicking on crafting tables.

 

 @SubscribeEvent
    public void rightClickBlock(RightClickBlock event) {
    	
    	if (event.getUseBlock().name().contains("crafting")) {
    		
    		event.setCanceled(true); 
    	}
    }

 

Tried that and other variants with the string method, ain't working. 

 

 

Posted
4 minutes ago, MineModder2000 said:

Tried that and other variants with the string method, ain't working. 

Just because something can be represented as a string doesn't mean it should be.

 

Also did you check the return type of RightClickBlock#getUseBlock? It doesn't have anything to do with what block was right clicked. Look at the stuff you do have access to in order to get the block that is being right clicked.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
41 minutes ago, Animefan8888 said:

Just because something can be represented as a string doesn't mean it should be.

 

Also did you check the return type of RightClickBlock#getUseBlock? It doesn't have anything to do with what block was right clicked. Look at the stuff you do have access to in order to get the block that is being right clicked.

	@SubscribeEvent
    public void rightClickBlock(RightClickBlock event) {
    	
    	if (event.getPlayer().getBlockState().getBlock() == Blocks.CRAFTING_TABLE) {
    		
    		event.setCanceled(true); 
    	}
    }

 

Can't figure it out, this didn't work either....

Posted
1 minute ago, MineModder2000 said:

Can't figure it out, this didn't work either....

You're getting closer you do need to use the PlayerEntity. Hint: Every Entity has access to the world it's in. Also there is one more method you need to use from the event.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 hour ago, Animefan8888 said:

You're getting closer you do need to use the PlayerEntity. Hint: Every Entity has access to the world it's in. Also there is one more method you need to use from the event.

Kumbaya my lord, Kumbaya :)

Posted (edited)

Okay now it's time to modify existing / vanilla mobs. I need to :

 

  1.  Spawn mobs in the over-world that otherwise don't spawn there (nether mobs for example). 
  2.  Alter mob AI
  3.  Spawn night mobs during the day, and have them not set on fire when exposed to sun rays. 
Edited by MineModder2000
Posted
7 hours ago, diesieben07 said:

Biome#addSpawn. You might have to override the default "can spawn" behavior if you do this, by using LivingSpawnEvent.CheckSpawn.

 

MobEntity#goalSelector is public. You can adjust it to your heart's content in EntityJoinWorldEvent.

 

You can adjust the spawning rules for vanilla mobs using LivingSpawnEvent.CheckSpawn.

 

Not easy. You might have to just replace the mobs entirely using EntityJoinWorldEvent.

 

Are you on a different version than 1.14.4? I'm not seeing any of these methods. Biome has addFeature, addCarver, and addStructure, but not addSpawn. I don't see any CheckSpawn or goalSelector in those other classes / events either. 

Posted

Uh...

public abstract class MobEntity extends LivingEntity {
   //...
   public final GoalSelector goalSelector;

and

   protected void addSpawn(EntityClassification type, Biome.SpawnListEntry spawnListEntry) {
      //...
   }

Forge build 1.14.4-28.0.45

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 hour ago, Draco18s said:

Uh...


public abstract class MobEntity extends LivingEntity {
   //...
   public final GoalSelector goalSelector;

and


   protected void addSpawn(EntityClassification type, Biome.SpawnListEntry spawnListEntry) {
      //...
   }

Forge build 1.14.4-28.0.45

 

Oh whoops I was looking into Entity instead of MobEntity. Keyword in addSpawn is PROTECTED, can't access. CheckSpawn class is static, but it's methods are not, so I can't access those either. 

Posted
57 minutes ago, MineModder2000 said:

Keyword in addSpawn is PROTECTED, can't access

Reflection exists.

  • Sad 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
5 minutes ago, MineModder2000 said:

CheckSpawn

This is an event.

 

45 minutes ago, MineModder2000 said:

Keyword in addSpawn is PROTECTED, can't access.

Instead use WorldEvent.PotentialSpawns until addSpawn is no longer protected I though I don't think that will happen.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
18 minutes ago, Animefan8888 said:

This is an event.

 

Instead use WorldEvent.PotentialSpawns until addSpawn is no longer protected I though I don't think that will happen.

 

Okay got the spawn code :

 

  @SubscribeEvent
    public void potentialSpawns(PotentialSpawns event) {
    	
    	event.getList().add(new SpawnListEntry(EntityType.ZOMBIE_PIGMAN, 10, 3, 5));
    }
    

 

It doesn't work with that alone. I'm looking through CheckSpawn, not seeing any "can spawn" type method. I did try this :

 

    @SubscribeEvent
    public void checkSpawn(CheckSpawn event) {
    	
    	if (event.getEntity().getType() == EntityType.ZOMBIE_PIGMAN) {
    	
    		event.getSpawner().getSpawnerEntity().forceSpawn = true;
    	}
    }

 

But yeah it didn't work...

Posted
7 hours ago, diesieben07 said:

Please read the god damn documentation.

Hey hey, don't be rude. I read it before, always do, so don't assume things. I see what it says about the Result, but Result isn't in the class itself so I am confused. The RightClickBlock class has this for example :

 

 public void setUseBlock(Result triggerBlock)
        {
            this.useBlock = triggerBlock;
        }

 

CheckSpawn doesn't have any of that, no setters at all......

Posted
4 minutes ago, MineModder2000 said:

I see what it says about the Result, but Result isn't in the class itself so I am confused.

Its part of the Event parent class.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
28 minutes ago, Draco18s said:

Its part of the Event parent class.

 

Tried this....

 

    @SubscribeEvent
    public void checkSpawn(CheckSpawn event) {
    	
    	if (event.isSpawner()) {
    		
        	event.getSpawner().setEntityType(EntityType.ZOMBIE_PIGMAN);
    		event.setResult(Result.ALLOW);
    	}
    }

 

Nopers....

Posted (edited)
43 minutes ago, diesieben07 said:

Yey, you only do something if isSpawner is true. Which is for (you guessed it) spawners. Also don't do that setEntityType thing, what are you trying to accomplish with that?

Whoops I put the wrong code in my paste, I was testing something with that isSpawner check. As far as the setEntityType, that's just me playing around with things to try and get something to work.

 

I've tried this, no check, just setting every instance Result to Allowed :

 

@SubscribeEvent
    public void checkSpawn(CheckSpawn event) {
  
    		event.setResult(Result.ALLOW);
    }

 

Nopers....

Edited by MineModder2000
Posted (edited)
19 minutes ago, diesieben07 said:

Okay. And now my 2nd question...?=

 

Oh sorry. I assume you mean Eclipse debugger, I'm not launching from Eclipse as I can't get that to work. 

Edited by MineModder2000
Posted
On 9/16/2019 at 10:46 AM, diesieben07 said:

Then you need to fix that. The debugger is vital in developing any kind of Java.

While I work on that, I need more understanding of this :

 

"MobEntity#goalSelector is public. You can adjust it to your heart's content in EntityJoinWorldEvent."

 

But how do I access that inside of the event?

 

 

Posted
2 minutes ago, MineModder2000 said:

But how do I access that inside of the event?

if event,getEntity instanceof MobEntity

   // Cast event.getEntity to MobEntity and access goalSelector

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 hour ago, Animefan8888 said:

if event,getEntity instanceof MobEntity

   // Cast event.getEntity to MobEntity and access goalSelector

OMG I got it working, but the instanceof check is not unnecessary, it already will be that. I just check for the correct type then add a goal. 

Posted (edited)

Okay got an issue, I have the pigs running away via the AvoidEntityGoal when I get too close, however they don't do it the way rabbits do, they occasionally stroll here and there instead of running which makes it too easy to hunt them. It might have to do with interference from their other behavior...

 

Also in the following : 

 

AvoidEntityGoal<>(this, PlayerEntity.class, 8.0F, 2.2D, 2.2D));

 

What do the last two number represent? I know the first one is the distance that triggers them to run. 

Edited by MineModder2000
Posted
19 minutes ago, MineModder2000 said:

What do the last two number represent?

Have you taken a look at the code? They are two speed values one for when the entity they need to avoid is far and when it is near.

22 minutes ago, MineModder2000 said:

It might have to do with interference from their other behavior...

What priority did you give it when you added it?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
55 minutes ago, Animefan8888 said:

Have you taken a look at the code? They are two speed values one for when the entity they need to avoid is far and when it is near.

What priority did you give it when you added it?

Whoops I see it now. I gave it 4 initially, then 99 but that didn't help...... oh wait it's suppose to be a smaller number doh! Working now. 

Edited by MineModder2000

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




×
×
  • Create New...

Important Information

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