split client and server 6
This commit is contained in:
parent
a6b0f110b1
commit
3e70accb76
26 changed files with 301 additions and 187 deletions
|
@ -66,6 +66,7 @@ import client.renderer.entity.RenderItem;
|
|||
import client.renderer.entity.RenderManager;
|
||||
import client.renderer.particle.EffectRenderer;
|
||||
import client.renderer.particle.EntityFirework;
|
||||
import client.renderer.texture.ColormapLoader;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import client.renderer.texture.TextureManager;
|
||||
import client.renderer.texture.TextureMap;
|
||||
|
@ -82,7 +83,6 @@ import game.biome.Biome;
|
|||
import game.block.Block;
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
import game.color.Colorizer;
|
||||
import game.color.TextColor;
|
||||
import game.entity.Entity;
|
||||
import game.entity.animal.EntityHorse;
|
||||
|
@ -109,6 +109,7 @@ import game.log.Log;
|
|||
import game.log.LogLevel;
|
||||
import game.log.Message;
|
||||
import game.material.Material;
|
||||
import game.model.ParticleType;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.network.IThreadListener;
|
||||
import game.network.NetConnection;
|
||||
|
@ -489,7 +490,7 @@ public class Game implements IThreadListener, IClient {
|
|||
public void refreshResources()
|
||||
{
|
||||
this.textureManager.onReload();
|
||||
Colorizer.reload();
|
||||
ColormapLoader.reload();
|
||||
this.modelManager.onReload();
|
||||
this.renderItem.onReload();
|
||||
this.blockRenderer.onReload();
|
||||
|
@ -503,7 +504,7 @@ public class Game implements IThreadListener, IClient {
|
|||
this.textureManager = new TextureManager();
|
||||
this.textureManager.onReload();
|
||||
this.soundManager = new SoundManager(this);
|
||||
Colorizer.reload();
|
||||
ColormapLoader.reload();
|
||||
GlState.enableTexture2D();
|
||||
GlState.shadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glClearDepth(1.0D);
|
||||
|
@ -3326,4 +3327,36 @@ public class Game implements IThreadListener, IClient {
|
|||
public void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
this.renderGlobal.markBlocksForUpdate(x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) {
|
||||
this.effectRenderer.emitParticleAtEntity(entityIn, particleTypes);
|
||||
}
|
||||
|
||||
public boolean isJumping() {
|
||||
return this.jump;
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return this.sprint;
|
||||
}
|
||||
|
||||
public boolean isSneaking() {
|
||||
return this.sneak;
|
||||
}
|
||||
|
||||
public float getMoveForward() {
|
||||
return this.moveForward;
|
||||
}
|
||||
|
||||
public float getMoveStrafe() {
|
||||
return this.moveStrafe;
|
||||
}
|
||||
|
||||
public void setMoveForward(float value) {
|
||||
this.moveForward = value;
|
||||
}
|
||||
|
||||
public void setMoveStrafe(float value) {
|
||||
this.moveStrafe = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ import game.color.TextColor;
|
|||
import game.dimension.Space;
|
||||
import game.log.Log;
|
||||
import game.world.Converter;
|
||||
import game.world.Converter.SaveVersion;
|
||||
import game.world.Region;
|
||||
import game.world.Region.FolderInfo;
|
||||
import game.world.Region.SaveVersion;
|
||||
import game.world.World;
|
||||
|
||||
public class GuiConvert extends GuiList<GuiConvert.SaveInfo> implements ActButton.Callback
|
||||
|
|
|
@ -162,7 +162,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
// }
|
||||
// }
|
||||
GuiChar.this.templateButton.enabled = this.charinfo != null;
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
if(this.skinImage == null) {
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(null, this.charinfo.skin));
|
||||
}
|
||||
else {
|
||||
int[] img = new int[this.model.texWidth * this.model.texHeight];
|
||||
this.skinImage.getRGB(0, 0, this.skinImage.getWidth(), this.skinImage.getHeight(), img, 0, this.skinImage.getWidth());
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(EntityTexManager.imageToComp(img, this.model), null));
|
||||
}
|
||||
// GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
GuiChar.this.currentSkin = this.skinFile != null ? this.skinFile.getName() : this.charinfo.skin;
|
||||
GuiChar.this.waiting = false;
|
||||
}
|
||||
|
|
22
client/src/client/init/AnimationRegistry.java
Normal file
22
client/src/client/init/AnimationRegistry.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package client.init;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import client.renderer.texture.TextureTicked;
|
||||
import client.renderer.ticked.TextureFlamesFX1;
|
||||
import client.renderer.ticked.TextureFlamesFX2;
|
||||
import client.renderer.ticked.TextureLavaFX;
|
||||
import client.renderer.ticked.TextureLavaFlowFX;
|
||||
import client.renderer.ticked.TextureWaterFX;
|
||||
import client.renderer.ticked.TextureWaterFlowFX;
|
||||
|
||||
public abstract class AnimationRegistry {
|
||||
public static void registerAnimations(Map<String, Class<? extends TextureTicked>> anim) {
|
||||
anim.put("fire1", TextureFlamesFX1.class);
|
||||
anim.put("fire2", TextureFlamesFX2.class);
|
||||
anim.put("lavaflow", TextureLavaFlowFX.class);
|
||||
anim.put("lava", TextureLavaFX.class);
|
||||
anim.put("waterflow", TextureWaterFlowFX.class);
|
||||
anim.put("water", TextureWaterFX.class);
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ import game.init.Items;
|
|||
import game.init.SpeciesRegistry;
|
||||
import game.init.SpeciesRegistry.ModelType;
|
||||
|
||||
public class EntityRenderRegistry {
|
||||
public abstract class EntityRenderRegistry {
|
||||
public static void registerRenderers(Map<Class<? extends Entity>, Render<? extends Entity>> map,
|
||||
Map<ModelType, RenderNpc> models, RenderManager mgr, RenderItem ritem) {
|
||||
map.put(EntityPig.class, new RenderPig(mgr, new ModelPig()));
|
||||
|
|
|
@ -13,8 +13,18 @@ import client.gui.GuiConsole;
|
|||
import client.gui.GuiLoading;
|
||||
import client.gui.character.GuiChar;
|
||||
import client.gui.character.GuiCharacters;
|
||||
import client.gui.container.GuiBrewing;
|
||||
import client.gui.container.GuiChest;
|
||||
import client.gui.container.GuiCrafting;
|
||||
import client.gui.container.GuiDispenser;
|
||||
import client.gui.container.GuiEnchant;
|
||||
import client.gui.container.GuiFurnace;
|
||||
import client.gui.container.GuiHopper;
|
||||
import client.gui.container.GuiHorse;
|
||||
import client.gui.container.GuiMachine;
|
||||
import client.gui.container.GuiMerchant;
|
||||
import client.gui.container.GuiRepair;
|
||||
import client.gui.ingame.GuiSign;
|
||||
import client.renderer.particle.EntityPickupFX;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import game.collect.Lists;
|
||||
|
@ -40,6 +50,7 @@ import game.init.SoundEvent;
|
|||
import game.inventory.AnimalChest;
|
||||
import game.inventory.Container;
|
||||
import game.inventory.ContainerLocalMenu;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryBasic;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
|
@ -115,14 +126,17 @@ import game.packet.SPacketUpdateHealth;
|
|||
import game.packet.SPacketWorld;
|
||||
import game.potion.PotionEffect;
|
||||
import game.rng.Random;
|
||||
import game.tileentity.IInteractionObject;
|
||||
import game.tileentity.LocalBlockIntercommunication;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntityMachine;
|
||||
import game.tileentity.TileEntitySign;
|
||||
import game.village.MerchantRecipeList;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Chunk;
|
||||
import game.world.Explosion;
|
||||
import game.world.Weather;
|
||||
import game.world.World;
|
||||
import game.world.WorldClient;
|
||||
|
||||
public class ClientPlayer extends NetHandler implements IClientPlayer
|
||||
|
@ -1941,4 +1955,70 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
{
|
||||
return this.playerList.keySet();
|
||||
}
|
||||
|
||||
public void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory) {
|
||||
String s = chestInventory instanceof IInteractionObject ? ((IInteractionObject)chestInventory).getGuiID() : "container";
|
||||
|
||||
if ("chest".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiChest(inventory, chestInventory));
|
||||
}
|
||||
else if ("hopper".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiHopper(inventory, chestInventory));
|
||||
}
|
||||
else if ("furnace".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiFurnace(inventory, chestInventory));
|
||||
}
|
||||
else if ("brewing_stand".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiBrewing(inventory, chestInventory));
|
||||
}
|
||||
// else if ("beacon".equals(s))
|
||||
// {
|
||||
// this.gm.displayGuiScreen(new GuiBeacon(this.inventory, chestInventory));
|
||||
// }
|
||||
else if (!"dispenser".equals(s) && !"dropper".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiChest(inventory, chestInventory));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiDispenser(inventory, chestInventory));
|
||||
}
|
||||
}
|
||||
|
||||
public void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj) {
|
||||
String s = guiOwner.getGuiID();
|
||||
|
||||
if ("crafting_table".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiCrafting(inventory, worldObj));
|
||||
}
|
||||
else if ("enchanting_table".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiEnchant(inventory, worldObj, guiOwner));
|
||||
}
|
||||
else if ("anvil".equals(s))
|
||||
{
|
||||
this.gameController.displayGuiScreen(new GuiRepair(inventory, worldObj));
|
||||
}
|
||||
}
|
||||
|
||||
public void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory) {
|
||||
this.gameController.displayGuiScreen(new GuiHorse(inventory, horseInventory, horse));
|
||||
}
|
||||
|
||||
public void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj) {
|
||||
this.gameController.displayGuiScreen(new GuiMerchant(inventory, title, worldObj));
|
||||
}
|
||||
|
||||
public void displayGuiSign(BlockPos pos, String[] signText) {
|
||||
this.gameController.displayGuiScreen(new GuiSign(pos, signText));
|
||||
}
|
||||
|
||||
public void closeGui() {
|
||||
this.gameController.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import client.Game;
|
|||
import client.renderer.entity.RenderItem;
|
||||
import client.renderer.entity.RenderManager;
|
||||
import client.renderer.entity.RenderNpc;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import client.renderer.texture.TextureAtlasSprite;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import game.block.Block;
|
||||
|
@ -291,7 +292,7 @@ public class ItemRenderer
|
|||
float f4 = ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
|
||||
GL11.glRotatef(f4 * 70.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(f3 * -20.0F, 0.0F, 0.0F, 1.0F);
|
||||
this.gm.getTextureManager().bindTexture(clientPlayer.getLocationSkin());
|
||||
this.gm.getTextureManager().bindTexture(EntityTexManager.getSkin(clientPlayer));
|
||||
GL11.glTranslatef(-1.0F, 3.6F, 3.5F);
|
||||
GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
|
||||
|
|
|
@ -12,6 +12,7 @@ import client.renderer.layers.LayerHeldItem;
|
|||
import client.renderer.layers.LayerPowerRods;
|
||||
import client.renderer.model.ModelBiped;
|
||||
import client.renderer.model.ModelHumanoid;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.item.ItemAction;
|
||||
import game.item.ItemStack;
|
||||
|
@ -82,7 +83,7 @@ public class RenderHumanoid extends RenderNpc
|
|||
|
||||
protected void renderLayers(EntityNPC entity, float swing, float amount, float partial, float time, float dYaw, float dPitch, float scale) {
|
||||
super.renderLayers(entity, swing, amount, partial, time, dYaw, dPitch, scale);
|
||||
LayerExtra extra = entity.getExtrasLayer();
|
||||
LayerExtra extra = EntityTexManager.getLayer(entity);
|
||||
if(extra != null) {
|
||||
extra.setModel(this.getMainModel());
|
||||
// boolean bright = this.setBrightness(entity, partial, extra.shouldCombineTextures());
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import client.renderer.model.ModelBase;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.network.IPlayer;
|
||||
|
||||
|
||||
public abstract class RenderNpc extends RenderLiving<EntityNPC>
|
||||
|
@ -64,7 +65,7 @@ public abstract class RenderNpc extends RenderLiving<EntityNPC>
|
|||
TexList alpha = new TexList();
|
||||
this.getSegments(opaque, alpha);
|
||||
this.compressedSize = alpha.getSize() * 4 + opaque.getSize() * 3;
|
||||
if(this.compressedSize > EntityTexManager.MAX_SKIN_SIZE)
|
||||
if(this.compressedSize > IPlayer.MAX_SKIN_SIZE)
|
||||
throw new IllegalArgumentException("Renderer " + this.getClass() + ": Textur zu Groß (" + this.compressedSize + " Bytes)");
|
||||
this.opaqueSegments = opaque.compile();
|
||||
this.alphaSegments = alpha.compile();
|
||||
|
@ -91,7 +92,7 @@ public abstract class RenderNpc extends RenderLiving<EntityNPC>
|
|||
|
||||
protected String getEntityTexture(EntityNPC entity)
|
||||
{
|
||||
return entity.getLocationSkin();
|
||||
return EntityTexManager.getSkin(entity);
|
||||
}
|
||||
|
||||
public void renderPlayerArm(EntityNPC entity)
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import client.renderer.GlState;
|
||||
import client.renderer.entity.RenderHumanoid;
|
||||
import client.renderer.model.ModelRenderer;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.util.ExtMath;
|
||||
|
||||
|
@ -28,9 +29,9 @@ public class LayerCape implements LayerRenderer<EntityNPC>
|
|||
{
|
||||
if(/* !entitylivingbaseIn.isInvisible() && */ // entitylivingbaseIn.isWearing(ModelPart.CAPE)
|
||||
// &&
|
||||
entitylivingbaseIn.getLocationCape() != null) {
|
||||
EntityTexManager.getCape(entitylivingbaseIn) != null) {
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.renderer.bindTexture(entitylivingbaseIn.getLocationCape());
|
||||
this.renderer.bindTexture(EntityTexManager.getCape(entitylivingbaseIn));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||
if(entitylivingbaseIn.isPlayer()) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import client.renderer.blockmodel.ModelGenerator;
|
|||
import client.renderer.model.ModelBox;
|
||||
import client.renderer.model.ModelHumanoid;
|
||||
import client.renderer.model.ModelRenderer;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import game.collect.Lists;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.init.SpeciesRegistry.ModelType;
|
||||
|
@ -61,7 +62,7 @@ public class LayerExtra implements LayerRenderer<EntityNPC>
|
|||
// if (!entity.isInvisible())
|
||||
// {
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Game.getGame().getTextureManager().bindTexture(extended.getLocationSkin());
|
||||
Game.getGame().getTextureManager().bindTexture(EntityTexManager.getSkin(extended));
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (entity.isSneakingVisually())
|
||||
|
|
27
client/src/client/renderer/texture/ColormapLoader.java
Normal file
27
client/src/client/renderer/texture/ColormapLoader.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package client.renderer.texture;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import game.color.Colorizer;
|
||||
import game.util.FileUtils;
|
||||
|
||||
public abstract class ColormapLoader {
|
||||
private static final String GRASS_TEX = "textures/world/grass.png";
|
||||
private static final String FOLIAGE_TEX = "textures/world/foliage.png";
|
||||
|
||||
public static void reload() {
|
||||
BufferedImage img;
|
||||
try {
|
||||
img = TextureUtil.readImage(FileUtils.getResource(GRASS_TEX));
|
||||
img.getRGB(0, 0, 256, 256, Colorizer.getGrassMap(), 0, 256);
|
||||
}
|
||||
catch(Exception e) {
|
||||
}
|
||||
try {
|
||||
img = TextureUtil.readImage(FileUtils.getResource(FOLIAGE_TEX));
|
||||
img.getRGB(0, 0, 256, 256, Colorizer.getFoliageMap(), 0, 256);
|
||||
}
|
||||
catch(Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,8 +27,6 @@ public abstract class EntityTexManager
|
|||
public static String altTexture = null;
|
||||
public static int altLayer = -1;
|
||||
public static String altNpcLayer = null;
|
||||
|
||||
public static final int MAX_SKIN_SIZE = 65536;
|
||||
|
||||
private static final Set<Integer> USER_TEXTURES = Sets.newHashSet();
|
||||
private static final Map<Integer, LayerExtra> USER_LAYERS = Maps.newHashMap();
|
||||
|
@ -233,4 +231,16 @@ public abstract class EntityTexManager
|
|||
render.imageToComp(comp, img, model.texWidth);
|
||||
return comp;
|
||||
}
|
||||
|
||||
public static String getSkin(EntityNPC entity) {
|
||||
return getSkin(entity.isPlayer() ? entity.getId() : -1, entity.getChar(), entity.getSpecies().renderer);
|
||||
}
|
||||
|
||||
public static LayerExtra getLayer(EntityNPC entity) {
|
||||
return getLayer(entity.isPlayer() ? entity.getId() : -1, entity.getChar(), entity.getSpecies().renderer);
|
||||
}
|
||||
|
||||
public static String getCape(EntityNPC entity) {
|
||||
return !entity.getCape().isEmpty() ? EntityTexManager.getCape(entity.getCape()) : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import client.init.AnimationRegistry;
|
||||
import client.renderer.GlState;
|
||||
import game.block.Block;
|
||||
import game.collect.Lists;
|
||||
|
@ -38,6 +39,8 @@ public class TextureMap extends Texture
|
|||
this.missingImage = new TextureAtlasSprite(LOCATION_MISSING_TEXTURE);
|
||||
// RenderRegistry.registerAnimations(this);
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
Map<String, Class<? extends TextureTicked>> anim = Maps.newHashMap();
|
||||
AnimationRegistry.registerAnimations(anim);
|
||||
for(Block block : BlockRegistry.REGISTRY) {
|
||||
block.getAnimatedTextures(map);
|
||||
}
|
||||
|
@ -48,12 +51,18 @@ public class TextureMap extends Texture
|
|||
FluidRegistry.getFluidAnim(z));
|
||||
}
|
||||
for(Entry<String, Object> entry : map.entrySet()) {
|
||||
if(entry.getValue() instanceof Integer)
|
||||
if(entry.getValue() instanceof Integer) {
|
||||
this.animTextures.put(entry.getKey(), (Integer)entry.getValue());
|
||||
else
|
||||
this.tickedTextures.put(entry.getKey(), (Class<? extends TextureTicked>)entry.getValue());
|
||||
}
|
||||
else {
|
||||
Class<? extends TextureTicked> clazz = anim.get((String)entry.getValue());
|
||||
if(clazz == null)
|
||||
throw new RuntimeException("Animation '" + (String)entry.getValue() + "' existiert nicht");
|
||||
this.tickedTextures.put(entry.getKey(), clazz);
|
||||
}
|
||||
}
|
||||
map.clear();
|
||||
anim.clear();
|
||||
}
|
||||
|
||||
private void initMissingImage()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue