diff --git a/client/src/client/Game.java b/client/src/client/Game.java index f528cb0..48ac915 100755 --- a/client/src/client/Game.java +++ b/client/src/client/Game.java @@ -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; + } } diff --git a/client/src/client/gui/GuiConvert.java b/client/src/client/gui/GuiConvert.java index e4b49e8..4097025 100755 --- a/client/src/client/gui/GuiConvert.java +++ b/client/src/client/gui/GuiConvert.java @@ -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 implements ActButton.Callback diff --git a/client/src/client/gui/character/GuiChar.java b/client/src/client/gui/character/GuiChar.java index 4ffc119..7fc0645 100755 --- a/client/src/client/gui/character/GuiChar.java +++ b/client/src/client/gui/character/GuiChar.java @@ -162,7 +162,15 @@ public class GuiChar extends GuiList // } // } 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; } diff --git a/client/src/client/init/AnimationRegistry.java b/client/src/client/init/AnimationRegistry.java new file mode 100644 index 0000000..4120fbb --- /dev/null +++ b/client/src/client/init/AnimationRegistry.java @@ -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> 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); + } +} diff --git a/client/src/client/init/EntityRenderRegistry.java b/client/src/client/init/EntityRenderRegistry.java index 535ff26..b8df0a0 100644 --- a/client/src/client/init/EntityRenderRegistry.java +++ b/client/src/client/init/EntityRenderRegistry.java @@ -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, Render> map, Map models, RenderManager mgr, RenderItem ritem) { map.put(EntityPig.class, new RenderPig(mgr, new ModelPig())); diff --git a/client/src/client/network/ClientPlayer.java b/client/src/client/network/ClientPlayer.java index 78cc391..dff2c2f 100755 --- a/client/src/client/network/ClientPlayer.java +++ b/client/src/client/network/ClientPlayer.java @@ -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); + } } diff --git a/client/src/client/renderer/ItemRenderer.java b/client/src/client/renderer/ItemRenderer.java index b5d7544..c3ac2e1 100755 --- a/client/src/client/renderer/ItemRenderer.java +++ b/client/src/client/renderer/ItemRenderer.java @@ -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); diff --git a/client/src/client/renderer/entity/RenderHumanoid.java b/client/src/client/renderer/entity/RenderHumanoid.java index 55748f0..6815f32 100755 --- a/client/src/client/renderer/entity/RenderHumanoid.java +++ b/client/src/client/renderer/entity/RenderHumanoid.java @@ -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()); diff --git a/client/src/client/renderer/entity/RenderNpc.java b/client/src/client/renderer/entity/RenderNpc.java index c443ef8..8fee9dc 100755 --- a/client/src/client/renderer/entity/RenderNpc.java +++ b/client/src/client/renderer/entity/RenderNpc.java @@ -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 @@ -64,7 +65,7 @@ public abstract class RenderNpc extends RenderLiving 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 protected String getEntityTexture(EntityNPC entity) { - return entity.getLocationSkin(); + return EntityTexManager.getSkin(entity); } public void renderPlayerArm(EntityNPC entity) diff --git a/client/src/client/renderer/layers/LayerCape.java b/client/src/client/renderer/layers/LayerCape.java index 5191980..ba3bbb9 100755 --- a/client/src/client/renderer/layers/LayerCape.java +++ b/client/src/client/renderer/layers/LayerCape.java @@ -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 { 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()) { diff --git a/client/src/client/renderer/layers/LayerExtra.java b/client/src/client/renderer/layers/LayerExtra.java index d51a79c..75c168b 100755 --- a/client/src/client/renderer/layers/LayerExtra.java +++ b/client/src/client/renderer/layers/LayerExtra.java @@ -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 // 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()) diff --git a/client/src/client/renderer/texture/ColormapLoader.java b/client/src/client/renderer/texture/ColormapLoader.java new file mode 100644 index 0000000..38c257d --- /dev/null +++ b/client/src/client/renderer/texture/ColormapLoader.java @@ -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) { + } + } +} diff --git a/client/src/client/renderer/texture/EntityTexManager.java b/client/src/client/renderer/texture/EntityTexManager.java index d2f0146..444163c 100755 --- a/client/src/client/renderer/texture/EntityTexManager.java +++ b/client/src/client/renderer/texture/EntityTexManager.java @@ -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 USER_TEXTURES = Sets.newHashSet(); private static final Map 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; + } } diff --git a/client/src/client/renderer/texture/TextureMap.java b/client/src/client/renderer/texture/TextureMap.java index 51a6936..50af03f 100755 --- a/client/src/client/renderer/texture/TextureMap.java +++ b/client/src/client/renderer/texture/TextureMap.java @@ -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 map = Maps.newHashMap(); + Map> 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 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)entry.getValue()); + } + else { + Class 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() diff --git a/java/src/game/IClient.java b/java/src/game/IClient.java index 9bec92c..3049938 100644 --- a/java/src/game/IClient.java +++ b/java/src/game/IClient.java @@ -3,6 +3,7 @@ package game; import game.entity.Entity; import game.entity.npc.EntityNPC; import game.entity.types.IEntityFX; +import game.model.ParticleType; import game.nbt.NBTTagCompound; import game.sound.Sound; import game.world.BlockPos; @@ -21,4 +22,13 @@ public interface IClient { void addBlockDestroyEffects(BlockPos pos, State state); void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress); 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); } diff --git a/java/src/game/block/BlockFire.java b/java/src/game/block/BlockFire.java index da5f8ed..3374010 100755 --- a/java/src/game/block/BlockFire.java +++ b/java/src/game/block/BlockFire.java @@ -2,8 +2,6 @@ package game.block; import java.util.Map; -import client.renderer.ticked.TextureFlamesFX1; -import client.renderer.ticked.TextureFlamesFX2; import game.collect.Maps; import game.init.Blocks; import game.init.Config; @@ -1166,7 +1164,7 @@ public class BlockFire extends Block } public void getAnimatedTextures(Map map) { - map.put("blocks/fire_layer_0", TextureFlamesFX1.class); - map.put("blocks/fire_layer_1", TextureFlamesFX2.class); + map.put("blocks/fire_layer_0", "fire1"); + map.put("blocks/fire_layer_1", "fire2"); } } diff --git a/java/src/game/color/Colorizer.java b/java/src/game/color/Colorizer.java index 0e45326..daba4cb 100755 --- a/java/src/game/color/Colorizer.java +++ b/java/src/game/color/Colorizer.java @@ -1,10 +1,6 @@ package game.color; -import java.awt.image.BufferedImage; - -import client.renderer.texture.TextureUtil; import game.biome.Biome; -import game.util.FileUtils; import game.world.BlockPos; import game.world.IWorldAccess; @@ -30,12 +26,18 @@ public enum Colorizer { 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[] FOLIAGE = new int[65536]; private final int color; + + public static int[] getGrassMap() { + return GRASS; + } + + public static int[] getFoliageMap() { + return FOLIAGE; + } public static int getGrassColor(double temp, double rain) { rain = rain * temp; @@ -52,22 +54,6 @@ public enum Colorizer { 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) { int r = 0; int g = 0; diff --git a/java/src/game/entity/npc/EntityHoveringNPC.java b/java/src/game/entity/npc/EntityHoveringNPC.java index 6a09843..c413458 100755 --- a/java/src/game/entity/npc/EntityHoveringNPC.java +++ b/java/src/game/entity/npc/EntityHoveringNPC.java @@ -114,9 +114,9 @@ public abstract class EntityHoveringNPC extends EntityNPC public void onLivingUpdate() { 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); - 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); } if (!this.onGround && this.motionY < 0.0D && (!this.isPlayer() || (!this.isFlying() && this.isHovering() && !this.jumping))) diff --git a/java/src/game/entity/npc/EntityNPC.java b/java/src/game/entity/npc/EntityNPC.java index 8ec1d52..196893c 100755 --- a/java/src/game/entity/npc/EntityNPC.java +++ b/java/src/game/entity/npc/EntityNPC.java @@ -4,20 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.function.Predicate; -import client.Game; -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.IClient; import game.ai.AIRangedAttack; import game.ai.EntityAIAttackOnCollide; import game.ai.EntityAIAvoidEntity; @@ -200,7 +187,7 @@ public abstract class EntityNPC extends EntityLiving public IPlayer connection; public IClientPlayer sendQueue; - protected Game gm; + protected IClient gm; public InventoryPlayer inventory; protected InventoryWarpChest warpChest; @@ -405,13 +392,13 @@ public abstract class EntityNPC extends EntityLiving this.stepHeight = 0.0F; } - public final void setClientPlayer(Game gm, IClientPlayer connection) { + public final void setClientPlayer(IClient gm, IClientPlayer connection) { this.initPlayer(); this.gm = gm; this.sendQueue = connection; } - public final void setOtherPlayer(Game gm) { + public final void setOtherPlayer(IClient gm) { this.initPlayer(); this.gm = gm; this.stepHeight = 0.0F; @@ -1071,11 +1058,6 @@ public abstract class EntityNPC extends EntityLiving // { // return this.getChar().startsWith("~"); // } - - public String getLocationCape() - { - return !this.getCape().isEmpty() ? EntityTexManager.getCape(this.getCape()) : null; - } // public boolean canRenderExtras() // { @@ -1801,7 +1783,7 @@ public abstract class EntityNPC extends EntityLiving 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()) { 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 { @@ -2072,7 +2054,7 @@ public abstract class EntityNPC extends EntityLiving // this.setScreenClosed(); // this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER)); // , this.openContainer.windowId)); // this.closeScreenAndDropStack(); - this.gm.displayGuiScreen(null); + this.sendQueue.closeGui(); } else this.openContainer = this.inventoryContainer; @@ -2186,7 +2168,7 @@ public abstract class EntityNPC extends EntityLiving if(this.connection != null) this.connection.openEditSign(signTile); 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) this.connection.displayGUIChest(chestInventory); else if(this.sendQueue != null) { - String s = chestInventory instanceof IInteractionObject ? ((IInteractionObject)chestInventory).getGuiID() : "container"; - - 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)); - } + this.sendQueue.displayGUIChest(chestInventory, this.inventory); } } @@ -2252,7 +2205,7 @@ public abstract class EntityNPC extends EntityLiving if(this.connection != null) this.connection.displayGUIHorse(horse, horseInventory); 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) @@ -2260,20 +2213,7 @@ public abstract class EntityNPC extends EntityLiving if(this.connection != null) this.connection.displayGui(guiOwner); else if(this.sendQueue != null) { - String s = guiOwner.getGuiID(); - - 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)); - } + this.sendQueue.displayGui(guiOwner, this.inventory, this.worldObj); } } @@ -2285,7 +2225,7 @@ public abstract class EntityNPC extends EntityLiving if(this.connection != null) this.connection.onCriticalHit(entityHit); else if(this.sendQueue != null) - this.gm.effectRenderer.emitParticleAtEntity(entityHit, ParticleType.CRIT); + this.gm.emitParticleAtEntity(entityHit, ParticleType.CRIT); } public void onEnchantmentCritical(Entity entityHit) @@ -2293,7 +2233,7 @@ public abstract class EntityNPC extends EntityLiving if(this.connection != null) this.connection.onEnchantmentCritical(entityHit); 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() { - return this.sendQueue != null ? this.gm.sneak : super.isSneaking(); + return this.sendQueue != null ? this.gm.isSneaking() : super.isSneaking(); } public void updateEntityActionState() @@ -2316,9 +2256,9 @@ public abstract class EntityNPC extends EntityLiving if (this.sendQueue != null && this.isCurrentViewEntity()) { - this.moveStrafe = this.gm.moveStrafe; - this.moveForward = this.gm.moveForward; - this.jumping = this.gm.jump; + this.moveStrafe = this.gm.getMoveStrafe(); + this.moveForward = this.gm.getMoveForward(); + this.jumping = this.gm.isJumping(); this.prevRenderArmYaw = this.renderArmYaw; this.prevRenderArmPitch = this.renderArmPitch; 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; // } - boolean flag = this.gm.jump; - boolean flag1 = this.gm.sneak; + boolean flag = this.gm.isJumping(); + boolean flag1 = this.gm.isSneaking(); float f = 0.8F; - boolean flag2 = this.gm.moveForward >= f; + boolean flag2 = this.gm.getMoveForward() >= f; this.gm.updatePlayerMoveState(); if (this.isUsingItem() && !this.isRiding()) { - this.gm.moveStrafe *= 0.2F; - this.gm.moveForward *= 0.2F; + this.gm.setMoveStrafe(this.gm.getMoveStrafe() * 0.2F); + this.gm.setMoveForward(this.gm.getMoveForward() * 0.2F); 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); 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; } @@ -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); } - if (this.isSprinting() && (this.gm.moveForward < f || this.collidedHorizontally || !canSprint)) + if (this.isSprinting() && (this.gm.getMoveForward() < f || this.collidedHorizontally || !canSprint)) { this.setSprinting(false); } @@ -2449,7 +2389,7 @@ public abstract class EntityNPC extends EntityLiving 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) { @@ -2471,13 +2411,13 @@ public abstract class EntityNPC extends EntityLiving if (this.isFlying() && this.isCurrentViewEntity()) { - if (this.gm.sneak) + if (this.gm.isSneaking()) { this.motionY -= (double)( this.landMovement * 0.5f * (this.canFlyFullSpeed() ? 3.0F : 1.0F)); } - if (this.gm.jump) + if (this.gm.isJumping()) { this.motionY += (double)( 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.sendHorseJump(); } - else if (!flag && this.gm.jump) + else if (!flag && this.gm.isJumping()) { this.horseJumpPowerCounter = 0; this.horseJumpPower = 0.0F; @@ -2854,7 +2794,7 @@ public abstract class EntityNPC extends EntityLiving 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() @@ -4709,17 +4649,7 @@ public abstract class EntityNPC extends EntityLiving public int getColor() { 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() { this.sendDeathMessage(this.isPlayer(), true); } diff --git a/java/src/game/entity/types/IEntityFX.java b/java/src/game/entity/types/IEntityFX.java index 26b274f..cf4aece 100644 --- a/java/src/game/entity/types/IEntityFX.java +++ b/java/src/game/entity/types/IEntityFX.java @@ -1,10 +1,8 @@ package game.entity.types; -import client.renderer.particle.EntityFX; - public interface IEntityFX { - EntityFX multiplyVelocity(float multiplier); + IEntityFX multiplyVelocity(float multiplier); void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn); diff --git a/java/src/game/init/BlockRegistry.java b/java/src/game/init/BlockRegistry.java index 4536a76..1008a5f 100755 --- a/java/src/game/init/BlockRegistry.java +++ b/java/src/game/init/BlockRegistry.java @@ -1,9 +1,5 @@ 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.color.DyeColor; import game.init.FluidRegistry.LiquidType; @@ -199,9 +195,9 @@ public abstract class BlockRegistry { .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(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(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); diff --git a/java/src/game/network/IClientPlayer.java b/java/src/game/network/IClientPlayer.java index 4ac9f51..4fb6331 100644 --- a/java/src/game/network/IClientPlayer.java +++ b/java/src/game/network/IClientPlayer.java @@ -1,5 +1,8 @@ package game.network; +import game.entity.animal.EntityHorse; +import game.inventory.IInventory; +import game.inventory.InventoryPlayer; import game.packet.S14PacketEntity; import game.packet.S18PacketEntityTeleport; import game.packet.S19PacketEntityHeadLook; @@ -61,6 +64,9 @@ import game.packet.SPacketTimeUpdate; import game.packet.SPacketTrades; import game.packet.SPacketUpdateHealth; import game.packet.SPacketWorld; +import game.tileentity.IInteractionObject; +import game.world.BlockPos; +import game.world.World; public interface IClientPlayer { void addToSendQueue(Packet packet); @@ -312,4 +318,10 @@ public interface IClientPlayer { 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(); } \ No newline at end of file diff --git a/java/src/game/network/IPlayer.java b/java/src/game/network/IPlayer.java index 6d06d57..2ec04ba 100644 --- a/java/src/game/network/IPlayer.java +++ b/java/src/game/network/IPlayer.java @@ -44,13 +44,14 @@ public interface IPlayer { } } - public static int MAX_USER_LENGTH = 16; - public static int MAX_NICK_LENGTH = 32; - public static int MAX_PASS_LENGTH = 64; - public static int MAX_CMD_LENGTH = 1024; - public static int MAX_INFO_LENGTH = 4096; - public static CharValidator VALID_USER = new IPlayer.UserValidator(); - public static CharValidator VALID_NICK = new IPlayer.NickValidator(); + public static final int MAX_USER_LENGTH = 16; + public static final int MAX_NICK_LENGTH = 32; + public static final int MAX_PASS_LENGTH = 64; + public static final int MAX_CMD_LENGTH = 1024; + public static final int MAX_INFO_LENGTH = 4096; + public static final int MAX_SKIN_SIZE = 65536; + public static final CharValidator VALID_USER = new IPlayer.UserValidator(); + public static final CharValidator VALID_NICK = new IPlayer.NickValidator(); public static boolean isValidNick(String user) { return VALID_NICK.valid(user); diff --git a/java/src/game/packet/CPacketSkin.java b/java/src/game/packet/CPacketSkin.java index b20c00e..180c49b 100755 --- a/java/src/game/packet/CPacketSkin.java +++ b/java/src/game/packet/CPacketSkin.java @@ -1,10 +1,7 @@ package game.packet; -import java.awt.image.BufferedImage; import java.io.IOException; -import client.renderer.texture.EntityTexManager; -import game.init.SpeciesRegistry.ModelType; import game.network.Packet; import game.network.PacketBuffer; import game.network.IPlayer; @@ -16,17 +13,9 @@ public class CPacketSkin implements Packet { public CPacketSkin() { } - public CPacketSkin(BufferedImage image, String character, ModelType model) { - if(image == null) { - this.texture = null; - 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 CPacketSkin(byte[] texture, String character) { + this.texture = texture; + this.character = character; } public byte[] getCompressed() { @@ -45,8 +34,8 @@ public class CPacketSkin implements Packet { else { this.texture = buf.readByteArray(); this.character = null; - if(this.texture.length == 0 || this.texture.length > EntityTexManager.MAX_SKIN_SIZE) - this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; + if(this.texture.length == 0 || this.texture.length > IPlayer.MAX_SKIN_SIZE) + this.texture = new byte[IPlayer.MAX_SKIN_SIZE]; } } diff --git a/java/src/game/packet/SPacketSkin.java b/java/src/game/packet/SPacketSkin.java index 512d09b..23b619f 100755 --- a/java/src/game/packet/SPacketSkin.java +++ b/java/src/game/packet/SPacketSkin.java @@ -2,9 +2,9 @@ package game.packet; import java.io.IOException; -import client.renderer.texture.EntityTexManager; import game.entity.Entity; import game.network.IClientPlayer; +import game.network.IPlayer; import game.network.Packet; import game.network.PacketBuffer; import game.world.World; @@ -46,8 +46,8 @@ public class SPacketSkin implements Packet if(this.texture.length == 0) { this.texture = null; } - else if(this.texture.length > EntityTexManager.MAX_SKIN_SIZE) { - this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; + else if(this.texture.length > IPlayer.MAX_SKIN_SIZE) { + this.texture = new byte[IPlayer.MAX_SKIN_SIZE]; } } diff --git a/java/src/game/packet/SPacketSpawnPlayer.java b/java/src/game/packet/SPacketSpawnPlayer.java index c0a9f3b..89702e6 100755 --- a/java/src/game/packet/SPacketSpawnPlayer.java +++ b/java/src/game/packet/SPacketSpawnPlayer.java @@ -3,13 +3,13 @@ package game.packet; import java.io.IOException; import java.util.List; -import client.renderer.texture.EntityTexManager; import game.entity.DataWatcher; import game.entity.npc.EntityNPC; import game.init.EntityRegistry; import game.init.ItemRegistry; import game.item.ItemStack; import game.network.IClientPlayer; +import game.network.IPlayer; import game.network.Packet; import game.network.PacketBuffer; import game.util.ExtMath; @@ -65,8 +65,8 @@ public class SPacketSpawnPlayer implements Packet if(this.texture.length == 0) { this.texture = null; } - else if(this.texture.length > EntityTexManager.MAX_SKIN_SIZE) { - this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE]; + else if(this.texture.length > IPlayer.MAX_SKIN_SIZE) { + this.texture = new byte[IPlayer.MAX_SKIN_SIZE]; } }