use of net.minecraft.client.multiplayer.WorldClient in project MorePlanets by SteveKunG.
the class ClientProxyMP method handleCustomSpawning.
private static void handleCustomSpawning() {
EntityRegistration entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySpaceFishHook.class, false);
Function<FMLMessage.EntitySpawnMessage, Entity> handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
int entityID = 0;
double posX = 0;
double posY = 0;
double posZ = 0;
try {
entityID = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "throwerId").getInt(input);
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity angler = world.getEntityByID(entityID);
if (angler instanceof EntityPlayer) {
Entity entity = new EntitySpaceFishHook(world, (EntityPlayer) angler, posX, posY, posZ);
return entity;
}
return null;
};
entityRegistration.setCustomSpawning(handler, false);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityCheeseSpore.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntityCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySmallCheeseSpore.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntitySmallCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityVeinBall.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntityVeinBall(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
}
use of net.minecraft.client.multiplayer.WorldClient in project Almura by AlmuraDev.
the class ClientboundFeaturesOpenResponsePacketHandler method handleMessage.
@Override
public void handleMessage(ClientboundFeaturesOpenResponsePacket message, RemoteConnection connection, Platform.Type side) {
if (side.isClient()) {
final Minecraft client = Minecraft.getMinecraft();
if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
final EntityPlayerSP player = client.player;
final WorldClient world = client.world;
final boolean isAdmin = message.admin;
new FeatureScreen(player, world, isAdmin).display();
}
}
}
use of net.minecraft.client.multiplayer.WorldClient in project Almura by AlmuraDev.
the class ClientboundPlayerDiedPacketHandler method handleMessage.
@Override
public void handleMessage(ClientboundPlayerDiedPacket message, RemoteConnection connection, Platform.Type side) {
if (side.isClient()) {
final Minecraft client = Minecraft.getMinecraft();
if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
final EntityPlayerSP player = client.player;
final WorldClient world = client.world;
new PlayerDiedGUI(player, message.droppedAmount, message.deathTaxAmount, message.dropCoins, message.canRevive).display();
}
}
}
use of net.minecraft.client.multiplayer.WorldClient in project Hyperium by HyperiumClient.
the class DragonHeadRenderer method renderHead.
private void renderHead(EntityPlayer player, float partialTicks) {
double scale = 1.0F;
double rotate = CosmeticsUtil.interpolate(player.prevRotationYawHead, player.rotationYawHead, partialTicks);
double rotate1 = CosmeticsUtil.interpolate(player.prevRotationPitch, player.rotationPitch, partialTicks);
GlStateManager.scale(-scale, -scale, scale);
GL11.glRotated(180.0 + rotate, 0.0, 1.0, 0.0);
GlStateManager.translate(0.0, -(player.height - .4) / scale, 0.0);
GlStateManager.translate(0.0D, 0.0D, .05 / scale);
GL11.glRotated(rotate1, 1.0D, 0.0D, 0.0D);
GlStateManager.translate(0.0, -0.3 / scale, .06);
if (player.isSneaking())
GlStateManager.translate(0.0, 0.125 / scale, 0.0);
float[] colors = new float[] { 1.0f, 1.0f, 1.0f };
if (player.onGround) {
jaw.rotateAngleX = 0;
} else {
if (mc.theWorld != null) {
int e = -1;
WorldClient theWorld = Minecraft.getMinecraft().theWorld;
Chunk chunk = theWorld.getChunkFromBlockCoords(new BlockPos(player.posX, player.posY, player.posZ));
for (int i = 0; i < 255; i++) {
if (i > player.posY)
break;
Block block = chunk.getBlock(new BlockPos(player.posX, i, player.posZ));
if (block != null && !block.getMaterial().equals(Material.air))
e = i;
}
jaw.rotateAngleX = 0;
if (e != -1) {
double dis = Math.abs(e - player.posY);
dis /= 4;
if (dis != 0) {
jaw.rotateAngleX = (float) ((dis) / (1 + dis));
}
}
} else {
jaw.rotateAngleX = 0;
}
}
GlStateManager.color(colors[0], colors[1], colors[2]);
mc.getTextureManager().bindTexture(selectedLoc);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
head.render(.1F);
GL11.glCullFace(GL11.GL_BACK);
GL11.glDisable(GL11.GL_CULL_FACE);
}
use of net.minecraft.client.multiplayer.WorldClient in project Hyperium by HyperiumClient.
the class GuiHyperiumScreenIngameMenu method initGui.
@Override
public void initGui() {
super.initGui();
buttonList.clear();
int i = -16;
buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 120 + i, I18n.format("menu.returnToMenu")));
/* If Client is on server, add disconnect button */
if (!mc.isIntegratedServerRunning())
(buttonList.get(0)).displayString = I18n.format("menu.disconnect");
/* Add initial buttons */
buttonList.add(new GuiButton(4, width / 2 - 100, height / 4 + 24 + i, I18n.format("menu.returnToGame")));
buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 96 + i, 98, 20, I18n.format("menu.options")));
GuiButton guibutton;
buttonList.add(guibutton = new GuiButton(7, width / 2 + 2, height / 4 + 96 + i, 98, 20, I18n.format("menu.shareToLan")));
buttonList.add(new GuiButton(5, width / 2 - 100, height / 4 + 48 + i, 98, 20, I18n.format("gui.achievements")));
buttonList.add(new GuiButton(6, width / 2 + 2, height / 4 + 48 + i, 98, 20, I18n.format("gui.stats")));
guibutton.enabled = mc.isSingleplayer() && !mc.getIntegratedServer().getPublic();
buttonList.add(new GuiButton(9, width / 2 - 100, height / 4 + 56, 98, 20, I18n.format("button.ingame.hyperiumsettings")));
buttonList.add(new GuiButton(8, width / 2 + 2, height / 4 + 56, 98, 20, I18n.format("button.ingame.hyperiumcredits")));
WorldClient theWorld = Minecraft.getMinecraft().theWorld;
// Used to detect if the player is on a singleplayer world or a multiplayer world.
MinecraftServer integratedServer = Minecraft.getMinecraft().getIntegratedServer();
if (theWorld != null && (integratedServer == null)) {
GuiButton oldButton = buttonList.remove(3);
GuiButton newButton = new GuiButton(10, oldButton.xPosition, oldButton.yPosition, oldButton.getButtonWidth(), 20, I18n.format("button.ingame.serverlist"));
buttonList.add(newButton);
}
}
Aggregations