MobRepeller - Prevent mob spawning in survival!

#MobRepeller

##Description
This plugin adds MobRepellers. A repeller is a ‘+’ shape built of valuable block: Lapis, iron, gold, diamond. All registered repellers prevent mob spawning in a radius calculated based on the amount and worthiness of the blocks.

##Usage
Build a ‘+’ shape(lying on the ground) out of the lapis, iron, gold and/or diamond blocks.

:arrow_right: Mobs won’t spawn in the radius around the repeller.

####Radius increase of blocks(Screenshot below illustrates it better):
Lapis: 2
Iron: 2
Gold: 4
Diamond: 6
Emerald: 10

##Screenshots

The most basic repeller in the 4 different materials.

An ugly repeller which has a radius of 42 = 52+32+24+36.
5 * lapis, 3 * iron, 2 * gold, 3 * diamond.

##Commands

  • listRepellers

##Download
:arrow_forward: Jar-Download :arrow_backward:
GitHub

##Idea
Thanks to @manwithpancakes: Forum thread


RandomByte

2 Likes

Very Kotlin, much wow.

Nice plugin though! I wonder if it would be possible to allow repellers to be registered automatically?

1 Like

Thanks!

I tried that before(don’t know if I pushed that to GitHub). I think it wouldn’t be good for the performance. I mean only my plugin on the server -> everything is fine but with some more plugins, every checking each block placement and iterating over some more blocks around the changed block: That would cause lags.
I could make it configurable. But before I have to fix some bugs and make this plugin more user friendly.

Yeah, I was thinking configurable.

Just something to consider: Minecraft, on its own, without sponge, tracks 100s of entities, 1000s of blocks, and potentially 100s of block places and mutations to the world, every tick. Checking block placement, and 4 blocks around it, shouldn’t really cause lag, now if you did something like parse a database on every EntityMove event (which that Portal plugin accidentally did), the lag is noticeable, but still technically playable. Put simply Computers are really fast.

Additionally you could only check when placing the blocks the repeller is made of? Since people aren’t often placing diamond/gold/iron/lapis blocks.

Couldn’t you just use a sign to activate the repeller? Example:

  1. Build structure
  2. place sign with text repeller on 2nd row
  3. plugin detects the sign (+text) and activates the repeller

That’s probably more resourcefriendly than checking every placed and or removed block and the user still gets around typing commands in chat.

@manwithpancakes lol, haven’t thought of this. It already does that but I forgot!
@meguy26 Thanks for pointing this out!
@Tzk Also thanks to you!

I will think about it. Thanks for your suggestions!

If you do this, either cache the block states at a given x y z location, limit the amount of objects you create in the loop.

The other option you may want to think about creating a tree of all the possible rotations / offsets that a given blockshape can be in, that will reduce the amount of times you need to loop drastically.

The final thing is do you get people to configure block types, block states, or block snapshots? block states and block snapshots are user unfriendly as they may “over specify” a block.

What we really need is a config serializable block matcher / partial block snapshot that can be easily understood by users.

I’d suggest some way of specifying the blocktype, blocktraits, and letting the user leave block traits unlisted to create a set of blockstates as a minimum of what this matcher should be able to accomplish.

You mean the users of the SpongeAPI = developers or users of this plugin? There should only be one shape this plugin reacts to.
If you meant users of SpongeAPI, then I agree, it would be really cool to have a ‘shape matcher’ built into Sponge. Or someone could create a library.

The shapematcher would be just for your plugin, minecraft has a shape matcher built in (wither, snow golem, iron golem, creeper face), but it’s busted as heck so it’s not worth exposing.

The block matcher on the other hand would be shapeless, just matches against a single block location, and returns true or false depending on whether the block matches the predicate. The reason why we can’t use predicates is that they are not serializable or immutable. The reason for having it built into sponge is to create a common serialization format that is easy for users to use. If plugins don’t like it, they can always create their own format.

1 Like

For what it’s worth, since the 4.0 release, there’s been an increase in the ability to cancel entity spawns before the entity is even constructed. If you listen to ConstructEntityEvent.Pre, you can get the EntityType and the proposed location. This should decrease most of the overhead of creating entity objects that aren’t going to spawn regardless.

2 Likes

Yeah, heard of it in SoS. I will be doing this once I updated the plugin to API version 4.

I am making progress in implementing database storage(in database branch if someone wants to have a look).

###The first beta v0.2.1 was released!

Opening post was edited.

Current download: Release Changed database location · randombyte-developer/MobRepeller · GitHub

We’ll take what we can get xD Better than Bukkit I’d presume :slight_smile:

###v0.2.2 was released!


Changes:

  • Removed Updatifier because of problems
  • Removed registerRepeller command, just build a repeller and it will get registered automatically
  • Changed listRepellers output
  • Added needed libs to run this plugin
  • Fixed typos and minor things

Thanks! I’ll check it out in a bit, I’ve been pretty busy

##v1.0 released: Download

Changes:

  • Added mcmod.info file
  • Updated exposed

Thanks For all the hard work!

I really like having players capable of setting up their own MobRepeller zones.

I got a bit confused about the text in the message. And thought it mighty help to clarify what the red/green X’s were the players position relative to the radius of each MobRepeller. (inside or outside). I didn’t really see it explained anywhere, after checking the code I felt dumb.

It’s a minor thing, but if you get a chance a flourish in the text I think would clarify what I got confused on. I would appreciate it anyhow :smile:

=== Position Radius X/X(in radius) ===
129, 62, 265 78 X
14, 62, 334 38 X

Maybe something like?
=== Position: Radius: Your Position ===
129, 62, 265: 78: inside radius
129, 62, 265: 38: outside radius

1 Like

Thanks for your feedback! :+1: I will improve that :slight_smile: