mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Cleanup TickHandler registration
This commit is contained in:
1 parent
2492167833
commit
dea639cee2
4 files changed
+11
-30
No files matched your search
@@ -10,12 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
@@ -25,16 +21,7 @@ import forestry.core.utils.GeneticsUtil;
|
||||
|
||||
public class TickHandlerCoreClient {
|
||||
|
||||
private static final ConcurrentLinkedQueue<String> messages = new ConcurrentLinkedQueue<String>();
|
||||
private boolean hasNaturalistView;
|
||||
|
||||
public TickHandlerCoreClient() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
public void queueChatMessage(String message) {
|
||||
messages.add(message);
|
||||
}
|
||||
private boolean hasNaturalistEye;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(PlayerTickEvent event) {
|
||||
@@ -42,20 +29,13 @@ public class TickHandlerCoreClient {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = Proxies.common.getClientInstance().thePlayer;
|
||||
EntityPlayer player = event.player;
|
||||
boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player);
|
||||
if (hasNaturalistEye != hasNaturalistView) {
|
||||
hasNaturalistView = !hasNaturalistView;
|
||||
if (this.hasNaturalistEye != hasNaturalistEye) {
|
||||
this.hasNaturalistEye = hasNaturalistEye;
|
||||
Proxies.common.getClientInstance().renderGlobal.markBlockRangeForRenderUpdate(
|
||||
(int) player.posX - 32, (int) player.posY - 32, (int) player.posZ - 32,
|
||||
(int) player.posX + 32, (int) player.posY + 32, (int) player.posZ + 32);
|
||||
}
|
||||
|
||||
if (messages.size() > 0) {
|
||||
String message;
|
||||
while ((message = messages.poll()) != null) {
|
||||
player.addChatMessage(new ChatComponentText(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
|
||||
@@ -40,8 +38,6 @@ public class TickHandlerCoreServer {
|
||||
|
||||
public TickHandlerCoreServer(WorldGenerator worldGenerator) {
|
||||
this.worldGenerator = worldGenerator;
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
@@ -52,7 +54,7 @@ public class ClientProxyCommon extends ProxyCommon {
|
||||
public void registerTickHandlers(WorldGenerator worldGenerator) {
|
||||
super.registerTickHandlers(worldGenerator);
|
||||
|
||||
new TickHandlerCoreClient();
|
||||
FMLCommonHandler.instance().bus().register(new TickHandlerCoreClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.world.WorldServer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
@@ -67,7 +68,9 @@ public class ProxyCommon {
|
||||
}
|
||||
|
||||
public void registerTickHandlers(WorldGenerator worldGenerator) {
|
||||
new TickHandlerCoreServer(worldGenerator);
|
||||
TickHandlerCoreServer tickHandlerCoreServer = new TickHandlerCoreServer(worldGenerator);
|
||||
FMLCommonHandler.instance().bus().register(tickHandlerCoreServer);
|
||||
MinecraftForge.EVENT_BUS.register(tickHandlerCoreServer);
|
||||
}
|
||||
|
||||
public void registerBlock(Block block, Class<? extends ItemBlock> itemClass) {
|
||||
|
||||
Reference in new issue
Block a user