split client and server 6

This commit is contained in:
Sen 2025-05-07 17:40:28 +02:00
parent a6b0f110b1
commit 3e70accb76
26 changed files with 301 additions and 187 deletions

View file

@ -66,6 +66,7 @@ import client.renderer.entity.RenderItem;
import client.renderer.entity.RenderManager; import client.renderer.entity.RenderManager;
import client.renderer.particle.EffectRenderer; import client.renderer.particle.EffectRenderer;
import client.renderer.particle.EntityFirework; import client.renderer.particle.EntityFirework;
import client.renderer.texture.ColormapLoader;
import client.renderer.texture.EntityTexManager; import client.renderer.texture.EntityTexManager;
import client.renderer.texture.TextureManager; import client.renderer.texture.TextureManager;
import client.renderer.texture.TextureMap; import client.renderer.texture.TextureMap;
@ -82,7 +83,6 @@ import game.biome.Biome;
import game.block.Block; import game.block.Block;
import game.collect.Lists; import game.collect.Lists;
import game.collect.Maps; import game.collect.Maps;
import game.color.Colorizer;
import game.color.TextColor; import game.color.TextColor;
import game.entity.Entity; import game.entity.Entity;
import game.entity.animal.EntityHorse; import game.entity.animal.EntityHorse;
@ -109,6 +109,7 @@ import game.log.Log;
import game.log.LogLevel; import game.log.LogLevel;
import game.log.Message; import game.log.Message;
import game.material.Material; import game.material.Material;
import game.model.ParticleType;
import game.nbt.NBTTagCompound; import game.nbt.NBTTagCompound;
import game.network.IThreadListener; import game.network.IThreadListener;
import game.network.NetConnection; import game.network.NetConnection;
@ -489,7 +490,7 @@ public class Game implements IThreadListener, IClient {
public void refreshResources() public void refreshResources()
{ {
this.textureManager.onReload(); this.textureManager.onReload();
Colorizer.reload(); ColormapLoader.reload();
this.modelManager.onReload(); this.modelManager.onReload();
this.renderItem.onReload(); this.renderItem.onReload();
this.blockRenderer.onReload(); this.blockRenderer.onReload();
@ -503,7 +504,7 @@ public class Game implements IThreadListener, IClient {
this.textureManager = new TextureManager(); this.textureManager = new TextureManager();
this.textureManager.onReload(); this.textureManager.onReload();
this.soundManager = new SoundManager(this); this.soundManager = new SoundManager(this);
Colorizer.reload(); ColormapLoader.reload();
GlState.enableTexture2D(); GlState.enableTexture2D();
GlState.shadeModel(GL11.GL_SMOOTH); GlState.shadeModel(GL11.GL_SMOOTH);
GL11.glClearDepth(1.0D); 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) { public void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
this.renderGlobal.markBlocksForUpdate(x1, y1, z1, x2, y2, 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;
}
} }

View file

@ -17,9 +17,9 @@ import game.color.TextColor;
import game.dimension.Space; import game.dimension.Space;
import game.log.Log; import game.log.Log;
import game.world.Converter; import game.world.Converter;
import game.world.Converter.SaveVersion;
import game.world.Region; import game.world.Region;
import game.world.Region.FolderInfo; import game.world.Region.FolderInfo;
import game.world.Region.SaveVersion;
import game.world.World; import game.world.World;
public class GuiConvert extends GuiList<GuiConvert.SaveInfo> implements ActButton.Callback public class GuiConvert extends GuiList<GuiConvert.SaveInfo> implements ActButton.Callback

View file

@ -162,7 +162,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
// } // }
// } // }
GuiChar.this.templateButton.enabled = this.charinfo != null; 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.currentSkin = this.skinFile != null ? this.skinFile.getName() : this.charinfo.skin;
GuiChar.this.waiting = false; GuiChar.this.waiting = false;
} }

View 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);
}
}

View file

@ -99,7 +99,7 @@ import game.init.Items;
import game.init.SpeciesRegistry; import game.init.SpeciesRegistry;
import game.init.SpeciesRegistry.ModelType; import game.init.SpeciesRegistry.ModelType;
public class EntityRenderRegistry { public abstract class EntityRenderRegistry {
public static void registerRenderers(Map<Class<? extends Entity>, Render<? extends Entity>> map, public static void registerRenderers(Map<Class<? extends Entity>, Render<? extends Entity>> map,
Map<ModelType, RenderNpc> models, RenderManager mgr, RenderItem ritem) { Map<ModelType, RenderNpc> models, RenderManager mgr, RenderItem ritem) {
map.put(EntityPig.class, new RenderPig(mgr, new ModelPig())); map.put(EntityPig.class, new RenderPig(mgr, new ModelPig()));

View file

@ -13,8 +13,18 @@ import client.gui.GuiConsole;
import client.gui.GuiLoading; import client.gui.GuiLoading;
import client.gui.character.GuiChar; import client.gui.character.GuiChar;
import client.gui.character.GuiCharacters; 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.GuiMachine;
import client.gui.container.GuiMerchant; import client.gui.container.GuiMerchant;
import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign;
import client.renderer.particle.EntityPickupFX; import client.renderer.particle.EntityPickupFX;
import client.renderer.texture.EntityTexManager; import client.renderer.texture.EntityTexManager;
import game.collect.Lists; import game.collect.Lists;
@ -40,6 +50,7 @@ import game.init.SoundEvent;
import game.inventory.AnimalChest; import game.inventory.AnimalChest;
import game.inventory.Container; import game.inventory.Container;
import game.inventory.ContainerLocalMenu; import game.inventory.ContainerLocalMenu;
import game.inventory.IInventory;
import game.inventory.InventoryBasic; import game.inventory.InventoryBasic;
import game.inventory.InventoryPlayer; import game.inventory.InventoryPlayer;
import game.item.ItemStack; import game.item.ItemStack;
@ -115,14 +126,17 @@ import game.packet.SPacketUpdateHealth;
import game.packet.SPacketWorld; import game.packet.SPacketWorld;
import game.potion.PotionEffect; import game.potion.PotionEffect;
import game.rng.Random; import game.rng.Random;
import game.tileentity.IInteractionObject;
import game.tileentity.LocalBlockIntercommunication; import game.tileentity.LocalBlockIntercommunication;
import game.tileentity.TileEntity; import game.tileentity.TileEntity;
import game.tileentity.TileEntityMachine; import game.tileentity.TileEntityMachine;
import game.tileentity.TileEntitySign; import game.tileentity.TileEntitySign;
import game.village.MerchantRecipeList; import game.village.MerchantRecipeList;
import game.world.BlockPos;
import game.world.Chunk; import game.world.Chunk;
import game.world.Explosion; import game.world.Explosion;
import game.world.Weather; import game.world.Weather;
import game.world.World;
import game.world.WorldClient; import game.world.WorldClient;
public class ClientPlayer extends NetHandler implements IClientPlayer public class ClientPlayer extends NetHandler implements IClientPlayer
@ -1941,4 +1955,70 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
{ {
return this.playerList.keySet(); 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);
}
} }

View file

@ -11,6 +11,7 @@ import client.Game;
import client.renderer.entity.RenderItem; import client.renderer.entity.RenderItem;
import client.renderer.entity.RenderManager; import client.renderer.entity.RenderManager;
import client.renderer.entity.RenderNpc; import client.renderer.entity.RenderNpc;
import client.renderer.texture.EntityTexManager;
import client.renderer.texture.TextureAtlasSprite; import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureMap; import client.renderer.texture.TextureMap;
import game.block.Block; import game.block.Block;
@ -291,7 +292,7 @@ public class ItemRenderer
float f4 = ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI); float f4 = ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
GL11.glRotatef(f4 * 70.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(f4 * 70.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f3 * -20.0F, 0.0F, 0.0F, 1.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.glTranslatef(-1.0F, 3.6F, 3.5F);
GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);

View file

@ -12,6 +12,7 @@ import client.renderer.layers.LayerHeldItem;
import client.renderer.layers.LayerPowerRods; import client.renderer.layers.LayerPowerRods;
import client.renderer.model.ModelBiped; import client.renderer.model.ModelBiped;
import client.renderer.model.ModelHumanoid; import client.renderer.model.ModelHumanoid;
import client.renderer.texture.EntityTexManager;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.item.ItemAction; import game.item.ItemAction;
import game.item.ItemStack; 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) { 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); super.renderLayers(entity, swing, amount, partial, time, dYaw, dPitch, scale);
LayerExtra extra = entity.getExtrasLayer(); LayerExtra extra = EntityTexManager.getLayer(entity);
if(extra != null) { if(extra != null) {
extra.setModel(this.getMainModel()); extra.setModel(this.getMainModel());
// boolean bright = this.setBrightness(entity, partial, extra.shouldCombineTextures()); // boolean bright = this.setBrightness(entity, partial, extra.shouldCombineTextures());

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import client.renderer.model.ModelBase; import client.renderer.model.ModelBase;
import client.renderer.texture.EntityTexManager; import client.renderer.texture.EntityTexManager;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.network.IPlayer;
public abstract class RenderNpc extends RenderLiving<EntityNPC> public abstract class RenderNpc extends RenderLiving<EntityNPC>
@ -64,7 +65,7 @@ public abstract class RenderNpc extends RenderLiving<EntityNPC>
TexList alpha = new TexList(); TexList alpha = new TexList();
this.getSegments(opaque, alpha); this.getSegments(opaque, alpha);
this.compressedSize = alpha.getSize() * 4 + opaque.getSize() * 3; 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)"); throw new IllegalArgumentException("Renderer " + this.getClass() + ": Textur zu Groß (" + this.compressedSize + " Bytes)");
this.opaqueSegments = opaque.compile(); this.opaqueSegments = opaque.compile();
this.alphaSegments = alpha.compile(); this.alphaSegments = alpha.compile();
@ -91,7 +92,7 @@ public abstract class RenderNpc extends RenderLiving<EntityNPC>
protected String getEntityTexture(EntityNPC entity) protected String getEntityTexture(EntityNPC entity)
{ {
return entity.getLocationSkin(); return EntityTexManager.getSkin(entity);
} }
public void renderPlayerArm(EntityNPC entity) public void renderPlayerArm(EntityNPC entity)

View file

@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL11;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.entity.RenderHumanoid; import client.renderer.entity.RenderHumanoid;
import client.renderer.model.ModelRenderer; import client.renderer.model.ModelRenderer;
import client.renderer.texture.EntityTexManager;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.util.ExtMath; import game.util.ExtMath;
@ -28,9 +29,9 @@ public class LayerCape implements LayerRenderer<EntityNPC>
{ {
if(/* !entitylivingbaseIn.isInvisible() && */ // entitylivingbaseIn.isWearing(ModelPart.CAPE) if(/* !entitylivingbaseIn.isInvisible() && */ // entitylivingbaseIn.isWearing(ModelPart.CAPE)
// && // &&
entitylivingbaseIn.getLocationCape() != null) { EntityTexManager.getCape(entitylivingbaseIn) != null) {
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
this.renderer.bindTexture(entitylivingbaseIn.getLocationCape()); this.renderer.bindTexture(EntityTexManager.getCape(entitylivingbaseIn));
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F); GL11.glTranslatef(0.0F, 0.0F, 0.125F);
if(entitylivingbaseIn.isPlayer()) { if(entitylivingbaseIn.isPlayer()) {

View file

@ -10,6 +10,7 @@ import client.renderer.blockmodel.ModelGenerator;
import client.renderer.model.ModelBox; import client.renderer.model.ModelBox;
import client.renderer.model.ModelHumanoid; import client.renderer.model.ModelHumanoid;
import client.renderer.model.ModelRenderer; import client.renderer.model.ModelRenderer;
import client.renderer.texture.EntityTexManager;
import game.collect.Lists; import game.collect.Lists;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.init.SpeciesRegistry.ModelType; import game.init.SpeciesRegistry.ModelType;
@ -61,7 +62,7 @@ public class LayerExtra implements LayerRenderer<EntityNPC>
// if (!entity.isInvisible()) // if (!entity.isInvisible())
// { // {
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); 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(); GL11.glPushMatrix();
if (entity.isSneakingVisually()) if (entity.isSneakingVisually())

View 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) {
}
}
}

View file

@ -27,8 +27,6 @@ public abstract class EntityTexManager
public static String altTexture = null; public static String altTexture = null;
public static int altLayer = -1; public static int altLayer = -1;
public static String altNpcLayer = null; 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 Set<Integer> USER_TEXTURES = Sets.newHashSet();
private static final Map<Integer, LayerExtra> USER_LAYERS = Maps.newHashMap(); private static final Map<Integer, LayerExtra> USER_LAYERS = Maps.newHashMap();
@ -233,4 +231,16 @@ public abstract class EntityTexManager
render.imageToComp(comp, img, model.texWidth); render.imageToComp(comp, img, model.texWidth);
return comp; 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;
}
} }

View file

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import client.init.AnimationRegistry;
import client.renderer.GlState; import client.renderer.GlState;
import game.block.Block; import game.block.Block;
import game.collect.Lists; import game.collect.Lists;
@ -38,6 +39,8 @@ public class TextureMap extends Texture
this.missingImage = new TextureAtlasSprite(LOCATION_MISSING_TEXTURE); this.missingImage = new TextureAtlasSprite(LOCATION_MISSING_TEXTURE);
// RenderRegistry.registerAnimations(this); // RenderRegistry.registerAnimations(this);
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
Map<String, Class<? extends TextureTicked>> anim = Maps.newHashMap();
AnimationRegistry.registerAnimations(anim);
for(Block block : BlockRegistry.REGISTRY) { for(Block block : BlockRegistry.REGISTRY) {
block.getAnimatedTextures(map); block.getAnimatedTextures(map);
} }
@ -48,12 +51,18 @@ public class TextureMap extends Texture
FluidRegistry.getFluidAnim(z)); FluidRegistry.getFluidAnim(z));
} }
for(Entry<String, Object> entry : map.entrySet()) { 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()); 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(); map.clear();
anim.clear();
} }
private void initMissingImage() private void initMissingImage()

View file

@ -3,6 +3,7 @@ package game;
import game.entity.Entity; import game.entity.Entity;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.entity.types.IEntityFX; import game.entity.types.IEntityFX;
import game.model.ParticleType;
import game.nbt.NBTTagCompound; import game.nbt.NBTTagCompound;
import game.sound.Sound; import game.sound.Sound;
import game.world.BlockPos; import game.world.BlockPos;
@ -21,4 +22,13 @@ public interface IClient {
void addBlockDestroyEffects(BlockPos pos, State state); void addBlockDestroyEffects(BlockPos pos, State state);
void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress); void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress);
void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2); void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2);
void updatePlayerMoveState();
void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes);
boolean isJumping();
boolean isSprinting();
boolean isSneaking();
float getMoveForward();
float getMoveStrafe();
void setMoveForward(float value);
void setMoveStrafe(float value);
} }

View file

@ -2,8 +2,6 @@ package game.block;
import java.util.Map; import java.util.Map;
import client.renderer.ticked.TextureFlamesFX1;
import client.renderer.ticked.TextureFlamesFX2;
import game.collect.Maps; import game.collect.Maps;
import game.init.Blocks; import game.init.Blocks;
import game.init.Config; import game.init.Config;
@ -1166,7 +1164,7 @@ public class BlockFire extends Block
} }
public void getAnimatedTextures(Map<String, Object> map) { public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/fire_layer_0", TextureFlamesFX1.class); map.put("blocks/fire_layer_0", "fire1");
map.put("blocks/fire_layer_1", TextureFlamesFX2.class); map.put("blocks/fire_layer_1", "fire2");
} }
} }

View file

@ -1,10 +1,6 @@
package game.color; package game.color;
import java.awt.image.BufferedImage;
import client.renderer.texture.TextureUtil;
import game.biome.Biome; import game.biome.Biome;
import game.util.FileUtils;
import game.world.BlockPos; import game.world.BlockPos;
import game.world.IWorldAccess; import game.world.IWorldAccess;
@ -30,12 +26,18 @@ public enum Colorizer {
return biome.waterColor; return biome.waterColor;
} }
}; };
private static final String GRASS_TEX = "textures/world/grass.png";
private static final String FOLIAGE_TEX = "textures/world/foliage.png";
private static final int[] GRASS = new int[65536]; private static final int[] GRASS = new int[65536];
private static final int[] FOLIAGE = new int[65536]; private static final int[] FOLIAGE = new int[65536];
private final int color; private final int color;
public static int[] getGrassMap() {
return GRASS;
}
public static int[] getFoliageMap() {
return FOLIAGE;
}
public static int getGrassColor(double temp, double rain) { public static int getGrassColor(double temp, double rain) {
rain = rain * temp; rain = rain * temp;
@ -52,22 +54,6 @@ public enum Colorizer {
return FOLIAGE[j << 8 | i]; return FOLIAGE[j << 8 | i];
} }
public static void reload() {
BufferedImage img;
try {
img = TextureUtil.readImage(FileUtils.getResource(GRASS_TEX));
img.getRGB(0, 0, 256, 256, GRASS, 0, 256);
}
catch(Exception e) {
}
try {
img = TextureUtil.readImage(FileUtils.getResource(FOLIAGE_TEX));
img.getRGB(0, 0, 256, 256, FOLIAGE, 0, 256);
}
catch(Exception e) {
}
}
private static int getColor(IWorldAccess access, BlockPos pos, ColorResolver resolver) { private static int getColor(IWorldAccess access, BlockPos pos, ColorResolver resolver) {
int r = 0; int r = 0;
int g = 0; int g = 0;

View file

@ -114,9 +114,9 @@ public abstract class EntityHoveringNPC extends EntityNPC
public void onLivingUpdate() public void onLivingUpdate()
{ {
if(this.sendQueue != null) { if(this.sendQueue != null) {
if(this.gm.jump && this.gm.sprint && this.gm.moveForward == 0.0f && this.gm.moveStrafe == 0.0f) if(this.gm.isJumping() && this.gm.isSprinting() && this.gm.getMoveForward() == 0.0f && this.gm.getMoveStrafe() == 0.0f)
this.setHovering(true); this.setHovering(true);
if(this.isFlying() || (!this.gm.jump && this.gm.sneak && this.onGround)) if(this.isFlying() || (!this.gm.isJumping() && this.gm.isSneaking() && this.onGround))
this.setHovering(false); this.setHovering(false);
} }
if (!this.onGround && this.motionY < 0.0D && (!this.isPlayer() || (!this.isFlying() && this.isHovering() && !this.jumping))) if (!this.onGround && this.motionY < 0.0D && (!this.isPlayer() || (!this.isFlying() && this.isHovering() && !this.jumping)))

View file

@ -4,20 +4,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import client.Game; import game.IClient;
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.GuiMerchant;
import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign;
import client.renderer.layers.LayerExtra;
import client.renderer.texture.EntityTexManager;
import game.ai.AIRangedAttack; import game.ai.AIRangedAttack;
import game.ai.EntityAIAttackOnCollide; import game.ai.EntityAIAttackOnCollide;
import game.ai.EntityAIAvoidEntity; import game.ai.EntityAIAvoidEntity;
@ -200,7 +187,7 @@ public abstract class EntityNPC extends EntityLiving
public IPlayer connection; public IPlayer connection;
public IClientPlayer sendQueue; public IClientPlayer sendQueue;
protected Game gm; protected IClient gm;
public InventoryPlayer inventory; public InventoryPlayer inventory;
protected InventoryWarpChest warpChest; protected InventoryWarpChest warpChest;
@ -405,13 +392,13 @@ public abstract class EntityNPC extends EntityLiving
this.stepHeight = 0.0F; this.stepHeight = 0.0F;
} }
public final void setClientPlayer(Game gm, IClientPlayer connection) { public final void setClientPlayer(IClient gm, IClientPlayer connection) {
this.initPlayer(); this.initPlayer();
this.gm = gm; this.gm = gm;
this.sendQueue = connection; this.sendQueue = connection;
} }
public final void setOtherPlayer(Game gm) { public final void setOtherPlayer(IClient gm) {
this.initPlayer(); this.initPlayer();
this.gm = gm; this.gm = gm;
this.stepHeight = 0.0F; this.stepHeight = 0.0F;
@ -1071,11 +1058,6 @@ public abstract class EntityNPC extends EntityLiving
// { // {
// return this.getChar().startsWith("~"); // return this.getChar().startsWith("~");
// } // }
public String getLocationCape()
{
return !this.getCape().isEmpty() ? EntityTexManager.getCape(this.getCape()) : null;
}
// public boolean canRenderExtras() // public boolean canRenderExtras()
// { // {
@ -1801,7 +1783,7 @@ public abstract class EntityNPC extends EntityLiving
if (this.sendQueue != null && entityIn instanceof EntityCart) if (this.sendQueue != null && entityIn instanceof EntityCart)
{ {
this.gm.getSoundManager().playSound(new MovingSoundMinecartRiding(this, (EntityCart)entityIn)); this.gm.playSound(new MovingSoundMinecartRiding(this, (EntityCart)entityIn));
} }
} }
@ -1819,7 +1801,7 @@ public abstract class EntityNPC extends EntityLiving
if (this.isRiding()) if (this.isRiding())
{ {
this.sendQueue.addToSendQueue(new CPacketPlayer.C05PacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround)); this.sendQueue.addToSendQueue(new CPacketPlayer.C05PacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround));
this.sendQueue.addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.gm.jump, this.gm.sneak)); this.sendQueue.addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.gm.isJumping(), this.gm.isSneaking()));
} }
else else
{ {
@ -2072,7 +2054,7 @@ public abstract class EntityNPC extends EntityLiving
// this.setScreenClosed(); // this.setScreenClosed();
// this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER)); // , this.openContainer.windowId)); // this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER)); // , this.openContainer.windowId));
// this.closeScreenAndDropStack(); // this.closeScreenAndDropStack();
this.gm.displayGuiScreen(null); this.sendQueue.closeGui();
} }
else else
this.openContainer = this.inventoryContainer; this.openContainer = this.inventoryContainer;
@ -2186,7 +2168,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.openEditSign(signTile); this.connection.openEditSign(signTile);
else if(this.sendQueue != null) else if(this.sendQueue != null)
this.gm.displayGuiScreen(new GuiSign(signTile.getPos(), signTile.signText)); this.sendQueue.displayGuiSign(signTile.getPos(), signTile.signText);
} }
/** /**
@ -2214,36 +2196,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.displayGUIChest(chestInventory); this.connection.displayGUIChest(chestInventory);
else if(this.sendQueue != null) { else if(this.sendQueue != null) {
String s = chestInventory instanceof IInteractionObject ? ((IInteractionObject)chestInventory).getGuiID() : "container"; this.sendQueue.displayGUIChest(chestInventory, this.inventory);
if ("chest".equals(s))
{
this.gm.displayGuiScreen(new GuiChest(this.inventory, chestInventory));
}
else if ("hopper".equals(s))
{
this.gm.displayGuiScreen(new GuiHopper(this.inventory, chestInventory));
}
else if ("furnace".equals(s))
{
this.gm.displayGuiScreen(new GuiFurnace(this.inventory, chestInventory));
}
else if ("brewing_stand".equals(s))
{
this.gm.displayGuiScreen(new GuiBrewing(this.inventory, chestInventory));
}
// else if ("beacon".equals(s))
// {
// this.gm.displayGuiScreen(new GuiBeacon(this.inventory, chestInventory));
// }
else if (!"dispenser".equals(s) && !"dropper".equals(s))
{
this.gm.displayGuiScreen(new GuiChest(this.inventory, chestInventory));
}
else
{
this.gm.displayGuiScreen(new GuiDispenser(this.inventory, chestInventory));
}
} }
} }
@ -2252,7 +2205,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.displayGUIHorse(horse, horseInventory); this.connection.displayGUIHorse(horse, horseInventory);
else if(this.sendQueue != null) else if(this.sendQueue != null)
this.gm.displayGuiScreen(new GuiHorse(this.inventory, horseInventory, horse)); this.sendQueue.displayGuiHorse(horse, this.inventory, horseInventory);
} }
public void displayGui(IInteractionObject guiOwner) public void displayGui(IInteractionObject guiOwner)
@ -2260,20 +2213,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.displayGui(guiOwner); this.connection.displayGui(guiOwner);
else if(this.sendQueue != null) { else if(this.sendQueue != null) {
String s = guiOwner.getGuiID(); this.sendQueue.displayGui(guiOwner, this.inventory, this.worldObj);
if ("crafting_table".equals(s))
{
this.gm.displayGuiScreen(new GuiCrafting(this.inventory, this.worldObj));
}
else if ("enchanting_table".equals(s))
{
this.gm.displayGuiScreen(new GuiEnchant(this.inventory, this.worldObj, guiOwner));
}
else if ("anvil".equals(s))
{
this.gm.displayGuiScreen(new GuiRepair(this.inventory, this.worldObj));
}
} }
} }
@ -2285,7 +2225,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.onCriticalHit(entityHit); this.connection.onCriticalHit(entityHit);
else if(this.sendQueue != null) else if(this.sendQueue != null)
this.gm.effectRenderer.emitParticleAtEntity(entityHit, ParticleType.CRIT); this.gm.emitParticleAtEntity(entityHit, ParticleType.CRIT);
} }
public void onEnchantmentCritical(Entity entityHit) public void onEnchantmentCritical(Entity entityHit)
@ -2293,7 +2233,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.connection != null) if(this.connection != null)
this.connection.onEnchantmentCritical(entityHit); this.connection.onEnchantmentCritical(entityHit);
else if(this.sendQueue != null) else if(this.sendQueue != null)
this.gm.effectRenderer.emitParticleAtEntity(entityHit, ParticleType.CRIT_MAGIC); this.gm.emitParticleAtEntity(entityHit, ParticleType.CRIT_MAGIC);
} }
/** /**
@ -2301,7 +2241,7 @@ public abstract class EntityNPC extends EntityLiving
*/ */
public boolean isSneaking() public boolean isSneaking()
{ {
return this.sendQueue != null ? this.gm.sneak : super.isSneaking(); return this.sendQueue != null ? this.gm.isSneaking() : super.isSneaking();
} }
public void updateEntityActionState() public void updateEntityActionState()
@ -2316,9 +2256,9 @@ public abstract class EntityNPC extends EntityLiving
if (this.sendQueue != null && this.isCurrentViewEntity()) if (this.sendQueue != null && this.isCurrentViewEntity())
{ {
this.moveStrafe = this.gm.moveStrafe; this.moveStrafe = this.gm.getMoveStrafe();
this.moveForward = this.gm.moveForward; this.moveForward = this.gm.getMoveForward();
this.jumping = this.gm.jump; this.jumping = this.gm.isJumping();
this.prevRenderArmYaw = this.renderArmYaw; this.prevRenderArmYaw = this.renderArmYaw;
this.prevRenderArmPitch = this.renderArmPitch; this.prevRenderArmPitch = this.renderArmPitch;
this.renderArmPitch = (float)((double)this.renderArmPitch + (double)(this.rotPitch - this.renderArmPitch) * 0.5D); this.renderArmPitch = (float)((double)this.renderArmPitch + (double)(this.rotPitch - this.renderArmPitch) * 0.5D);
@ -2398,16 +2338,16 @@ public abstract class EntityNPC extends EntityLiving
// --this.portalTimer; // --this.portalTimer;
// } // }
boolean flag = this.gm.jump; boolean flag = this.gm.isJumping();
boolean flag1 = this.gm.sneak; boolean flag1 = this.gm.isSneaking();
float f = 0.8F; float f = 0.8F;
boolean flag2 = this.gm.moveForward >= f; boolean flag2 = this.gm.getMoveForward() >= f;
this.gm.updatePlayerMoveState(); this.gm.updatePlayerMoveState();
if (this.isUsingItem() && !this.isRiding()) if (this.isUsingItem() && !this.isRiding())
{ {
this.gm.moveStrafe *= 0.2F; this.gm.setMoveStrafe(this.gm.getMoveStrafe() * 0.2F);
this.gm.moveForward *= 0.2F; this.gm.setMoveForward(this.gm.getMoveForward() * 0.2F);
this.sprintToggleTimer = 0; this.sprintToggleTimer = 0;
} }
@ -2417,9 +2357,9 @@ public abstract class EntityNPC extends EntityLiving
this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D); this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D);
boolean canSprint = true; // (float)this.getFoodStats().getFoodLevel() > 6.0F || this.allowFlying; boolean canSprint = true; // (float)this.getFoodStats().getFoodLevel() > 6.0F || this.allowFlying;
if (this.onGround && !flag1 && !flag2 && this.gm.moveForward >= f && !this.isSprinting() && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS)) if (this.onGround && !flag1 && !flag2 && this.gm.getMoveForward() >= f && !this.isSprinting() && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS))
{ {
if (this.sprintToggleTimer <= 0 && !this.gm.sprint) if (this.sprintToggleTimer <= 0 && !this.gm.isSprinting())
{ {
this.sprintToggleTimer = 7; this.sprintToggleTimer = 7;
} }
@ -2429,12 +2369,12 @@ public abstract class EntityNPC extends EntityLiving
} }
} }
if (!this.isSprinting() && this.gm.moveForward >= f && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS) && this.gm.sprint) if (!this.isSprinting() && this.gm.getMoveForward() >= f && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS) && this.gm.isSprinting())
{ {
this.setSprinting(true); this.setSprinting(true);
} }
if (this.isSprinting() && (this.gm.moveForward < f || this.collidedHorizontally || !canSprint)) if (this.isSprinting() && (this.gm.getMoveForward() < f || this.collidedHorizontally || !canSprint))
{ {
this.setSprinting(false); this.setSprinting(false);
} }
@ -2449,7 +2389,7 @@ public abstract class EntityNPC extends EntityLiving
this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.START_FLYING)); this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.START_FLYING));
} }
} }
else if (!flag && this.gm.jump) else if (!flag && this.gm.isJumping())
{ {
if (this.flyToggleTimer == 0) if (this.flyToggleTimer == 0)
{ {
@ -2471,13 +2411,13 @@ public abstract class EntityNPC extends EntityLiving
if (this.isFlying() && this.isCurrentViewEntity()) if (this.isFlying() && this.isCurrentViewEntity())
{ {
if (this.gm.sneak) if (this.gm.isSneaking())
{ {
this.motionY -= (double)( this.motionY -= (double)(
this.landMovement * 0.5f * (this.canFlyFullSpeed() ? 3.0F : 1.0F)); this.landMovement * 0.5f * (this.canFlyFullSpeed() ? 3.0F : 1.0F));
} }
if (this.gm.jump) if (this.gm.isJumping())
{ {
this.motionY += (double)( this.motionY += (double)(
this.landMovement * 0.5f * (this.canFlyFullSpeed() ? 3.0F : 1.0F)); this.landMovement * 0.5f * (this.canFlyFullSpeed() ? 3.0F : 1.0F));
@ -2496,12 +2436,12 @@ public abstract class EntityNPC extends EntityLiving
} }
} }
if (flag && !this.gm.jump) if (flag && !this.gm.isJumping())
{ {
this.horseJumpPowerCounter = -10; this.horseJumpPowerCounter = -10;
this.sendHorseJump(); this.sendHorseJump();
} }
else if (!flag && this.gm.jump) else if (!flag && this.gm.isJumping())
{ {
this.horseJumpPowerCounter = 0; this.horseJumpPowerCounter = 0;
this.horseJumpPower = 0.0F; this.horseJumpPower = 0.0F;
@ -2854,7 +2794,7 @@ public abstract class EntityNPC extends EntityLiving
public void displayTradeGui(String title) public void displayTradeGui(String title)
{ {
this.gm.displayGuiScreen(new GuiMerchant(this.inventory, title, this.worldObj)); this.sendQueue.displayGuiMerchant(title, this.inventory, this.worldObj);
} }
protected boolean isCurrentViewEntity() protected boolean isCurrentViewEntity()
@ -4709,17 +4649,7 @@ public abstract class EntityNPC extends EntityLiving
public int getColor() { public int getColor() {
return this.isPlayer() ? 0xff00ff : 0x5000ad; return this.isPlayer() ? 0xff00ff : 0x5000ad;
} }
public LayerExtra getExtrasLayer()
{
return EntityTexManager.getLayer(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
}
public String getLocationSkin()
{
return EntityTexManager.getSkin(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
}
public void sendDeathMessage() { public void sendDeathMessage() {
this.sendDeathMessage(this.isPlayer(), true); this.sendDeathMessage(this.isPlayer(), true);
} }

View file

@ -1,10 +1,8 @@
package game.entity.types; package game.entity.types;
import client.renderer.particle.EntityFX;
public interface IEntityFX { public interface IEntityFX {
EntityFX multiplyVelocity(float multiplier); IEntityFX multiplyVelocity(float multiplier);
void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn); void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn);

View file

@ -1,9 +1,5 @@
package game.init; package game.init;
import client.renderer.ticked.TextureLavaFX;
import client.renderer.ticked.TextureLavaFlowFX;
import client.renderer.ticked.TextureWaterFX;
import client.renderer.ticked.TextureWaterFlowFX;
import game.block.*; import game.block.*;
import game.color.DyeColor; import game.color.DyeColor;
import game.init.FluidRegistry.LiquidType; import game.init.FluidRegistry.LiquidType;
@ -199,9 +195,9 @@ public abstract class BlockRegistry {
.setDisplay("Schwarzbruchstein").setTab(CheatTab.tabNature)); .setDisplay("Schwarzbruchstein").setTab(CheatTab.tabNature));
registerFluid(32, 33, "water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, TextureWaterFX.class, TextureWaterFlowFX.class); registerFluid(32, 33, "water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, "water", "waterflow");
registerFluid(34, 35, "lava", "Lava", false, LiquidType.LAVA, true, 15, -30, 0.0f, 2, 3); registerFluid(34, 35, "lava", "Lava", false, LiquidType.LAVA, true, 15, -30, 0.0f, 2, 3);
registerFluid(36, 37, "magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, TextureLavaFX.class, TextureLavaFlowFX.class); registerFluid(36, 37, "magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, "lava", "lavaflow");
registerFluid(38, 39, "mercury", "Quecksilber", false, LiquidType.COLD, true, 0, 40, 0.0f, 8, 4); registerFluid(38, 39, "mercury", "Quecksilber", false, LiquidType.COLD, true, 0, 40, 0.0f, 8, 4);
registerFluid(40, 41, "hydrogen", "Wasserstoff", false, LiquidType.COLD, true, 0, 50, 0.0f, 8, 4); registerFluid(40, 41, "hydrogen", "Wasserstoff", false, LiquidType.COLD, true, 0, 50, 0.0f, 8, 4);
registerFluid(42, 43, "acid", "Säure", false, LiquidType.HOT, false, 0, 5, 0.0f, 1, 1); registerFluid(42, 43, "acid", "Säure", false, LiquidType.HOT, false, 0, 5, 0.0f, 1, 1);

View file

@ -1,5 +1,8 @@
package game.network; package game.network;
import game.entity.animal.EntityHorse;
import game.inventory.IInventory;
import game.inventory.InventoryPlayer;
import game.packet.S14PacketEntity; import game.packet.S14PacketEntity;
import game.packet.S18PacketEntityTeleport; import game.packet.S18PacketEntityTeleport;
import game.packet.S19PacketEntityHeadLook; import game.packet.S19PacketEntityHeadLook;
@ -61,6 +64,9 @@ import game.packet.SPacketTimeUpdate;
import game.packet.SPacketTrades; import game.packet.SPacketTrades;
import game.packet.SPacketUpdateHealth; import game.packet.SPacketUpdateHealth;
import game.packet.SPacketWorld; import game.packet.SPacketWorld;
import game.tileentity.IInteractionObject;
import game.world.BlockPos;
import game.world.World;
public interface IClientPlayer { public interface IClientPlayer {
void addToSendQueue(Packet packet); void addToSendQueue(Packet packet);
@ -312,4 +318,10 @@ public interface IClientPlayer {
void handleDimName(SPacketDimensionName packetIn); void handleDimName(SPacketDimensionName packetIn);
void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory);
void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj);
void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory);
void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj);
void displayGuiSign(BlockPos pos, String[] signText);
void closeGui();
} }

View file

@ -44,13 +44,14 @@ public interface IPlayer {
} }
} }
public static int MAX_USER_LENGTH = 16; public static final int MAX_USER_LENGTH = 16;
public static int MAX_NICK_LENGTH = 32; public static final int MAX_NICK_LENGTH = 32;
public static int MAX_PASS_LENGTH = 64; public static final int MAX_PASS_LENGTH = 64;
public static int MAX_CMD_LENGTH = 1024; public static final int MAX_CMD_LENGTH = 1024;
public static int MAX_INFO_LENGTH = 4096; public static final int MAX_INFO_LENGTH = 4096;
public static CharValidator VALID_USER = new IPlayer.UserValidator(); public static final int MAX_SKIN_SIZE = 65536;
public static CharValidator VALID_NICK = new IPlayer.NickValidator(); public static final CharValidator VALID_USER = new IPlayer.UserValidator();
public static final CharValidator VALID_NICK = new IPlayer.NickValidator();
public static boolean isValidNick(String user) { public static boolean isValidNick(String user) {
return VALID_NICK.valid(user); return VALID_NICK.valid(user);

View file

@ -1,10 +1,7 @@
package game.packet; package game.packet;
import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import client.renderer.texture.EntityTexManager;
import game.init.SpeciesRegistry.ModelType;
import game.network.Packet; import game.network.Packet;
import game.network.PacketBuffer; import game.network.PacketBuffer;
import game.network.IPlayer; import game.network.IPlayer;
@ -16,17 +13,9 @@ public class CPacketSkin implements Packet<IPlayer> {
public CPacketSkin() { public CPacketSkin() {
} }
public CPacketSkin(BufferedImage image, String character, ModelType model) { public CPacketSkin(byte[] texture, String character) {
if(image == null) { this.texture = texture;
this.texture = null; this.character = character;
this.character = character;
}
else {
int[] img = new int[model.texWidth * model.texHeight];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), img, 0, image.getWidth());
this.texture = EntityTexManager.imageToComp(img, model);
this.character = null;
}
} }
public byte[] getCompressed() { public byte[] getCompressed() {
@ -45,8 +34,8 @@ public class CPacketSkin implements Packet<IPlayer> {
else { else {
this.texture = buf.readByteArray(); this.texture = buf.readByteArray();
this.character = null; this.character = null;
if(this.texture.length == 0 || this.texture.length > EntityTexManager.MAX_SKIN_SIZE) if(this.texture.length == 0 || this.texture.length > IPlayer.MAX_SKIN_SIZE)
this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; this.texture = new byte[IPlayer.MAX_SKIN_SIZE];
} }
} }

View file

@ -2,9 +2,9 @@ package game.packet;
import java.io.IOException; import java.io.IOException;
import client.renderer.texture.EntityTexManager;
import game.entity.Entity; import game.entity.Entity;
import game.network.IClientPlayer; import game.network.IClientPlayer;
import game.network.IPlayer;
import game.network.Packet; import game.network.Packet;
import game.network.PacketBuffer; import game.network.PacketBuffer;
import game.world.World; import game.world.World;
@ -46,8 +46,8 @@ public class SPacketSkin implements Packet<IClientPlayer>
if(this.texture.length == 0) { if(this.texture.length == 0) {
this.texture = null; this.texture = null;
} }
else if(this.texture.length > EntityTexManager.MAX_SKIN_SIZE) { else if(this.texture.length > IPlayer.MAX_SKIN_SIZE) {
this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; this.texture = new byte[IPlayer.MAX_SKIN_SIZE];
} }
} }

View file

@ -3,13 +3,13 @@ package game.packet;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import client.renderer.texture.EntityTexManager;
import game.entity.DataWatcher; import game.entity.DataWatcher;
import game.entity.npc.EntityNPC; import game.entity.npc.EntityNPC;
import game.init.EntityRegistry; import game.init.EntityRegistry;
import game.init.ItemRegistry; import game.init.ItemRegistry;
import game.item.ItemStack; import game.item.ItemStack;
import game.network.IClientPlayer; import game.network.IClientPlayer;
import game.network.IPlayer;
import game.network.Packet; import game.network.Packet;
import game.network.PacketBuffer; import game.network.PacketBuffer;
import game.util.ExtMath; import game.util.ExtMath;
@ -65,8 +65,8 @@ public class SPacketSpawnPlayer implements Packet<IClientPlayer>
if(this.texture.length == 0) { if(this.texture.length == 0) {
this.texture = null; this.texture = null;
} }
else if(this.texture.length > EntityTexManager.MAX_SKIN_SIZE) { else if(this.texture.length > IPlayer.MAX_SKIN_SIZE) {
this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; this.texture = new byte[IPlayer.MAX_SKIN_SIZE];
} }
} }