Last active
August 29, 2015 14:13
-
-
Save firstspring1845/f7698053226759d9490f to your computer and use it in GitHub Desktop.
敵性モブをデスポーンさせるだけのMOD 1.7.10用のMinecraftForgeで作った
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.firsp.mods; | |
import cpw.mods.fml.common.FMLCommonHandler; | |
import cpw.mods.fml.common.Mod; | |
import cpw.mods.fml.common.event.FMLInitializationEvent; | |
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | |
import cpw.mods.fml.common.gameevent.TickEvent; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.boss.IBossDisplayData; | |
import net.minecraft.entity.monster.IMob; | |
import net.minecraft.server.MinecraftServer; | |
import java.util.Arrays; | |
@Mod(modid = "Despawn Mobs") | |
public class DespawnMobs { | |
@Mod.EventHandler | |
public void init(FMLInitializationEvent event) { | |
FMLCommonHandler.instance().bus().register(this); | |
} | |
@SubscribeEvent | |
public void tickEnd(TickEvent.ServerTickEvent event) { | |
if (event.type == TickEvent.Type.SERVER && event.phase == TickEvent.Phase.END) { | |
Arrays.stream(MinecraftServer.getServer().worldServers) | |
.filter(w -> w != null) | |
.forEach(w -> w.getLoadedEntityList() | |
.stream() | |
.filter(e -> e instanceof IMob) | |
.filter(e -> !(e instanceof IBossDisplayData)) | |
.forEach(e -> ((Entity) e).setDead())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
build.gradleのapply plugin以降に
sourceCompatibility=JavaVersion.VERSION_1_8
targetCompatibility=JavaVersion.VERSION_1_8
を加えるとビルドできるはず
参考 https://twitter.com/alalwww/status/554023357687926784