Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/makeo/gadomancy/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import makeo.gadomancy.common.blocks.tiles.TileStickyJar;
import makeo.gadomancy.common.entities.EntityAuraCore;
import makeo.gadomancy.common.entities.EntityPermNoClipItem;
import makeo.gadomancy.common.events.EventHandlerTooltips;
import makeo.gadomancy.common.registration.RegisteredBlocks;
import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.Injector;
Expand All @@ -95,7 +96,7 @@
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
*
* <p>
* Created by makeo @ 29.11.2014 14:15
*/
public class ClientProxy extends CommonProxy {
Expand Down Expand Up @@ -227,15 +228,15 @@ public void initalize() {
@Override
public void postInitalize() {
IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
if (manager instanceof SimpleReloadableResourceManager) {
SimpleReloadableResourceManager rm = (SimpleReloadableResourceManager) manager;
if (manager instanceof SimpleReloadableResourceManager rm) {
rm.registerReloadListener(ResourceReloadListener.getInstance());
}

MinecraftForge.EVENT_BUS.register(new EventHandlerTooltips());
MinecraftForge.EVENT_BUS.register(EffectHandler.getInstance());
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());
FMLCommonHandler.instance().bus().register(new RenderEventHandler());

final RenderEventHandler renderHandler = new RenderEventHandler();
MinecraftForge.EVENT_BUS.register(renderHandler);
FMLCommonHandler.instance().bus().register(renderHandler);
FMLCommonHandler.instance().bus().register(new ClientHandler());

super.postInitalize();
Expand Down
100 changes: 42 additions & 58 deletions src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package makeo.gadomancy.client.events;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.zip.GZIPInputStream;

Expand Down Expand Up @@ -60,21 +59,39 @@
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
*
* <p>
* Created by makeo @ 13.10.2015 16:11
*/
public class RenderEventHandler {
public final class RenderEventHandler {

private static final REHWandHandler WAND_HANDLER = new REHWandHandler();
private static final FakeArchitectItem ARCHITECT_ITEM = new FakeArchitectItem();
private static final IModelCustom obj;
private static final ResourceLocation texture = new ResourceLocation("gadomancy:textures/misc/texW.png");

static {
ResourceLocation resourceLocation = new ResourceLocation("gadomancy:textures/models/modelAssec.obj");
IModelCustom buf;
try {
buf = new WavefrontObject(
"gadomancy:wRender",
new GZIPInputStream(
Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation)
.getInputStream()));
} catch (Exception exc) {
// shush.
buf = null;
}
obj = buf;
}

private final REHWandHandler WAND_HANDLER = new REHWandHandler();
private final FakeArchitectItem ARCHITECT_ITEM = new FakeArchitectItem();
private Object oldGolemblurb;
private int blurbId;
private int dList = -1;

@SubscribeEvent
public void on(GuiScreenEvent.DrawScreenEvent.Pre e) {
if (e.gui instanceof GuiGolem) {
GuiGolem gui = (GuiGolem) e.gui;
if (e.gui instanceof GuiGolem gui) {
EntityGolemBase golem = new Injector(gui, GuiGolem.class).getField("golem");
if (golem != null) {
AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem);
Expand Down Expand Up @@ -103,13 +120,13 @@ public void on(DrawBlockHighlightEvent e) {
if (e.currentItem == null) return;
if (e.currentItem.getItem() instanceof ItemWandCasting) {
ItemFocusBasic focus = ((ItemWandCasting) e.currentItem.getItem()).getFocus(e.currentItem);
if (focus == null || !(focus instanceof IArchitect)) {
if (!(focus instanceof IArchitect)) {
Block block = e.player.worldObj.getBlock(e.target.blockX, e.target.blockY, e.target.blockZ);
if (block != null && block == RegisteredBlocks.blockArcaneDropper) {
ForgeDirection dir = ForgeDirection.getOrientation(
e.player.worldObj.getBlockMetadata(e.target.blockX, e.target.blockY, e.target.blockZ) & 7);

ArrayList<BlockCoordinates> coords = new ArrayList<BlockCoordinates>();
ArrayList<BlockCoordinates> coords = new ArrayList<>();
for (int x = -1; x < 2; x++) {
for (int y = -1; y < 2; y++) {
for (int z = -1; z < 2; z++) {
Expand All @@ -127,11 +144,11 @@ public void on(DrawBlockHighlightEvent e) {
e.target.blockY + dir.offsetY,
e.target.blockZ + dir.offsetZ));

RenderEventHandler.ARCHITECT_ITEM.setCoords(coords);
this.ARCHITECT_ITEM.setCoords(coords);

GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
RenderEventHandler.WAND_HANDLER.handleArchitectOverlay(
new ItemStack(RenderEventHandler.ARCHITECT_ITEM),
this.WAND_HANDLER.handleArchitectOverlay(
new ItemStack(this.ARCHITECT_ITEM),
e,
e.player.ticksExisted,
e.target);
Expand All @@ -145,13 +162,11 @@ public void on(DrawBlockHighlightEvent e) {
int blockZ = e.target.blockZ;
if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) {
TileEntity tile = e.player.worldObj.getTileEntity(blockX, blockY, blockZ);
if (tile instanceof TileExtendedNode) {
TileExtendedNode node = (TileExtendedNode) tile;
if (tile instanceof TileExtendedNode node) {
if (node.getExtendedNodeType() == null) return;
ExtendedTypeDisplayManager
.notifyDisplayTick(node.getId(), node.getNodeType(), node.getExtendedNodeType());
} else if (tile instanceof TileExtendedNodeJar) {
TileExtendedNodeJar nodeJar = (TileExtendedNodeJar) tile;
} else if (tile instanceof TileExtendedNodeJar nodeJar) {
if (nodeJar.getExtendedNodeType() == null) return;
ExtendedTypeDisplayManager
.notifyDisplayTick(nodeJar.getId(), nodeJar.getNodeType(), nodeJar.getExtendedNodeType());
Expand All @@ -162,8 +177,7 @@ public void on(DrawBlockHighlightEvent e) {

@SubscribeEvent
public void guiOpen(GuiOpenEvent event) {
if (event.gui != null && event.gui instanceof GuiResearchRecipe) {
GuiResearchRecipe gui = (GuiResearchRecipe) event.gui;
if (event.gui instanceof GuiResearchRecipe gui) {
ResearchItem research = new Injector(gui, GuiResearchRecipe.class).getField("research");
if (research.key.equals(Gadomancy.MODID.toUpperCase() + ".AURA_EFFECTS")
&& !(gui instanceof GuiResearchRecipeAuraEffects)) {
Expand All @@ -183,10 +197,8 @@ public void worldRenderEvent(RenderWorldLastEvent event) {

@SubscribeEvent(priority = EventPriority.LOWEST)
public void renderEntityPre(RenderLivingEvent.Pre event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) event.entity;
if (((DataAchromatic) SyncDataHolder.getDataClient("AchromaticData"))
.isAchromatic((EntityPlayer) event.entity)) {
if (event.entity instanceof EntityPlayer p) {
if (((DataAchromatic) SyncDataHolder.getDataClient("AchromaticData")).isAchromatic(p)) {
this.current = p;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
GL11.glDepthMask(false);
Expand Down Expand Up @@ -224,8 +236,7 @@ public void renderEntityPre(RenderLivingEvent.Pre event) {

@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void renderPost(RenderLivingEvent.Post event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) event.entity;
if (event.entity instanceof EntityPlayer p) {
if (this.armor != null) {
p.inventory.armorInventory = this.armor;
}
Expand All @@ -241,33 +252,6 @@ public void onSetArmor(RenderPlayerEvent.SetArmorModel event) {
}
}

static {
ResourceLocation mod = new ResourceLocation(
Gadomancy.MODID.toLowerCase() + new String(
new byte[] { 58, 116, 101, 120, 116, 117, 114, 101, 115, 47, 109, 111, 100, 101, 108, 115, 47,
109, 111, 100, 101, 108, 65, 115, 115, 101, 99, 46, 111, 98, 106 },
StandardCharsets.UTF_8));
IModelCustom buf;
try {
buf = new WavefrontObject(
"gadomancy:wRender",
new GZIPInputStream(
Minecraft.getMinecraft().getResourceManager().getResource(mod).getInputStream()));
} catch (Exception exc) {
// shush.
buf = null;
}
obj = buf;
}

private static final IModelCustom obj;
private static final ResourceLocation tex = new ResourceLocation(
new String(
new byte[] { 103, 97, 100, 111, 109, 97, 110, 99, 121, 58, 116, 101, 120, 116, 117, 114, 101, 115,
47, 109, 105, 115, 99, 47, 116, 101, 120, 87, 46, 112, 110, 103 },
StandardCharsets.UTF_8));
private static int dList = -1;

@SubscribeEvent
public void onRender(RenderPlayerEvent.Specials.Post event) {
if (event.entityPlayer == null) return;
Expand All @@ -278,30 +262,30 @@ public void onRender(RenderPlayerEvent.Specials.Post event) {
GL11.glColor4f(1f, 1f, 1f, 1f);

GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(RenderEventHandler.tex);
Minecraft.getMinecraft().renderEngine.bindTexture(RenderEventHandler.texture);
boolean f = event.entityPlayer.capabilities.isFlying;
double ma = f ? 15 : 5;
double r = (ma * (Math.abs((ClientHandler.ticks % 80) - 40) / 40D)) + ((65 - ma) * Math
.max(0, Math.min(1, new Vector3(event.entityPlayer.motionX, 0, event.entityPlayer.motionZ).length())));
GL11.glScaled(0.07, 0.07, 0.07);
GL11.glRotatef(180, 0, 0, 1);
GL11.glTranslated(0, -12.7, 0.7 - (((float) (r / ma)) * (f ? 0.5D : 0.2D)));
if (RenderEventHandler.dList == -1) {
RenderEventHandler.dList = GLAllocation.generateDisplayLists(2);
GL11.glNewList(RenderEventHandler.dList, GL11.GL_COMPILE);
if (this.dList == -1) {
this.dList = GLAllocation.generateDisplayLists(2);
GL11.glNewList(this.dList, GL11.GL_COMPILE);
RenderEventHandler.obj.renderOnly("wR");
GL11.glEndList();
GL11.glNewList(RenderEventHandler.dList + 1, GL11.GL_COMPILE);
GL11.glNewList(this.dList + 1, GL11.GL_COMPILE);
RenderEventHandler.obj.renderOnly("wL");
GL11.glEndList();
}
GL11.glPushMatrix();
GL11.glRotated(20D + r, 0, -1, 0);
GL11.glCallList(RenderEventHandler.dList);
GL11.glCallList(this.dList);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotated(20D + r, 0, 1, 0);
GL11.glCallList(RenderEventHandler.dList + 1);
GL11.glCallList(this.dList + 1);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
Expand Down
44 changes: 21 additions & 23 deletions src/main/java/makeo/gadomancy/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import makeo.gadomancy.common.containers.ContainerInfusionClaw;
import makeo.gadomancy.common.data.SyncDataHolder;
import makeo.gadomancy.common.data.config.ModConfig;
import makeo.gadomancy.common.events.EventHandlerEntity;
import makeo.gadomancy.common.events.EventHandlerEntityServer;
import makeo.gadomancy.common.events.EventHandlerGolem;
import makeo.gadomancy.common.events.EventHandlerGolemServer;
import makeo.gadomancy.common.events.EventHandlerNetwork;
import makeo.gadomancy.common.events.EventHandlerWorld;
import makeo.gadomancy.common.network.PacketHandler;
Expand Down Expand Up @@ -72,6 +73,8 @@ public void initalize() {
RegisteredEntities.init();
DimensionManager.registerProviderType(ModConfig.dimOuterId, WorldProviderTCEldrich.class, true);
DimensionManager.registerDimension(ModConfig.dimOuterId, ModConfig.dimOuterId);
FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
MinecraftForge.EVENT_BUS.register(new EventHandlerGolem());
}

public void postInitalize() {
Expand Down Expand Up @@ -126,32 +129,27 @@ public Side getSide() {
return Side.SERVER;
}

public EventHandlerGolem EVENT_HANDLER_GOLEM;
public EventHandlerNetwork EVENT_HANDLER_NETWORK;
public EventHandlerWorld EVENT_HANDLER_WORLD;
public EventHandlerEntity EVENT_HANDLER_ENTITY;
public EventHandlerGolemServer handlerGolemServer;
private EventHandlerWorld handlerWorld;
public EventHandlerEntityServer handlerEntityServer;

public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
EVENT_HANDLER_GOLEM = new EventHandlerGolem();
MinecraftForge.EVENT_BUS.register(EVENT_HANDLER_GOLEM);
EVENT_HANDLER_NETWORK = new EventHandlerNetwork();
FMLCommonHandler.instance().bus().register(EVENT_HANDLER_NETWORK);
EVENT_HANDLER_WORLD = new EventHandlerWorld();
MinecraftForge.EVENT_BUS.register(EVENT_HANDLER_WORLD);
FMLCommonHandler.instance().bus().register(EVENT_HANDLER_WORLD);
EVENT_HANDLER_ENTITY = new EventHandlerEntity();
MinecraftForge.EVENT_BUS.register(EVENT_HANDLER_ENTITY);
handlerGolemServer = new EventHandlerGolemServer();
MinecraftForge.EVENT_BUS.register(handlerGolemServer);
handlerWorld = new EventHandlerWorld();
MinecraftForge.EVENT_BUS.register(handlerWorld);
FMLCommonHandler.instance().bus().register(handlerWorld);
handlerEntityServer = new EventHandlerEntityServer();
MinecraftForge.EVENT_BUS.register(handlerEntityServer);
}

public void onServerStopped(FMLServerStoppedEvent event) {
MinecraftForge.EVENT_BUS.unregister(EVENT_HANDLER_GOLEM);
EVENT_HANDLER_GOLEM = null;
FMLCommonHandler.instance().bus().unregister(EVENT_HANDLER_NETWORK);
EVENT_HANDLER_NETWORK = null;
MinecraftForge.EVENT_BUS.unregister(EVENT_HANDLER_WORLD);
FMLCommonHandler.instance().bus().unregister(EVENT_HANDLER_WORLD);
EVENT_HANDLER_WORLD = null;
MinecraftForge.EVENT_BUS.unregister(EVENT_HANDLER_ENTITY);
EVENT_HANDLER_ENTITY = null;
MinecraftForge.EVENT_BUS.unregister(handlerGolemServer);
handlerGolemServer = null;
MinecraftForge.EVENT_BUS.unregister(handlerWorld);
FMLCommonHandler.instance().bus().unregister(handlerWorld);
handlerWorld = null;
MinecraftForge.EVENT_BUS.unregister(handlerEntityServer);
handlerEntityServer = null;
}
}
4 changes: 2 additions & 2 deletions src/main/java/makeo/gadomancy/common/aura/AuraEffects.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ public boolean isEntityApplicable(Entity e) {

@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
if (!Gadomancy.proxy.EVENT_HANDLER_ENTITY.registeredLuxPylons.contains(originTile)) {
Gadomancy.proxy.EVENT_HANDLER_ENTITY.registeredLuxPylons.add(originTile);
if (!Gadomancy.proxy.handlerEntityServer.registeredLuxPylons.contains(originTile)) {
Gadomancy.proxy.handlerEntityServer.registeredLuxPylons.add(originTile);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <p/>
* Created by HellFirePvP @ 31.10.2015 15:28
*/
public class EventHandlerEntity {
public class EventHandlerEntityServer {

public final List<ChunkCoordinates> registeredLuxPylons = new ArrayList<>();

Expand Down Expand Up @@ -91,8 +91,7 @@ public void on(LivingDeathEvent event) {
@SubscribeEvent
public void on(EntityItemPickupEvent event) {
if (!event.entityPlayer.worldObj.isRemote) {
if (event.item instanceof EntityPermNoClipItem) {
EntityPermNoClipItem item = (EntityPermNoClipItem) event.item;
if (event.item instanceof EntityPermNoClipItem item) {
ChunkCoordinates master = (ChunkCoordinates) item.getDataWatcher()
.getWatchedObject(ModConfig.entityNoClipItemDatawatcherMasterId).getObject();
TileEntity te = event.entityPlayer.worldObj.getTileEntity(master.posX, master.posY, master.posZ);
Expand Down
Loading