remove slot magic value for npcs
This commit is contained in:
parent
acc43e2d42
commit
e1fc81962a
59 changed files with 776 additions and 825 deletions
|
@ -882,7 +882,7 @@ public class Client implements IThreadListener {
|
|||
this.player.dropOneItem(this.ctrl());
|
||||
}
|
||||
else if(Bind.RENAME.isPressed()) {
|
||||
ItemStack stack = this.player.getCurrentEquippedItem();
|
||||
ItemStack stack = this.player.getHeldItem();
|
||||
if(stack != null)
|
||||
this.show(new GuiRename(-1, stack, null));
|
||||
}
|
||||
|
@ -1923,7 +1923,7 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
else if((this.pointed != null && this.pointed.type == HitPosition.ObjectType.ENTITY && this.pointed.entity != null) || showPlayerInfo) {
|
||||
Entity entity = showPlayerInfo ? this.player : this.pointed.entity;
|
||||
ItemStack held = entity instanceof EntityLiving && ((EntityLiving)entity).getHeldItem() != null ? ((EntityLiving)entity).getHeldItem() : null;
|
||||
ItemStack held = entity instanceof EntityNPC && ((EntityNPC)entity).getHeldItem() != null ? ((EntityNPC)entity).getHeldItem() : null;
|
||||
|
||||
return
|
||||
(showPlayerInfo ? "Charakter: " : "Schaue auf: ") + EntityRegistry.getEntityString(entity) + " (" + entity.getId() + ")" + "\n" +
|
||||
|
|
|
@ -139,6 +139,7 @@ import common.util.BlockPos;
|
|||
import common.util.Pair;
|
||||
import common.util.ParticleType;
|
||||
import common.util.BlockPos.MutableBlockPos;
|
||||
import common.util.Equipment;
|
||||
import common.village.MerchantRecipeList;
|
||||
import common.world.Explosion;
|
||||
import common.world.State;
|
||||
|
@ -1349,9 +1350,12 @@ public class ClientPlayer implements IClientPlayer
|
|||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||
Entity entity = this.world.getEntityByID(packetIn.getEntityID());
|
||||
|
||||
if (entity != null)
|
||||
if (entity instanceof EntityNPC npc)
|
||||
{
|
||||
entity.setItem(packetIn.getEquipmentSlot(), packetIn.getItemStack());
|
||||
if(packetIn.getEquipmentSlot() == 0)
|
||||
npc.setHeldItem(packetIn.getItemStack());
|
||||
else
|
||||
npc.setArmor(Equipment.ARMOR[packetIn.getEquipmentSlot() - 1], packetIn.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ import common.item.Item;
|
|||
import common.item.ItemStack;
|
||||
import common.item.WieldType;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.item.material.ItemAnimalArmor;
|
||||
import common.model.GuiPosition;
|
||||
import common.util.Facing;
|
||||
import common.util.Equipment;
|
||||
import common.util.Vec3i;
|
||||
|
||||
public class RenderItem
|
||||
|
@ -34,8 +35,8 @@ public class RenderItem
|
|||
private final ItemModelMesher mesher;
|
||||
private final TextureManager manager;
|
||||
private final LayerArmor armor = new LayerArmor(null, 12, 12) {
|
||||
public ItemStack getCurrentArmor(EntityLiving entitylivingbaseIn, int armorSlot) {
|
||||
return ((ItemArmor)RenderItem.this.stack.getItem()).armorType.getIndex() == armorSlot ? RenderItem.this.stack : null;
|
||||
public ItemStack getCurrentArmor(EntityNPC entitylivingbaseIn, Equipment slot) {
|
||||
return ((ItemArmor)RenderItem.this.stack.getItem()).getArmorType() == slot ? RenderItem.this.stack : null;
|
||||
}
|
||||
};
|
||||
private final ModelHorse horse = new ModelHorse();
|
||||
|
@ -113,17 +114,17 @@ public class RenderItem
|
|||
this.stack = stack;
|
||||
GL11.glPushMatrix();
|
||||
float offset = 0.0f;
|
||||
switch(armor.armorType) {
|
||||
case HEAD:
|
||||
switch(armor.getArmorType()) {
|
||||
case HELMET:
|
||||
offset = -0.15f;
|
||||
break;
|
||||
case BODY:
|
||||
case CHESTPLATE:
|
||||
offset = 0.45f;
|
||||
break;
|
||||
case LEGS:
|
||||
case LEGGINGS:
|
||||
offset = 1.35f;
|
||||
break;
|
||||
case FEET:
|
||||
case BOOTS:
|
||||
offset = 1.7f;
|
||||
break;
|
||||
}
|
||||
|
@ -139,7 +140,7 @@ public class RenderItem
|
|||
GL11.glPopMatrix();
|
||||
this.stack = null;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemHorseArmor horseArmor) {
|
||||
else if(stack.getItem() instanceof ItemAnimalArmor horseArmor) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.9f, 0.5f, 0.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
|
|
|
@ -2,27 +2,22 @@ package client.renderer.layers;
|
|||
|
||||
import client.renderer.entity.RendererLivingEntity;
|
||||
import client.renderer.model.ModelBiped;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class LayerArachnoidArmor extends LayerArmor
|
||||
{
|
||||
public LayerArachnoidArmor(RendererLivingEntity<?> rendererIn)
|
||||
{
|
||||
super(rendererIn, 12, 12);
|
||||
}
|
||||
public class LayerArachnoidArmor extends LayerArmor {
|
||||
public LayerArachnoidArmor(RendererLivingEntity<?> rendererIn) {
|
||||
super(rendererIn, 12, 12);
|
||||
}
|
||||
|
||||
protected void setModelPartVisible(ModelBiped model, int armorSlot)
|
||||
{
|
||||
|
||||
switch (armorSlot)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
model.setVisible(false);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
super.setModelPartVisible(model, armorSlot);
|
||||
}
|
||||
}
|
||||
protected void setModelPartVisible(ModelBiped model, Equipment slot) {
|
||||
switch(slot) {
|
||||
case CHESTPLATE:
|
||||
case HELMET:
|
||||
super.setModelPartVisible(model, slot);
|
||||
break;
|
||||
default:
|
||||
model.setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package client.renderer.layers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import client.Client;
|
||||
|
@ -7,15 +9,28 @@ import client.renderer.GlState;
|
|||
import client.renderer.entity.RendererLivingEntity;
|
||||
import client.renderer.model.ModelArmor;
|
||||
import client.renderer.model.ModelBiped;
|
||||
import common.collect.Lists;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class LayerArmor implements LayerRenderer<EntityLiving>
|
||||
public class LayerArmor implements LayerRenderer<EntityNPC>
|
||||
{
|
||||
protected static final String ENCHANTED_ITEM_GLINT_RES = "textures/glint.png";
|
||||
private static final Equipment[] SLOTS;
|
||||
|
||||
static {
|
||||
List<Equipment> list = Lists.newArrayList();
|
||||
for(Equipment tool : Equipment.values()) {
|
||||
if(tool.isArmor() && tool.isArmorRendered() && !tool.isAnimalArmor())
|
||||
list.add(tool);
|
||||
}
|
||||
SLOTS = list.toArray(new Equipment[list.size()]);
|
||||
}
|
||||
|
||||
protected ModelArmor modelLeggings;
|
||||
protected ModelArmor modelArmor;
|
||||
|
@ -35,12 +50,11 @@ public class LayerArmor implements LayerRenderer<EntityLiving>
|
|||
this.modelArmor = new ModelArmor(1.0F, arms, legs);
|
||||
}
|
||||
|
||||
public void doRenderLayer(EntityLiving entity, float limbSwing, float limbSwingAmount, float partial, float yaw, float pitch, float factor, float scale)
|
||||
public void doRenderLayer(EntityNPC entity, float limbSwing, float limbSwingAmount, float partial, float yaw, float pitch, float factor, float scale)
|
||||
{
|
||||
this.renderLayer(entity, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale, 4);
|
||||
this.renderLayer(entity, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale, 3);
|
||||
this.renderLayer(entity, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale, 2);
|
||||
this.renderLayer(entity, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale, 1);
|
||||
for(Equipment tool : SLOTS) {
|
||||
this.renderLayer(entity, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale, tool);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldCombineTextures()
|
||||
|
@ -48,23 +62,22 @@ public class LayerArmor implements LayerRenderer<EntityLiving>
|
|||
return false;
|
||||
}
|
||||
|
||||
private void renderLayer(EntityLiving entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partial, float yaw, float pitch, float factor, float scale, int armorSlot)
|
||||
private void renderLayer(EntityNPC entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partial, float yaw, float pitch, float factor, float scale, Equipment slot)
|
||||
{
|
||||
ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, armorSlot);
|
||||
ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, slot);
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemArmor itemarmor && (this.renderer == null || EnchantmentHelper.getEnchantmentLevel(Enchantment.VANITY, itemstack) <= 0))
|
||||
{
|
||||
ModelArmor t = this.getArmorModel(armorSlot);
|
||||
ModelArmor t = this.getArmorModel(slot);
|
||||
t.setModelAttributes(this.renderer != null ? this.renderer.getMainModel() : null);
|
||||
t.setLivingAnimations(entitylivingbaseIn, limbSwing, limbSwingAmount, partial);
|
||||
this.setModelPartVisible(t, armorSlot);
|
||||
boolean flag = this.isSlotForLeggings(armorSlot);
|
||||
this.setModelPartVisible(t, slot);
|
||||
boolean flag = this.isSlotForLeggings(slot);
|
||||
String tex = this.getArmorResource(itemarmor, flag, null);
|
||||
if(this.renderer != null)
|
||||
this.renderer.bindTexture(tex);
|
||||
else
|
||||
Client.CLIENT.getTextureManager().bindTexture(tex);
|
||||
|
||||
if (itemarmor.getArmorMaterial().canBeDyed())
|
||||
{
|
||||
int i = itemstack.getDyeColor();
|
||||
|
@ -79,37 +92,26 @@ public class LayerArmor implements LayerRenderer<EntityLiving>
|
|||
else
|
||||
Client.CLIENT.getTextureManager().bindTexture(overlay);
|
||||
}
|
||||
|
||||
// case CHAIN:
|
||||
// case IRON:
|
||||
// case GOLD:
|
||||
// case DIAMOND:
|
||||
if(itemarmor.getArmorMaterial().hasArmor()) {
|
||||
GlState.color(this.colorR, this.colorG, this.colorB, this.alpha);
|
||||
t.render(entitylivingbaseIn, limbSwing, limbSwingAmount, yaw, pitch, factor, scale);
|
||||
}
|
||||
|
||||
// default:
|
||||
GlState.color(this.colorR, this.colorG, this.colorB, this.alpha);
|
||||
t.render(entitylivingbaseIn, limbSwing, limbSwingAmount, yaw, pitch, factor, scale);
|
||||
if (itemstack.isItemEnchanted())
|
||||
{
|
||||
this.renderGlint(entitylivingbaseIn, t, limbSwing, limbSwingAmount, partial, yaw, pitch, factor, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getCurrentArmor(EntityLiving entitylivingbaseIn, int armorSlot)
|
||||
public ItemStack getCurrentArmor(EntityNPC entitylivingbaseIn, Equipment armorSlot)
|
||||
{
|
||||
return entitylivingbaseIn.getArmor(armorSlot - 1);
|
||||
return entitylivingbaseIn.getArmor(armorSlot);
|
||||
}
|
||||
|
||||
public ModelArmor getArmorModel(int armorSlot)
|
||||
public ModelArmor getArmorModel(Equipment armorSlot)
|
||||
{
|
||||
return this.isSlotForLeggings(armorSlot) ? this.modelLeggings : this.modelArmor;
|
||||
}
|
||||
|
||||
private boolean isSlotForLeggings(int armorSlot)
|
||||
private boolean isSlotForLeggings(Equipment armorSlot)
|
||||
{
|
||||
return armorSlot == 2;
|
||||
return armorSlot == Equipment.LEGGINGS;
|
||||
}
|
||||
|
||||
private void renderGlint(EntityLiving entitylivingbaseIn, ModelArmor modelbaseIn, float p_177183_3_, float p_177183_4_, float partialTicks, float p_177183_6_, float p_177183_7_, float p_177183_8_, float scale)
|
||||
|
@ -180,30 +182,30 @@ public class LayerArmor implements LayerRenderer<EntityLiving>
|
|||
// this.modelArmor = new ModelBiped(1.0F);
|
||||
// }
|
||||
|
||||
protected void setModelPartVisible(ModelBiped model, int armorSlot)
|
||||
protected void setModelPartVisible(ModelBiped model, Equipment slot)
|
||||
{
|
||||
model.setVisible(false);
|
||||
|
||||
switch (armorSlot)
|
||||
switch (slot)
|
||||
{
|
||||
case 1:
|
||||
case BOOTS:
|
||||
model.bipedRightLeg.showModel = true;
|
||||
model.bipedLeftLeg.showModel = true;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case LEGGINGS:
|
||||
model.bipedBody.showModel = true;
|
||||
model.bipedRightLeg.showModel = true;
|
||||
model.bipedLeftLeg.showModel = true;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case CHESTPLATE:
|
||||
model.bipedBody.showModel = true;
|
||||
model.bipedRightArm.showModel = true;
|
||||
model.bipedLeftArm.showModel = true;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case HELMET:
|
||||
model.bipedHead.showModel = true;
|
||||
model.bipedHeadwear.showModel = true;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@ import client.Client;
|
|||
import client.renderer.entity.RendererLivingEntity;
|
||||
import client.renderer.model.ModelBiped;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Items;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
|
||||
public class LayerHeldItem implements LayerRenderer<EntityLiving>
|
||||
public class LayerHeldItem implements LayerRenderer<EntityNPC>
|
||||
{
|
||||
private final RendererLivingEntity<?> livingEntityRenderer;
|
||||
private final float xshift;
|
||||
|
@ -24,7 +23,7 @@ public class LayerHeldItem implements LayerRenderer<EntityLiving>
|
|||
this.yshift = yshift * 0.0625F; // 0.4375F
|
||||
}
|
||||
|
||||
public void doRenderLayer(EntityLiving entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
|
||||
public void doRenderLayer(EntityNPC entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
|
||||
{
|
||||
ItemStack itemstack = entitylivingbaseIn.getHeldItem();
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PlayerController {
|
|||
|
||||
this.position = new BlockPos(this.position.getX(), -1, this.position.getZ());
|
||||
|
||||
ItemStack stack = this.gm.player.getCurrentEquippedItem();
|
||||
ItemStack stack = this.gm.player.getHeldItem();
|
||||
|
||||
if(stack != null) {
|
||||
stack.getItem().onBlockDestroyed(stack, world, block, pos, this.gm.player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue