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);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class AIFireballAttack extends EntityAIBase
|
|||
|
||||
public void resetTask()
|
||||
{
|
||||
this.parentEntity.setItemNoUpdate(0, null);
|
||||
this.parentEntity.setItemNoUpdate(null);
|
||||
}
|
||||
|
||||
public void updateTask()
|
||||
|
@ -56,13 +56,13 @@ public class AIFireballAttack extends EntityAIBase
|
|||
if (this.attackTimer == this.delay)
|
||||
{
|
||||
world.playEffect(1007, new BlockPos(this.parentEntity), 0);
|
||||
this.parentEntity.setItemNoUpdate(0, new ItemStack(Items.orb));
|
||||
this.parentEntity.setItemNoUpdate(new ItemStack(Items.orb));
|
||||
}
|
||||
|
||||
if (this.attackTimer == this.delay * 2)
|
||||
{
|
||||
this.parentEntity.swingItem();
|
||||
this.parentEntity.setItemNoUpdate(0, null);
|
||||
this.parentEntity.setItemNoUpdate(null);
|
||||
double d1 = 1.0D;
|
||||
Vec3 vec3 = this.parentEntity.getLook(1.0F);
|
||||
double d2 = target.posX - (this.parentEntity.posX + vec3.xCoord * d1);
|
||||
|
@ -91,6 +91,6 @@ public class AIFireballAttack extends EntityAIBase
|
|||
--this.attackTimer;
|
||||
}
|
||||
|
||||
this.parentEntity.setItemNoUpdate(0, this.attackTimer > this.delay ? new ItemStack(Items.orb) : null);
|
||||
this.parentEntity.setItemNoUpdate(this.attackTimer > this.delay ? new ItemStack(Items.orb) : null);
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ public class EntityAITakePlace extends EntityAIBase
|
|||
this.entity.swingItem();
|
||||
world.setState(blockpos, state, 3);
|
||||
if(stack.decrSize())
|
||||
this.entity.setItemNoUpdate(0, null);
|
||||
this.entity.setItemNoUpdate(null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -102,7 +102,7 @@ public class EntityAITakePlace extends EntityAIBase
|
|||
if(this.entity.getHeldItem() != null)
|
||||
this.entity.getHeldItem().incrSize();
|
||||
else
|
||||
this.entity.setItemNoUpdate(0, new ItemStack(STEALABLE.get(state)));
|
||||
this.entity.setItemNoUpdate(new ItemStack(STEALABLE.get(state)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class EntityAITempt extends EntityAIBase
|
|||
{
|
||||
if(this.temptItem == null)
|
||||
return this.temptedEntity.getDistanceSqToEntity(this.temptingPlayer) >= this.distance;
|
||||
ItemStack itemstack = this.temptingPlayer.getCurrentEquippedItem();
|
||||
ItemStack itemstack = this.temptingPlayer.getHeldItem();
|
||||
return itemstack == null ? false : this.temptItem.test(itemstack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package common.attributes;
|
||||
|
||||
public enum UsageSlot {
|
||||
HAND(0), HEAD(4, 0), BODY(3, 1), LEGS(2, 2), FEET(1, 3), INVENTORY(-1);
|
||||
|
||||
private static final UsageSlot[] LOOKUP = new UsageSlot[UsageSlot.values().length];
|
||||
|
||||
private final int index;
|
||||
private final int armor;
|
||||
|
||||
static {
|
||||
for(UsageSlot slot : values()) {
|
||||
if(slot.index >= 0)
|
||||
LOOKUP[slot.index] = slot;
|
||||
}
|
||||
}
|
||||
|
||||
private UsageSlot(int index, int armor) {
|
||||
this.index = index;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
private UsageSlot(int index) {
|
||||
this(index, -1);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public int getArmorSlot() {
|
||||
return this.armor;
|
||||
}
|
||||
|
||||
public static UsageSlot getByIndex(int index) {
|
||||
return index < 0 || index >= LOOKUP.length ? null : LOOKUP[index];
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import java.util.Map.Entry;
|
|||
import java.util.function.Function;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.natural.BlockSnow;
|
||||
import common.collect.ImmutableList;
|
||||
|
@ -46,7 +45,7 @@ import common.util.BlockPos;
|
|||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.Facing;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.HitPosition;
|
||||
import common.util.Vec3;
|
||||
import common.util.HitPosition.ObjectType;
|
||||
|
@ -195,7 +194,7 @@ public class Block {
|
|||
private String display;
|
||||
private CheatTab tab;
|
||||
private SoundType sound;
|
||||
private HarvestTool miningTool;
|
||||
private Equipment miningTool;
|
||||
private Item item;
|
||||
|
||||
private static <T> Iterable<List<T>> cartesianProduct(Iterable<? extends Iterable<? extends T>> sets) {
|
||||
|
@ -425,17 +424,21 @@ public class Block {
|
|||
return this;
|
||||
}
|
||||
|
||||
public final Block setMiningTool(HarvestTool tool, int level) {
|
||||
public final Block setMiningTool(Equipment tool, int level) {
|
||||
if(tool.isArmor())
|
||||
throw new IllegalArgumentException("Typ " + tool + " darf keine Rüstung sein");
|
||||
if(!tool.isLevelled())
|
||||
throw new IllegalArgumentException("Abbauwerkzeug " + tool.getDisplay() + " muss Levels besitzen");
|
||||
throw new IllegalArgumentException("Abbauwerkzeug " + tool + " muss Levels besitzen");
|
||||
this.miningTool = tool;
|
||||
this.miningLevel = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Block setMiningTool(HarvestTool tool) {
|
||||
public final Block setMiningTool(Equipment tool) {
|
||||
if(tool.isArmor())
|
||||
throw new IllegalArgumentException("Typ " + tool + " darf keine Rüstung sein");
|
||||
if(tool.isLevelled())
|
||||
throw new IllegalArgumentException("Abbauwerkzeug " + tool.getDisplay() + " darf keine Levels besitzen");
|
||||
throw new IllegalArgumentException("Abbauwerkzeug " + tool + " darf keine Levels besitzen");
|
||||
this.miningTool = tool;
|
||||
this.miningLevel = -1;
|
||||
return this;
|
||||
|
@ -579,7 +582,7 @@ public class Block {
|
|||
return this.miningLevel;
|
||||
}
|
||||
|
||||
public final HarvestTool getMiningTool() {
|
||||
public final Equipment getMiningTool() {
|
||||
return this.miningTool;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1025,7 @@ public class Block {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot) {
|
||||
public void getModifiers(Map<Attribute, Float> map) {
|
||||
}
|
||||
|
||||
@Clientside
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package common.block;
|
||||
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
|
||||
public enum Material {
|
||||
NONE {{
|
||||
|
@ -10,13 +10,13 @@ public enum Material {
|
|||
;
|
||||
}},
|
||||
WOOD {{
|
||||
this.setBurning().setTool(HarvestTool.AXE);
|
||||
this.setBurning().setTool(Equipment.AXE);
|
||||
}},
|
||||
SOLID {{
|
||||
this.setRequiredTool(HarvestTool.PICKAXE);
|
||||
this.setRequiredTool(Equipment.PICKAXE);
|
||||
}},
|
||||
DIGGABLE {{ // can harvest with shovel
|
||||
this.setRequiredTool(HarvestTool.SHOVEL);
|
||||
this.setRequiredTool(Equipment.SHOVEL);
|
||||
}},
|
||||
TRANSLUCENT {{
|
||||
this.setTranslucent();
|
||||
|
@ -25,16 +25,16 @@ public enum Material {
|
|||
this.setBurning();
|
||||
}},
|
||||
SOFT {{ // can break faster with sword, can't connect to fences+walls
|
||||
this.setNoPushMobility().setTool(HarvestTool.AXE);
|
||||
this.setNoPushMobility().setTool(Equipment.AXE);
|
||||
}},
|
||||
PISTON {{
|
||||
this.setImmovableMobility();
|
||||
}},
|
||||
HEAVY {{
|
||||
this.setRequiredTool(HarvestTool.PICKAXE).setImmovableMobility();
|
||||
this.setRequiredTool(Equipment.PICKAXE).setImmovableMobility();
|
||||
}},
|
||||
PLANT {{ // can break faster with sword
|
||||
this.setNonSolid().setNoPushMobility().setTool(HarvestTool.AXE);
|
||||
this.setNonSolid().setNoPushMobility().setTool(Equipment.AXE);
|
||||
}},
|
||||
SMALL {{ // can be placed more easily
|
||||
this.setNonSolid().setNoPushMobility();
|
||||
|
@ -64,19 +64,19 @@ public enum Material {
|
|||
this.setLiquid(true).setReplaceable().setNoPushMobility();
|
||||
}},
|
||||
LEAVES {{ // can break faster with sword, precipitation block, special treatment in some worldgen
|
||||
this.setBurning().setTranslucent().setNoPushMobility().setTool(HarvestTool.SHEARS);
|
||||
this.setBurning().setTranslucent().setNoPushMobility().setTool(Equipment.SHEARS);
|
||||
}},
|
||||
BUSH {{ // can break faster with sword, can be replaced by small tree leaves
|
||||
this.setNonSolid().setBurning().setNoPushMobility().setReplaceable().setTool(HarvestTool.AXE);
|
||||
this.setNonSolid().setBurning().setNoPushMobility().setReplaceable().setTool(Equipment.AXE);
|
||||
}},
|
||||
FIRE {{
|
||||
this.setNonSolid().setReplaceable().setNoPushMobility();
|
||||
}},
|
||||
POWDER {{ // can harvest with shovel, precipitation block
|
||||
this.setNonSolid().setReplaceable().setRequiredTool(HarvestTool.SHOVEL).setNoPushMobility();
|
||||
this.setNonSolid().setReplaceable().setRequiredTool(Equipment.SHOVEL).setNoPushMobility();
|
||||
}},
|
||||
FLUFF {{ // can harvest with shears
|
||||
this.setPassable().setRequiredTool(HarvestTool.SWORD).setNoPushMobility();
|
||||
this.setPassable().setRequiredTool(Equipment.SWORD).setNoPushMobility();
|
||||
}};
|
||||
|
||||
private boolean solid = true;
|
||||
|
@ -91,7 +91,7 @@ public enum Material {
|
|||
private boolean requiresTool;
|
||||
// 0 - normal; 1 - can't push other blocks; 2 - can't be pushed
|
||||
private int mobility;
|
||||
private HarvestTool tool;
|
||||
private Equipment tool;
|
||||
|
||||
protected Material setTranslucent() {
|
||||
this.opaque = false;
|
||||
|
@ -124,13 +124,13 @@ public enum Material {
|
|||
return this;
|
||||
}
|
||||
|
||||
protected Material setRequiredTool(HarvestTool tool) {
|
||||
protected Material setRequiredTool(Equipment tool) {
|
||||
this.requiresTool = true;
|
||||
this.tool = tool;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Material setTool(HarvestTool tool) {
|
||||
protected Material setTool(Equipment tool) {
|
||||
this.tool = tool;
|
||||
return this;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public enum Material {
|
|||
return this.mobility;
|
||||
}
|
||||
|
||||
public HarvestTool getTool() {
|
||||
public Equipment getTool() {
|
||||
return this.tool;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.SoundType;
|
||||
|
@ -42,9 +41,9 @@ public class BlockMetalBlock extends Block {
|
|||
tooltip.add(this.metal.formatRarity());
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
|
||||
public void getModifiers(Map<Attribute, Float> map)
|
||||
{
|
||||
if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f)
|
||||
if(this.metal.radioactivity > 0.0f)
|
||||
map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f * 9.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import common.model.GuiPosition;
|
|||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class BlockDeadBush extends BlockBush
|
|||
|
||||
public void postBroken(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te)
|
||||
{
|
||||
if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS)
|
||||
if (!worldIn.client && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS)
|
||||
{
|
||||
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
|
||||
dropItem(worldIn, pos, new ItemStack(Items.deadbush));
|
||||
|
|
|
@ -19,7 +19,7 @@ import common.properties.PropertyEnum;
|
|||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Identifyable;
|
||||
import common.util.Facing.Axis;
|
||||
import common.vars.Vars;
|
||||
|
@ -170,7 +170,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
|
|||
|
||||
public void postBroken(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te)
|
||||
{
|
||||
if (worldIn.client || player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS) || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
|
||||
if (worldIn.client || player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS) || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
|
||||
{
|
||||
super.postBroken(worldIn, player, pos, state, te);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
|
|||
}
|
||||
else if (!worldIn.client)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS)
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS)
|
||||
{
|
||||
this.onHarvest(worldIn, pos, iblockstate, player);
|
||||
worldIn.setBlockToAir(pos.down());
|
||||
|
|
|
@ -21,7 +21,7 @@ import common.rng.Random;
|
|||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.vars.Vars;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
@ -280,7 +280,7 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
}
|
||||
|
||||
public void postBroken(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te) {
|
||||
if(!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS) {
|
||||
if(!worldIn.client && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS) {
|
||||
dropItem(worldIn, pos, new ItemStack(this.getItem()));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -14,7 +14,7 @@ import common.model.GuiPosition;
|
|||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Identifyable;
|
||||
import common.vars.Vars;
|
||||
import common.world.State;
|
||||
|
@ -92,7 +92,7 @@ public class BlockTallGrass extends BlockBush implements IGrowable
|
|||
|
||||
public void postBroken(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te)
|
||||
{
|
||||
if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS)
|
||||
if (!worldIn.client && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS)
|
||||
{
|
||||
dropItem(worldIn, pos, new ItemStack(this.getItem()));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import common.util.BlockPos;
|
|||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.Facing;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.vars.Vars;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.State;
|
||||
|
@ -404,7 +404,7 @@ public class BlockVine extends Block
|
|||
|
||||
public void postBroken(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te)
|
||||
{
|
||||
if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS)
|
||||
if (!worldIn.client && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS)
|
||||
{
|
||||
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
|
||||
dropItem(worldIn, pos, new ItemStack(this.getItem()));
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.SoundType;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.MetalType;
|
||||
|
@ -37,9 +36,9 @@ public class BlockMetalOre extends BlockOre {
|
|||
tooltip.add(this.metal.formatRarity());
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
|
||||
public void getModifiers(Map<Attribute, Float> map)
|
||||
{
|
||||
if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f)
|
||||
if(this.metal.radioactivity > 0.0f)
|
||||
map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f * 2.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,9 @@ public class BlockTNT extends Block
|
|||
|
||||
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (playerIn.getCurrentEquippedItem() != null)
|
||||
if (playerIn.getHeldItem() != null)
|
||||
{
|
||||
Item item = playerIn.getCurrentEquippedItem().getItem();
|
||||
Item item = playerIn.getHeldItem().getItem();
|
||||
|
||||
if (item == Items.lighter || item == Items.fireball)
|
||||
{
|
||||
|
@ -99,11 +99,11 @@ public class BlockTNT extends Block
|
|||
|
||||
if (item == Items.lighter)
|
||||
{
|
||||
playerIn.getCurrentEquippedItem().damage(1, playerIn);
|
||||
playerIn.getHeldItem().damage(1, playerIn);
|
||||
}
|
||||
else // if (!playerIn.creative)
|
||||
{
|
||||
playerIn.getCurrentEquippedItem().decrSize();
|
||||
playerIn.getHeldItem().decrSize();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -27,15 +27,15 @@ public class BlockToggleableLight extends Block {
|
|||
|
||||
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ) {
|
||||
if(!this.isOn) {
|
||||
if(player.getCurrentEquippedItem() == null)
|
||||
if(player.getHeldItem() == null)
|
||||
return super.onUse(worldIn, pos, state, player, side, hitX, hitY, hitZ);
|
||||
Item item = player.getCurrentEquippedItem().getItem();
|
||||
Item item = player.getHeldItem().getItem();
|
||||
if(item != Items.lighter && item != Items.fireball)
|
||||
return super.onUse(worldIn, pos, state, player, side, hitX, hitY, hitZ);
|
||||
if(item == Items.lighter)
|
||||
player.getCurrentEquippedItem().damage(1, player);
|
||||
player.getHeldItem().damage(1, player);
|
||||
else
|
||||
player.getCurrentEquippedItem().decrSize();
|
||||
player.getHeldItem().decrSize();
|
||||
}
|
||||
this.toggle(worldIn, pos);
|
||||
worldIn.playEffect(player, this.isOn ? 1004 : 1007, pos, 0);
|
||||
|
|
|
@ -20,7 +20,7 @@ import common.util.BlockPos;
|
|||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.Facing;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.world.IBlockAccess;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.State;
|
||||
|
@ -128,7 +128,7 @@ public class BlockTripWire extends Block
|
|||
{
|
||||
if (!worldIn.client)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS)
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS)
|
||||
{
|
||||
worldIn.setState(pos, state.withProperty(DISARMED, Boolean.valueOf(true)), 4);
|
||||
}
|
||||
|
|
|
@ -28,18 +28,18 @@ public class BlockUnlitTorch extends BlockTorch {
|
|||
}
|
||||
|
||||
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
|
||||
if(playerIn.getCurrentEquippedItem() != null) {
|
||||
Item item = playerIn.getCurrentEquippedItem().getItem();
|
||||
if(playerIn.getHeldItem() != null) {
|
||||
Item item = playerIn.getHeldItem().getItem();
|
||||
|
||||
if(item == Items.lighter || item == Items.fireball) {
|
||||
worldIn.setState(pos, this.lit.getState().withProperty(FACING, state.getValue(FACING)).withProperty(BlockLitTorch.FUEL, 7), 3);
|
||||
worldIn.playEffect(playerIn, 1007, pos, 0);
|
||||
|
||||
if(item == Items.lighter) {
|
||||
playerIn.getCurrentEquippedItem().damage(1, playerIn);
|
||||
playerIn.getHeldItem().damage(1, playerIn);
|
||||
}
|
||||
else {
|
||||
playerIn.getCurrentEquippedItem().decrSize();
|
||||
playerIn.getHeldItem().decrSize();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||
import common.collect.Maps;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
|
@ -11,7 +12,7 @@ import common.item.tool.ItemTool;
|
|||
import common.rng.Random;
|
||||
import common.util.Displayable;
|
||||
import common.util.ExtMath;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Identifyable;
|
||||
import common.vars.Vars;
|
||||
|
||||
|
@ -186,7 +187,7 @@ public enum Enchantment implements Displayable, Identifyable
|
|||
public void onUserHurt(EntityLiving user, Entity attacker, int level)
|
||||
{
|
||||
Random random = user.getRNG();
|
||||
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.THORNS, user);
|
||||
ItemStack itemstack = EnchantmentHelper.getEnchantedArmor(Enchantment.THORNS, user);
|
||||
|
||||
if ((user.worldObj.client || Vars.damageThorns) && isThornsHurting(level, random))
|
||||
{
|
||||
|
@ -230,7 +231,7 @@ public enum Enchantment implements Displayable, Identifyable
|
|||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return (stack.getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.AXE) || super.canApply(stack);
|
||||
return (stack.getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.AXE) || super.canApply(stack);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -487,7 +488,7 @@ public enum Enchantment implements Displayable, Identifyable
|
|||
}
|
||||
|
||||
public boolean canApply(ItemStack stack) {
|
||||
return (stack.getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.AXE) || super.canApply(stack);
|
||||
return (stack.getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.AXE) || super.canApply(stack);
|
||||
}
|
||||
|
||||
public void onEntityDamaged(EntityLiving user, Entity target, int level) {
|
||||
|
@ -617,7 +618,7 @@ public enum Enchantment implements Displayable, Identifyable
|
|||
|
||||
public static int getFireTimeForEntity(Entity entity, int duration)
|
||||
{
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.FIRE_PROTECTION, entity.getInventory());
|
||||
int i = entity instanceof EntityNPC npc ? EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.FIRE_PROTECTION, npc.getArmor()) : 0;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
|
@ -629,7 +630,7 @@ public enum Enchantment implements Displayable, Identifyable
|
|||
|
||||
public static double getKnockbackFactor(Entity entity, double strength)
|
||||
{
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.BLAST_PROTECTION, entity.getInventory());
|
||||
int i = entity instanceof EntityNPC npc ? EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.BLAST_PROTECTION, npc.getArmor()) : 0;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ import common.collect.Lists;
|
|||
import common.collect.Maps;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Items;
|
||||
import common.item.Item;
|
||||
|
@ -171,12 +172,12 @@ public class EnchantmentHelper
|
|||
|
||||
if (user != null)
|
||||
{
|
||||
applyEnchantmentModifierArray(ENCHANTMENT_ITERATOR_HURT, user.getInventory());
|
||||
applyEnchantmentModifierArray(ENCHANTMENT_ITERATOR_HURT, user instanceof EntityNPC npc ? npc.getArmor() : new ItemStack[0]);
|
||||
}
|
||||
|
||||
if (user != null && attacker != null) // && attacker.isPlayer())
|
||||
{
|
||||
applyEnchantmentModifier(ENCHANTMENT_ITERATOR_HURT, user.getHeldItem());
|
||||
applyEnchantmentModifier(ENCHANTMENT_ITERATOR_HURT, user instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,12 +188,12 @@ public class EnchantmentHelper
|
|||
|
||||
if (user != null)
|
||||
{
|
||||
applyEnchantmentModifierArray(ENCHANTMENT_ITERATOR_DAMAGE, user.getInventory());
|
||||
applyEnchantmentModifierArray(ENCHANTMENT_ITERATOR_DAMAGE, user instanceof EntityNPC npc ? npc.getArmor() : new ItemStack[0]);
|
||||
}
|
||||
|
||||
if (user != null) // && user.isPlayer())
|
||||
{
|
||||
applyEnchantmentModifier(ENCHANTMENT_ITERATOR_DAMAGE, user.getHeldItem());
|
||||
applyEnchantmentModifier(ENCHANTMENT_ITERATOR_DAMAGE, user instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +202,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getKnockbackModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.KNOCKBACK, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.KNOCKBACK, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,7 +210,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getFireAspectModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.FIRE_ASPECT, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.FIRE_ASPECT, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -233,7 +234,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getEfficiencyModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.EFFICIENCY, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.EFFICIENCY, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,7 +242,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static boolean getSilkTouchModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.SILK_TOUCH, player.getHeldItem()) > 0;
|
||||
return getEnchantmentLevel(Enchantment.SILK_TOUCH, player instanceof EntityNPC npc ? npc.getHeldItem() : null) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,7 +250,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getFortuneModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.FORTUNE, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.FORTUNE, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +258,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLuckOfSeaModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.LUCK_OF_THE_SEA, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LUCK_OF_THE_SEA, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,7 +266,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLureModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.LURE, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LURE, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,7 +274,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLootingModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.LOOTING, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LOOTING, player instanceof EntityNPC npc ? npc.getHeldItem() : null);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -284,15 +285,17 @@ public class EnchantmentHelper
|
|||
// return getMaxEnchantmentLevel(Enchantment.aquaAffinity.effectId, player.getInventory()) > 0;
|
||||
// }
|
||||
|
||||
public static ItemStack getEnchantedItem(Enchantment p_92099_0_, EntityLiving p_92099_1_)
|
||||
public static ItemStack getEnchantedArmor(Enchantment ench, EntityLiving entity)
|
||||
{
|
||||
for (ItemStack itemstack : p_92099_1_.getInventory())
|
||||
{
|
||||
if (itemstack != null && getEnchantmentLevel(p_92099_0_, itemstack) > 0)
|
||||
{
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
if(entity instanceof EntityNPC npc) {
|
||||
for (ItemStack itemstack : npc.getArmor())
|
||||
{
|
||||
if (itemstack != null && getEnchantmentLevel(ench, itemstack) > 0)
|
||||
{
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.attributes.UsageSlot;
|
||||
import common.item.Item;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.tool.ItemFishingRod;
|
||||
|
@ -31,17 +30,9 @@ public enum EnchantmentType
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else if (item instanceof ItemArmor)
|
||||
else if (item instanceof ItemArmor armor)
|
||||
{
|
||||
if (this == ARMOR)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemArmor armor = (ItemArmor)item;
|
||||
return armor.armorType == UsageSlot.HEAD ? this == ARMOR_HEAD : (armor.armorType == UsageSlot.LEGS ? this == ARMOR_LEGS : (armor.armorType == UsageSlot.BODY ? this == ARMOR_TORSO : (armor.armorType == UsageSlot.FEET ? this == ARMOR_FEET : false)));
|
||||
}
|
||||
return this == ARMOR || armor.getArmorType().getEnchantmentType() == this;
|
||||
}
|
||||
else if(item instanceof ItemTool tool) {
|
||||
return this == DIGGER || (tool.getToolType().isMelee() && this == WEAPON);
|
||||
|
|
|
@ -1956,21 +1956,6 @@ public abstract class Entity
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the inventory of this entity (only used in EntityNPCMP it seems)
|
||||
*/
|
||||
public ItemStack[] getInventory()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
|
||||
*/
|
||||
public void setItem(int slot, ItemStack stack)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package common.entity;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemStack;
|
||||
import common.util.Color;
|
||||
|
@ -52,7 +53,7 @@ public class EntityDamageSource extends DamageSource
|
|||
*/
|
||||
public String getDeathMessage(EntityLiving victim)
|
||||
{
|
||||
ItemStack item = this.damageSourceEntity instanceof EntityLiving ? ((EntityLiving)this.damageSourceEntity).getHeldItem() : null;
|
||||
ItemStack item = this.damageSourceEntity instanceof EntityNPC ? ((EntityNPC)this.damageSourceEntity).getHeldItem() : null;
|
||||
// String s = "death.attack." + this.damageType;
|
||||
// String s1 = s + "Item";
|
||||
return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color), item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package common.entity;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemStack;
|
||||
import common.util.Color;
|
||||
|
@ -37,7 +38,7 @@ public class EntityDamageSourceIndirect extends EntityDamageSource
|
|||
public String getDeathMessage(EntityLiving victim)
|
||||
{
|
||||
String killer = this.indirectEntity == null ? this.damageSourceEntity.getColoredName(this.color) : this.indirectEntity.getColoredName(this.color);
|
||||
ItemStack item = this.indirectEntity instanceof EntityLiving ? ((EntityLiving)this.indirectEntity).getHeldItem() : null;
|
||||
ItemStack item = this.indirectEntity instanceof EntityNPC ? ((EntityNPC)this.indirectEntity).getHeldItem() : null;
|
||||
// String s = "death.attack." + this.damageType;
|
||||
// String s1 = s + "Item";
|
||||
return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), killer, item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), killer);
|
||||
|
|
|
@ -27,6 +27,7 @@ import common.packet.SPacketSpawnObject;
|
|||
import common.packet.SPacketSpawnPlayer;
|
||||
import common.tags.TagObject;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class EntityTrackerEntry {
|
||||
public final Entity trackedEntity;
|
||||
|
@ -308,13 +309,19 @@ public class EntityTrackerEntry {
|
|||
new SPacketEntityAttach(1, this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedTo()));
|
||||
}
|
||||
|
||||
if(this.trackedEntity instanceof EntityLiving) {
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
ItemStack itemstack = ((EntityLiving)this.trackedEntity).getItem(i);
|
||||
if(this.trackedEntity instanceof EntityNPC) {
|
||||
ItemStack itemstack1 = ((EntityNPC)this.trackedEntity).getHeldItem();
|
||||
|
||||
if(itemstack1 != null) {
|
||||
playerMP.connection
|
||||
.sendPacket(new SPacketEntityEquipment(this.trackedEntity.getId(), 0, itemstack1));
|
||||
}
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
ItemStack itemstack = ((EntityNPC)this.trackedEntity).getArmor(slot);
|
||||
|
||||
if(itemstack != null) {
|
||||
playerMP.connection
|
||||
.sendPacket(new SPacketEntityEquipment(this.trackedEntity.getId(), i, itemstack));
|
||||
.sendPacket(new SPacketEntityEquipment(this.trackedEntity.getId(), slot.getIndex() + 1, itemstack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import common.inventory.IInvBasic;
|
|||
import common.inventory.InventoryBasic;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.item.material.ItemAnimalArmor;
|
||||
import common.item.spawner.ItemMobTemplate;
|
||||
import common.pathfinding.PathNavigateGround;
|
||||
import common.tags.TagObject;
|
||||
|
@ -263,10 +263,10 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
return this.getHorseWatchableBoolean(8);
|
||||
}
|
||||
|
||||
public ItemHorseArmor getHorseArmorItem()
|
||||
public ItemAnimalArmor getHorseArmorItem()
|
||||
{
|
||||
Item item = ItemRegistry.byId(this.dataWatcher.getWatchableObjectInt(22));
|
||||
return item instanceof ItemHorseArmor armor ? armor : null;
|
||||
return item instanceof ItemAnimalArmor armor ? armor : null;
|
||||
}
|
||||
|
||||
public boolean isEatingHaystack()
|
||||
|
@ -292,7 +292,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
@Serverside
|
||||
public void setHorseArmorStack(ItemStack itemStackIn)
|
||||
{
|
||||
this.dataWatcher.updateObject(22, itemStackIn != null && itemStackIn.getItem() instanceof ItemHorseArmor armor ? ItemRegistry.getId(armor) : 0);
|
||||
this.dataWatcher.updateObject(22, itemStackIn != null && itemStackIn.getItem() instanceof ItemAnimalArmor armor ? ItemRegistry.getId(armor) : 0);
|
||||
}
|
||||
|
||||
public void setBreeding(boolean breeding)
|
||||
|
@ -346,7 +346,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
*/
|
||||
public int getTotalArmorValue()
|
||||
{
|
||||
ItemHorseArmor armor = this.getHorseArmorItem();
|
||||
ItemAnimalArmor armor = this.getHorseArmorItem();
|
||||
return armor != null ? armor.getArmorValue() : 0;
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
this.texturePrefix = this.texturePrefix + "_" + i + "_";
|
||||
}
|
||||
|
||||
ItemHorseArmor i1 = this.getHorseArmorItem();
|
||||
ItemAnimalArmor i1 = this.getHorseArmorItem();
|
||||
|
||||
// if (i1 >= horseArmorTextures.length)
|
||||
// {
|
||||
|
@ -788,7 +788,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
|
||||
if (this.canWearArmor())
|
||||
{
|
||||
if (itemstack.getItem() instanceof ItemHorseArmor)
|
||||
if (itemstack.getItem() instanceof ItemAnimalArmor)
|
||||
{
|
||||
if (!this.isTame())
|
||||
{
|
||||
|
@ -1718,7 +1718,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
*/
|
||||
public static boolean isArmorItem(Item p_146085_0_)
|
||||
{
|
||||
return p_146085_0_ instanceof ItemHorseArmor;
|
||||
return p_146085_0_ instanceof ItemAnimalArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ import common.rng.Random;
|
|||
import common.tags.TagObject;
|
||||
import common.util.Clientside;
|
||||
import common.util.ExtMath;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Color;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class EntitySheep extends EntityAnimal
|
|||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemTool tool && tool.getToolType() == HarvestTool.SHEARS && !this.getSheared() && !this.isChild())
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS && !this.getSheared() && !this.isChild())
|
||||
{
|
||||
if (!this.worldObj.client)
|
||||
{
|
||||
|
|
|
@ -39,12 +39,12 @@ public class EntityCultivator extends EntityNPC {
|
|||
|
||||
public void startExecuting() {
|
||||
super.startExecuting();
|
||||
EntityCultivator.this.setItemNoUpdate(0, new ItemStack(Items.camera));
|
||||
EntityCultivator.this.setItemNoUpdate(new ItemStack(Items.camera));
|
||||
}
|
||||
|
||||
public void resetTask() {
|
||||
super.resetTask();
|
||||
EntityCultivator.this.setItemNoUpdate(0, null);
|
||||
EntityCultivator.this.setItemNoUpdate(null);
|
||||
}
|
||||
});
|
||||
this.tasks.addTask(10, new EntityAITakePlace(this));
|
||||
|
|
|
@ -35,7 +35,7 @@ public class EntityMage extends EntityNPC
|
|||
{
|
||||
this.drinking = false;
|
||||
ItemStack itemstack = this.getHeldItem();
|
||||
this.setItem(0, null);
|
||||
this.setHeldItem(null);
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemPotion potion)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public class EntityMage extends EntityNPC
|
|||
|
||||
if (i != null)
|
||||
{
|
||||
this.setItem(0, new ItemStack(i));
|
||||
this.setHeldItem(new ItemStack(i));
|
||||
this.attackTimer = this.getHeldItem().getMaxItemUseDuration();
|
||||
this.drinking = true;
|
||||
this.setSpeedMod(0.165f);
|
||||
|
@ -90,7 +90,7 @@ public class EntityMage extends EntityNPC
|
|||
if(far || this.rand.chance()) {
|
||||
EntityLiving target = this.getAttackTarget();
|
||||
if(target == null) {
|
||||
this.setItem(0, new ItemStack(Items.potion_poison));
|
||||
this.setHeldItem(new ItemStack(Items.potion_poison));
|
||||
}
|
||||
else {
|
||||
double d1 = target.posX + target.motionX - this.posX;
|
||||
|
@ -98,24 +98,24 @@ public class EntityMage extends EntityNPC
|
|||
float f = ExtMath.sqrtd(d1 * d1 + d3 * d3);
|
||||
if (f >= 8.0F && !target.hasEffect(Effect.SLOWNESS))
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_slowness));
|
||||
this.setHeldItem(new ItemStack(Items.potion_slowness));
|
||||
}
|
||||
else if (target.getHealth() >= 8 && !target.hasEffect(Effect.POISON))
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_poison));
|
||||
this.setHeldItem(new ItemStack(Items.potion_poison));
|
||||
}
|
||||
else if (f <= 3.0F && !target.hasEffect(Effect.WEAKNESS) && this.rand.floatv() < 0.25F)
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_weakness));
|
||||
this.setHeldItem(new ItemStack(Items.potion_weakness));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_damage));
|
||||
this.setHeldItem(new ItemStack(Items.potion_damage));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setItem(0, null);
|
||||
this.setHeldItem(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import common.ai.EntityAISwimming;
|
|||
import common.ai.EntityAIWander;
|
||||
import common.ai.EntityAIWatchClosest;
|
||||
import common.ai.EntityAIWatchClosest2;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.Block;
|
||||
import common.block.artificial.BlockBed;
|
||||
import common.collect.Lists;
|
||||
|
@ -87,6 +86,7 @@ import common.util.BoundingBox;
|
|||
import common.util.Clientside;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.util.Equipment;
|
||||
import common.util.ParticleType;
|
||||
import common.util.PortalType;
|
||||
import common.util.Color;
|
||||
|
@ -170,8 +170,10 @@ public abstract class EntityNPC extends EntityLiving
|
|||
private boolean fleeing;
|
||||
private boolean playing;
|
||||
protected boolean noPickup;
|
||||
private ItemStack[] equipment = new ItemStack[5];
|
||||
private final ItemStack[] prevEquipment = new ItemStack[5];
|
||||
private ItemStack heldItem;
|
||||
private ItemStack prevHeldItem;
|
||||
private ItemStack[] armor = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
private final ItemStack[] prevArmor = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
private InventoryBasic extraInventory;
|
||||
private int inLove;
|
||||
protected Alignment alignment = Alignment.NEUTRAL;
|
||||
|
@ -920,7 +922,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack pickArmor(int slot) {
|
||||
protected ItemStack pickArmor(Equipment slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1156,6 +1158,21 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
protected int applyPotionDamageCalculations(DamageSource source, int damage) {
|
||||
damage = super.applyPotionDamageCalculations(source, damage);
|
||||
if(damage > 0) {
|
||||
int k = EnchantmentHelper.getEnchantmentModifierDamage(this.getArmor(), source);
|
||||
|
||||
if (k > 20)
|
||||
{
|
||||
k = 20;
|
||||
}
|
||||
|
||||
if (k > 0 && k <= 20)
|
||||
{
|
||||
int l = 25 - k;
|
||||
float f1 = (float)damage * (float)l;
|
||||
damage = (int)(f1 / 25.0F);
|
||||
}
|
||||
}
|
||||
if(this.canUseMagic() && source.isMagicDamage())
|
||||
damage = source.getEntity() == this ? 0 : (int)((double)damage * 0.15D);
|
||||
return damage;
|
||||
|
@ -1303,61 +1320,60 @@ public abstract class EntityNPC extends EntityLiving
|
|||
ItemStack stack = itemEntity.getEntityItem();
|
||||
if(stack.getItem().getRadiation(stack) > 0.0f)
|
||||
return;
|
||||
int slot = ItemArmor.getArmorPosition(stack);
|
||||
Equipment slot = stack.getItem() instanceof ItemArmor armor ? armor.getArmorType() : null;
|
||||
|
||||
if(slot > -1) {
|
||||
boolean flag = true;
|
||||
ItemStack old = this.getItem(slot);
|
||||
boolean flag = true;
|
||||
ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot);
|
||||
|
||||
if(old != null) {
|
||||
if(slot == 0) {
|
||||
if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isMelee() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isMelee())) {
|
||||
flag = true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isMelee() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isMelee()) {
|
||||
if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) {
|
||||
flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old);
|
||||
}
|
||||
else {
|
||||
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
|
||||
}
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) {
|
||||
flag = stack.isItemEnchanted() && !old.isItemEnchanted();
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) {
|
||||
flag = true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemBow && !(old.getItem() instanceof ItemBow) && !(old.getItem() instanceof ItemTool tool && tool.getToolType().isMelee())) {
|
||||
flag = true;
|
||||
}
|
||||
else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) {
|
||||
if(old != null) {
|
||||
if(slot == null) {
|
||||
if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isMelee() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isMelee())) {
|
||||
flag = true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) {
|
||||
ItemArmor itemarmor = (ItemArmor)stack.getItem();
|
||||
ItemArmor itemarmor1 = (ItemArmor)old.getItem();
|
||||
|
||||
if(itemarmor.damageReduceAmount != itemarmor1.damageReduceAmount) {
|
||||
flag = itemarmor.damageReduceAmount > itemarmor1.damageReduceAmount;
|
||||
else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isMelee() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isMelee()) {
|
||||
if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) {
|
||||
flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old);
|
||||
}
|
||||
else {
|
||||
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
|
||||
}
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) {
|
||||
flag = stack.isItemEnchanted() && !old.isItemEnchanted();
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) {
|
||||
flag = true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemBow && !(old.getItem() instanceof ItemBow) && !(old.getItem() instanceof ItemTool tool && tool.getToolType().isMelee())) {
|
||||
flag = true;
|
||||
}
|
||||
else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) {
|
||||
flag = true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) {
|
||||
ItemArmor itemarmor = (ItemArmor)stack.getItem();
|
||||
ItemArmor itemarmor1 = (ItemArmor)old.getItem();
|
||||
|
||||
if(flag) { // && this.canPickUpItem(stack)) {
|
||||
if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) {
|
||||
this.entityDropItem(old, 0.0F);
|
||||
if(itemarmor.getArmorValue() != itemarmor1.getArmorValue()) {
|
||||
flag = itemarmor.getArmorValue() > itemarmor1.getArmorValue();
|
||||
}
|
||||
else {
|
||||
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
|
||||
}
|
||||
}
|
||||
else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(flag) { // && this.canPickUpItem(stack)) {
|
||||
if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) {
|
||||
this.entityDropItem(old, 0.0F);
|
||||
}
|
||||
|
||||
// if(stack.getItem() == Items.diamond && itemEntity.getThrower() != null) {
|
||||
// EntityNPC entityplayer = this.worldObj.getPlayer(itemEntity.getThrower());
|
||||
|
@ -1367,12 +1383,14 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// }
|
||||
// }
|
||||
|
||||
this.setItem(slot, stack);
|
||||
if(slot == null)
|
||||
this.setHeldItem(stack);
|
||||
else
|
||||
this.setArmor(slot, stack);
|
||||
// this.dropChances[slot] = 2.0F;
|
||||
// this.noDespawn = true;
|
||||
this.onItemPickup(itemEntity, 1);
|
||||
itemEntity.setDead();
|
||||
}
|
||||
this.onItemPickup(itemEntity, 1);
|
||||
itemEntity.setDead();
|
||||
}
|
||||
if(!itemEntity.dead) {
|
||||
stack = itemEntity.getEntityItem();
|
||||
|
@ -1616,26 +1634,33 @@ public abstract class EntityNPC extends EntityLiving
|
|||
private void updateNpc()
|
||||
{
|
||||
if(!this.worldObj.client) {
|
||||
for (int j = 0; j < 5; ++j)
|
||||
ItemStack itemstack2 = this.prevHeldItem;
|
||||
ItemStack itemstack21 = this.getHeldItem();
|
||||
if (!ItemStack.allEquals(itemstack21, itemstack2))
|
||||
{
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityEquipment(this.getId(), 0, itemstack21));
|
||||
this.prevHeldItem = itemstack21 == null ? null : itemstack21.copy();
|
||||
}
|
||||
for (Equipment slot : Equipment.ARMOR)
|
||||
{
|
||||
ItemStack itemstack = this.prevEquipment[j];
|
||||
ItemStack itemstack1 = this.getItem(j);
|
||||
ItemStack itemstack = this.prevArmor[slot.getIndex()];
|
||||
ItemStack itemstack1 = this.getArmor(slot);
|
||||
|
||||
if (!ItemStack.allEquals(itemstack1, itemstack))
|
||||
{
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityEquipment(this.getId(), j, itemstack1));
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityEquipment(this.getId(), slot.getIndex() + 1, itemstack1));
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.attributes.remove(itemstack.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j);
|
||||
this.attributes.remove(itemstack.getAttributeModifiers(slot), -1 - slot.getIndex());
|
||||
}
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
this.attributes.add(itemstack1.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j, itemstack1.getSize());
|
||||
this.attributes.add(itemstack1.getAttributeModifiers(slot), -1 - slot.getIndex(), itemstack1.getSize());
|
||||
}
|
||||
|
||||
this.prevEquipment[j] = itemstack1 == null ? null : itemstack1.copy();
|
||||
this.prevArmor[slot.getIndex()] = itemstack1 == null ? null : itemstack1.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2660,24 +2685,49 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
}
|
||||
|
||||
public void setItem(int slot, ItemStack stack)
|
||||
public ItemStack getHeldItem()
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.getCurrentItem() : this.heldItem;
|
||||
}
|
||||
|
||||
public ItemStack[] getArmor()
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.armorInventory : this.armor;
|
||||
}
|
||||
|
||||
public ItemStack getArmor(Equipment slot)
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.armorInventory[slot.getIndex()] : this.armor[slot.getIndex()];
|
||||
}
|
||||
|
||||
public void setHeldItem(ItemStack stack)
|
||||
{
|
||||
if(this.slave && this.client == null) {
|
||||
if (slot == 0)
|
||||
this.inventory.mainInventory[this.inventory.currentItem] = stack;
|
||||
else
|
||||
this.inventory.armorInventory[slot - 1] = stack;
|
||||
this.inventory.mainInventory[this.inventory.currentItem] = stack;
|
||||
}
|
||||
else if(this.isPlayer()) {
|
||||
this.inventory.armorInventory[slot] = stack;
|
||||
}
|
||||
else {
|
||||
this.setItemNoUpdate(slot, stack);
|
||||
if(!this.worldObj.client && slot == 0)
|
||||
else if(!this.isPlayer()) {
|
||||
this.heldItem = stack;
|
||||
if(!this.worldObj.client)
|
||||
this.setCombatTask();
|
||||
}
|
||||
}
|
||||
|
||||
public void setArmor(Equipment slot, ItemStack stack)
|
||||
{
|
||||
if(this.isPlayer()) {
|
||||
this.inventory.armorInventory[slot.getIndex()] = stack;
|
||||
}
|
||||
else {
|
||||
this.armor[slot.getIndex()] = stack;
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemNoUpdate(ItemStack stack)
|
||||
{
|
||||
if(!this.isPlayer())
|
||||
this.heldItem = stack;
|
||||
}
|
||||
|
||||
// END OTHER
|
||||
|
||||
|
||||
|
@ -3222,13 +3272,18 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// this.setCanPickUpLoot(tagCompund.getBoolean("CanPickUpLoot"));
|
||||
// }
|
||||
|
||||
if(tagCompund.hasList("Equipment")) {
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Equipment");
|
||||
|
||||
for(int i = 0; i < this.equipment.length; ++i) {
|
||||
this.equipment[i] = ItemStack.readFromTag(nbttaglist.get(i));
|
||||
if(!this.isPlayer()) {
|
||||
if(tagCompund.hasObject("HeldItem")) {
|
||||
this.heldItem = ItemStack.readFromTag(tagCompund.getObject("HeldItem"));
|
||||
}
|
||||
}
|
||||
if(tagCompund.hasList("Armor")) {
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Armor");
|
||||
|
||||
for(int i = 0; i < this.armor.length; ++i) {
|
||||
this.armor[i] = i < nbttaglist.size() ? ItemStack.readFromTag(nbttaglist.get(i)) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// this.setSpecies(tagCompund.getString("Species"));
|
||||
this.setChar(tagCompund.getString("Char"));
|
||||
this.isWilling = tagCompund.getBool("Willing");
|
||||
|
@ -3257,16 +3312,18 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.setNpcClass(type);
|
||||
this.setHeight(tagCompund.hasFloat("Height") ? tagCompund.getFloat("Height") : this.getBaseSize());
|
||||
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Items");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.readFromTag(nbttaglist.get(i));
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.extraInventory.addStack(itemstack);
|
||||
}
|
||||
if(!this.isPlayer()) {
|
||||
List<TagObject> nbttaglist = tagCompund.getList("Items");
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.readFromTag(nbttaglist.get(i));
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.extraInventory.addStack(itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tagCompund.hasList("Offers")) {
|
||||
|
@ -3356,19 +3413,27 @@ public abstract class EntityNPC extends EntityLiving
|
|||
super.writeEntity(tagCompound);
|
||||
|
||||
// tagCompound.setBoolean("CanPickUpLoot", this.canPickUpLoot());
|
||||
List<TagObject> nbttaglist0 = Lists.newArrayList();
|
||||
|
||||
for(int i = 0; i < this.equipment.length; ++i) {
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
|
||||
if(this.equipment[i] != null) {
|
||||
this.equipment[i].writeTags(nbttagcompound);
|
||||
if(!this.isPlayer()) {
|
||||
TagObject held = new TagObject();
|
||||
if(this.heldItem != null) {
|
||||
this.heldItem.writeTags(held);
|
||||
}
|
||||
tagCompound.setObject("HeldItem", held);
|
||||
|
||||
List<TagObject> armor = Lists.newArrayList();
|
||||
|
||||
for(int i = 0; i < this.armor.length; ++i) {
|
||||
TagObject item = new TagObject();
|
||||
|
||||
if(this.armor[i] != null) {
|
||||
this.armor[i].writeTags(item);
|
||||
}
|
||||
|
||||
armor.add(item);
|
||||
}
|
||||
|
||||
nbttaglist0.add(nbttagcompound);
|
||||
}
|
||||
|
||||
tagCompound.setList("Equipment", nbttaglist0);
|
||||
|
||||
tagCompound.setList("Armor", armor);
|
||||
}
|
||||
// tagCompound.setString("Species", this.getSpecies());
|
||||
tagCompound.setString("Char", this.getChar());
|
||||
tagCompound.setBool("Willing", this.isWilling);
|
||||
|
@ -3382,19 +3447,21 @@ public abstract class EntityNPC extends EntityLiving
|
|||
if(type != null)
|
||||
tagCompound.setString("ClassType", this.species.classnames.inverse().get(type));
|
||||
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.extraInventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = this.extraInventory.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
nbttaglist.add(itemstack.writeTags(new TagObject()));
|
||||
}
|
||||
if(!this.isPlayer()) {
|
||||
List<TagObject> nbttaglist = Lists.newArrayList();
|
||||
|
||||
for (int i = 0; i < this.extraInventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = this.extraInventory.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
nbttaglist.add(itemstack.writeTags(new TagObject()));
|
||||
}
|
||||
}
|
||||
|
||||
tagCompound.setList("Items", nbttaglist);
|
||||
}
|
||||
|
||||
tagCompound.setList("Items", nbttaglist);
|
||||
if(this.trades != null)
|
||||
tagCompound.setList("Offers", this.trades.toTags());
|
||||
tagCompound.setInt("healTimer", this.healTimer);
|
||||
|
@ -3465,12 +3532,22 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.inventory.damageArmor(p_70675_1_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
|
||||
*/
|
||||
public int getTotalArmorValue()
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.getTotalArmorValue() : super.getTotalArmorValue();
|
||||
if(this.isPlayer())
|
||||
return this.inventory.getTotalArmorValue();
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack itemstack : this.armor)
|
||||
{
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemArmor)
|
||||
{
|
||||
int j = ((ItemArmor)itemstack.getItem()).getArmorValue();
|
||||
i += j;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public boolean interactWith(Entity targetEntity)
|
||||
|
@ -3486,7 +3563,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
ItemStack itemstack = this.getCurrentEquippedItem();
|
||||
ItemStack itemstack = this.getHeldItem();
|
||||
ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;
|
||||
|
||||
if (!targetEntity.interactFirst(this))
|
||||
|
@ -3513,7 +3590,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
else
|
||||
{
|
||||
if (itemstack != null && itemstack == this.getCurrentEquippedItem())
|
||||
if (itemstack != null && itemstack == this.getHeldItem())
|
||||
{
|
||||
if (itemstack.isEmpty()) // && !this.creative)
|
||||
{
|
||||
|
@ -3530,14 +3607,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently being used item by the player.
|
||||
*/
|
||||
public ItemStack getCurrentEquippedItem()
|
||||
{
|
||||
return this.inventory.getCurrentItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the currently equipped item from the player's inventory.
|
||||
*/
|
||||
|
@ -3632,7 +3701,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
|
||||
EnchantmentHelper.applyArthropodEnchantments(this, targetEntity);
|
||||
ItemStack itemstack = this.getCurrentEquippedItem();
|
||||
ItemStack itemstack = this.getHeldItem();
|
||||
Entity entity = targetEntity;
|
||||
|
||||
if (targetEntity instanceof EntityDragonPart)
|
||||
|
@ -3915,11 +3984,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
super.setInWeb();
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getArmor(int slot)
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.armorItemInSlot(slot) : this.equipment[slot + 1];
|
||||
}
|
||||
|
||||
public void setExperience(int points) {
|
||||
this.setXPStats(0.0f, 0, 0);
|
||||
|
@ -4015,31 +4079,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.warpChest = warpChest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0: Tool in Hand; 1-4: Armor
|
||||
*/
|
||||
public ItemStack getItem(int slot)
|
||||
{
|
||||
return this.isPlayer() ? (slot == 0 ? this.inventory.getCurrentItem() : this.inventory.armorInventory[slot - 1]) : this.equipment[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item that this EntityLiving is holding, if any.
|
||||
*/
|
||||
public ItemStack getHeldItem()
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.getCurrentItem() : this.equipment[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the inventory of this entity (only used in EntityNPCMP it seems)
|
||||
*/
|
||||
public ItemStack[] getInventory()
|
||||
{
|
||||
return this.isPlayer() ? this.inventory.armorInventory : this.equipment;
|
||||
}
|
||||
|
||||
public boolean isPushedByWater()
|
||||
{
|
||||
return !this.isPlayer() || !this.flying;
|
||||
|
@ -4101,7 +4140,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public boolean canOpen(String code)
|
||||
{
|
||||
ItemStack stack = this.getCurrentEquippedItem();
|
||||
ItemStack stack = this.getHeldItem();
|
||||
return stack != null && stack.getItem() instanceof ItemKey &&
|
||||
stack.hasDisplayName() && stack.getDisplayName().equals(code);
|
||||
}
|
||||
|
@ -4193,17 +4232,17 @@ public abstract class EntityNPC extends EntityLiving
|
|||
if(info.items != null) {
|
||||
for(ItemStack stack : info.items) {
|
||||
if(stack.getItem() instanceof ItemArmor)
|
||||
this.setItem(((ItemArmor)stack.getItem()).armorType.getIndex(), stack);
|
||||
this.setArmor(((ItemArmor)stack.getItem()).getArmorType(), stack);
|
||||
else if(stack.getItem().getWieldType() != null)
|
||||
this.setItem(0, stack);
|
||||
this.setHeldItem(stack);
|
||||
else
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setItem(0, this.pickItem());
|
||||
for(int z = 0; z < 4; z++) {
|
||||
this.setItem(z + 1, this.pickArmor(z));
|
||||
this.setHeldItem(this.pickItem());
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
this.setArmor(slot, this.pickArmor(slot));
|
||||
}
|
||||
int items = this.pickItemAmount();
|
||||
ItemStack stack;
|
||||
|
@ -4307,9 +4346,14 @@ public abstract class EntityNPC extends EntityLiving
|
|||
{
|
||||
if(this.isPlayer())
|
||||
return;
|
||||
for (int i = 0; i < this.getInventory().length; ++i)
|
||||
ItemStack itemstack1 = this.getHeldItem();
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
ItemStack itemstack = this.getItem(i);
|
||||
this.entityDropItem(itemstack1, 0.0F);
|
||||
}
|
||||
for (Equipment slot : Equipment.ARMOR)
|
||||
{
|
||||
ItemStack itemstack = this.getArmor(slot);
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.entityDropItem(itemstack, 0.0F);
|
||||
|
@ -4351,12 +4395,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return entity;
|
||||
}
|
||||
|
||||
public void setItemNoUpdate(int slot, ItemStack stack)
|
||||
{
|
||||
if(!this.isPlayer())
|
||||
this.equipment[slot] = stack;
|
||||
}
|
||||
|
||||
public void setCombatTask()
|
||||
{
|
||||
if(!this.isPlayer()) {
|
||||
|
|
|
@ -214,7 +214,7 @@ public class EntityHook extends Entity implements IObjectData
|
|||
{
|
||||
if (!this.worldObj.client)
|
||||
{
|
||||
ItemStack itemstack = this.angler.getCurrentEquippedItem();
|
||||
ItemStack itemstack = this.angler.getHeldItem();
|
||||
|
||||
if (this.angler.dead || !this.angler.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.angler) > 1024.0D)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@ import common.init.Items;
|
|||
import common.init.SoundEvent;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.spawner.ItemMobTemplate;
|
||||
import common.network.IPlayer;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
|
@ -55,6 +54,7 @@ import common.util.BlockPos;
|
|||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Equipment;
|
||||
import common.util.ParticleType;
|
||||
import common.util.Serverside;
|
||||
import common.util.Color;
|
||||
|
@ -66,8 +66,6 @@ import common.world.AWorldServer;
|
|||
|
||||
public abstract class EntityLiving extends Entity
|
||||
{
|
||||
private static final ItemStack[] EMPTY_INV = new ItemStack[5];
|
||||
|
||||
protected AttributeMap attributes = new AttributeMap();
|
||||
private final List<CombatEntry> combat = Lists.<CombatEntry>newArrayList();
|
||||
private final Map<Effect, StatusEffect> effects = Maps.<Effect, StatusEffect>newEnumMap(Effect.class);
|
||||
|
@ -845,9 +843,9 @@ public abstract class EntityLiving extends Entity
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((source == DamageSource.anvil || source == DamageSource.fallingBlock) && this.getItem(4) != null)
|
||||
if (this instanceof EntityNPC npc && (source == DamageSource.anvil || source == DamageSource.fallingBlock) && npc.getArmor(Equipment.HELMET) != null)
|
||||
{
|
||||
this.getItem(4).damage((int)(amount * 4.0F + this.rand.floatv() * (float)amount * 2.0F), this);
|
||||
npc.getArmor(Equipment.HELMET).damage((int)(amount * 4.0F + this.rand.floatv() * (float)amount * 2.0F), this);
|
||||
amount = (int)((float)amount * 0.75F);
|
||||
}
|
||||
|
||||
|
@ -1153,23 +1151,9 @@ public abstract class EntityLiving extends Entity
|
|||
this.attackedYaw = 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
|
||||
*/
|
||||
public int getTotalArmorValue()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack itemstack : this.getInventory())
|
||||
{
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemArmor)
|
||||
{
|
||||
int j = ((ItemArmor)itemstack.getItem()).damageReduceAmount;
|
||||
i += j;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void damageArmor(int p_70675_1_)
|
||||
|
@ -1215,21 +1199,7 @@ public abstract class EntityLiving extends Entity
|
|||
}
|
||||
else
|
||||
{
|
||||
int k = EnchantmentHelper.getEnchantmentModifierDamage(this.getInventory(), source);
|
||||
|
||||
if (k > 20)
|
||||
{
|
||||
k = 20;
|
||||
}
|
||||
|
||||
if (k > 0 && k <= 20)
|
||||
{
|
||||
int l = 25 - k;
|
||||
float f1 = (float)damage * (float)l;
|
||||
damage = (int)(f1 / 25.0F);
|
||||
}
|
||||
|
||||
return damage;
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1398,17 +1368,6 @@ public abstract class EntityLiving extends Entity
|
|||
// return CreatureType.UNDEFINED;
|
||||
// }
|
||||
|
||||
public ItemStack getHeldItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getItem(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getArmor(int slotIn) {
|
||||
return null;
|
||||
}
|
||||
// public abstract void setItem(int slot, ItemStack stack);
|
||||
|
||||
/**
|
||||
|
@ -2363,7 +2322,7 @@ public abstract class EntityLiving extends Entity
|
|||
if(fall.source() != DamageSource.fall && fall.source() != DamageSource.outOfWorld) {
|
||||
Entity fallEnt = fall.source().getEntity();
|
||||
if(fallEnt != null && (lastEnt == null || fallEnt != lastEnt)) {
|
||||
ItemStack fallItem = fallEnt instanceof EntityLiving ? ((EntityLiving)fallEnt).getHeldItem() : null;
|
||||
ItemStack fallItem = fallEnt instanceof EntityNPC ? ((EntityNPC)fallEnt).getHeldItem() : null;
|
||||
receiver = fallEnt.isPlayer() ? ((EntityNPC)fallEnt).connection : null;
|
||||
if(fallItem != null) { // && fallItem.hasDisplayName()) {
|
||||
msg = String.format("%s wurde von %s mit %s zum Fallen verdammt", this.getColoredName(Color.CYAN),
|
||||
|
@ -2379,7 +2338,7 @@ public abstract class EntityLiving extends Entity
|
|||
}
|
||||
}
|
||||
else if(lastEnt != null) {
|
||||
ItemStack lastItem = lastEnt instanceof EntityLiving ? ((EntityLiving)lastEnt).getHeldItem() : null;
|
||||
ItemStack lastItem = lastEnt instanceof EntityNPC ? ((EntityNPC)lastEnt).getHeldItem() : null;
|
||||
receiver = lastEnt.isPlayer() ? ((EntityNPC)lastEnt).connection : null;
|
||||
if(lastItem != null) { // && lastItem.hasDisplayName()) {
|
||||
msg = String.format("%s fiel zu tief und wurde von %s mit %s erledigt",
|
||||
|
@ -3008,10 +2967,6 @@ public abstract class EntityLiving extends Entity
|
|||
this.bodyHelper.updateRenderAngles();
|
||||
return p_110146_2_;
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory() {
|
||||
return EMPTY_INV;
|
||||
}
|
||||
|
||||
// public LayerExtra getExtrasLayer() {
|
||||
// return null;
|
||||
|
|
|
@ -135,7 +135,7 @@ import common.model.TextureAnimation;
|
|||
import common.properties.Property;
|
||||
import common.util.PortalType;
|
||||
import common.util.Color;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Util;
|
||||
import common.world.State;
|
||||
|
||||
|
@ -244,7 +244,7 @@ public abstract class BlockRegistry {
|
|||
Block stone = (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setSound(SoundType.STONE).setDisplay("Stein");
|
||||
register("stone", stone);
|
||||
register("bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Grundgestein").setTab(CheatTab.ROCK).setMiningTool(HarvestTool.PICKAXE, 6));
|
||||
.setDisplay("Grundgestein").setTab(CheatTab.ROCK).setMiningTool(Equipment.PICKAXE, 6));
|
||||
register("rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setSound(SoundType.STONE).setDisplay("Felsen").setTab(CheatTab.ROCK));
|
||||
register("smooth_rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setSound(SoundType.STONE).setDisplay("Glatter Felsen").setTab(CheatTab.ROCK));
|
||||
register("hellrock", (new BlockHellRock()).setHardness(0.4F).setSound(SoundType.STONE).setDisplay("Höllenstein"));
|
||||
|
@ -263,8 +263,8 @@ public abstract class BlockRegistry {
|
|||
register("smooth_sandstone", (new BlockSandStone("smooth")).setSound(SoundType.STONE).setHardness(0.8F).setDisplay("Glatter Sandstein"));
|
||||
register("carved_sandstone", (new BlockSandStone("carved")).setSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Sandstein"));
|
||||
register("obsidian", (new BlockObsidian()).setHardness(50.0F).setResistance(2000.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Obsidian").setMiningTool(HarvestTool.PICKAXE, 3));
|
||||
register("clay", (new BlockClay()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Ton").setMiningTool(HarvestTool.SHOVEL));
|
||||
.setDisplay("Obsidian").setMiningTool(Equipment.PICKAXE, 3));
|
||||
register("clay", (new BlockClay()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Ton").setMiningTool(Equipment.SHOVEL));
|
||||
register("hardened_clay", (new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setSound(SoundType.STONE).setDisplay("Gebrannter Ton"));
|
||||
for(Color color : Color.values()) {
|
||||
register(color.getName() + "_clay", (new BlockColoredClay(color)).setHardness(1.25F).setResistance(7.0F)
|
||||
|
@ -272,16 +272,16 @@ public abstract class BlockRegistry {
|
|||
}
|
||||
register("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
|
||||
.setSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5));
|
||||
register("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Sand").setMiningTool(HarvestTool.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Roter Sand").setMiningTool(HarvestTool.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("gravel", (new BlockGravel()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Kies").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Sand").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Roter Sand").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("gravel", (new BlockGravel()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Kies").setMiningTool(Equipment.SHOVEL));
|
||||
register("ash", (new BlockFalling(Material.LOOSE)).setHardness(0.2F).setSound(SoundType.SAND).setDisplay("Asche")
|
||||
.setTab(CheatTab.NATURE).setMiningTool(HarvestTool.SHOVEL));
|
||||
register("snow_layer", (new BlockSnow()).setHardness(0.1F).setSound(SoundType.SNOW).setDisplay("Schnee").setOpacity(0).setMiningTool(HarvestTool.SHOVEL));
|
||||
register("snow", (new BlockSnowBlock()).setHardness(0.2F).setSound(SoundType.SNOW).setDisplay("Schnee").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("ice", (new BlockIce()).setHardness(0.5F).setOpacity(3).setSound(SoundType.GLASS).setDisplay("Eis").setMiningTool(HarvestTool.PICKAXE, 0));
|
||||
register("packed_ice", (new BlockPackedIce()).setHardness(0.5F).setSound(SoundType.GLASS).setDisplay("Packeis").setMiningTool(HarvestTool.PICKAXE, 0));
|
||||
register("soul_sand", (new BlockSoulSand()).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Seelensand").setMiningTool(HarvestTool.SHOVEL));
|
||||
.setTab(CheatTab.NATURE).setMiningTool(Equipment.SHOVEL));
|
||||
register("snow_layer", (new BlockSnow()).setHardness(0.1F).setSound(SoundType.SNOW).setDisplay("Schnee").setOpacity(0).setMiningTool(Equipment.SHOVEL));
|
||||
register("snow", (new BlockSnowBlock()).setHardness(0.2F).setSound(SoundType.SNOW).setDisplay("Schnee").setMiningTool(Equipment.SHOVEL));
|
||||
register("ice", (new BlockIce()).setHardness(0.5F).setOpacity(3).setSound(SoundType.GLASS).setDisplay("Eis").setMiningTool(Equipment.PICKAXE, 0));
|
||||
register("packed_ice", (new BlockPackedIce()).setHardness(0.5F).setSound(SoundType.GLASS).setDisplay("Packeis").setMiningTool(Equipment.PICKAXE, 0));
|
||||
register("soul_sand", (new BlockSoulSand()).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Seelensand").setMiningTool(Equipment.SHOVEL));
|
||||
register("glowstone", (new BlockGlowstone(Material.TRANSLUCENT)).setHardness(0.3F).setSound(SoundType.GLASS).setLight(1.0F)
|
||||
.setDisplay("Glowstone"));
|
||||
register("blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setSound(SoundType.STONE).setDisplay("Schwarzstein"));
|
||||
|
@ -307,35 +307,35 @@ public abstract class BlockRegistry {
|
|||
|
||||
register("coal_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE).setDisplay("Steinkohle"));
|
||||
register("lapis_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Lapislazulierz").setMiningTool(HarvestTool.PICKAXE, 1));
|
||||
.setDisplay("Lapislazulierz").setMiningTool(Equipment.PICKAXE, 1));
|
||||
register("emerald_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Smaragderz").setMiningTool(HarvestTool.PICKAXE, 2));
|
||||
.setDisplay("Smaragderz").setMiningTool(Equipment.PICKAXE, 2));
|
||||
register("quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Quarzerz"));
|
||||
register("black_quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Schwarzes Quarzerz"));
|
||||
register("charge_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Geladenes Erz").setMiningTool(HarvestTool.PICKAXE, 2));
|
||||
.setDisplay("Geladenes Erz").setMiningTool(Equipment.PICKAXE, 2));
|
||||
|
||||
for(MetalType metal : MetalType.values()) {
|
||||
// String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
|
||||
register(metal.name + "_ore", (new BlockMetalOre(metal)).setHardness(3.0F).setResistance(5.0F)
|
||||
.setDisplay(metal.display + "erz").setMiningTool(HarvestTool.PICKAXE, 1));
|
||||
.setDisplay(metal.display + "erz").setMiningTool(Equipment.PICKAXE, 1));
|
||||
}
|
||||
for(OreType ore : OreType.values()) {
|
||||
// String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1);
|
||||
register(ore.name + "_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setSound(SoundType.STONE)
|
||||
.setDisplay(ore.display + "erz").setMiningTool(HarvestTool.PICKAXE, ore.material.getHarvestLevel() - 1));
|
||||
.setDisplay(ore.display + "erz").setMiningTool(Equipment.PICKAXE, ore.material.getHarvestLevel() - 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
register("dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Erde").setMiningTool(HarvestTool.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("grass", (new BlockGrass()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Gras").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("coarse_dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Grobe Erde").setMiningTool(HarvestTool.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("podzol", (new BlockPodzol()).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Podsol").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("mycelium", (new BlockMycelium()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Myzel").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Erde").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("grass", (new BlockGrass()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Gras").setMiningTool(Equipment.SHOVEL));
|
||||
register("coarse_dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Grobe Erde").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
|
||||
register("podzol", (new BlockPodzol()).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Podsol").setMiningTool(Equipment.SHOVEL));
|
||||
register("mycelium", (new BlockMycelium()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Myzel").setMiningTool(Equipment.SHOVEL));
|
||||
register("tian", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setSound(SoundType.STONE)
|
||||
.setDisplay("Tian").setTab(CheatTab.NATURE));
|
||||
register("tian_soil", (new BlockTianSoil()).setHardness(2.0F).setResistance(15.0F).setSound(SoundType.STONE)
|
||||
|
@ -343,15 +343,15 @@ public abstract class BlockRegistry {
|
|||
register("moon_cheese", (new BlockTreasure(Material.SOFT)).setHardness(1.5F).setResistance(5.0F)
|
||||
.setSound(SoundType.CLOTH).setDisplay("Mondkäse").setTab(CheatTab.NATURE));
|
||||
register("slime_block", (new BlockSlime()).setDisplay("Schleimblock").setSound(SoundType.SLIME));
|
||||
register("blackened_dirt", (new BlockBlackenedDirt()).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("blackened_soil", (new BlockBlackenedSoil()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Schwarzgrund").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("swamp", (new BlockSwamp()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Sumpf").setMiningTool(HarvestTool.SHOVEL));
|
||||
register("blackened_dirt", (new BlockBlackenedDirt()).setHardness(0.5F).setSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setMiningTool(Equipment.SHOVEL));
|
||||
register("blackened_soil", (new BlockBlackenedSoil()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Schwarzgrund").setMiningTool(Equipment.SHOVEL));
|
||||
register("swamp", (new BlockSwamp()).setHardness(0.6F).setSound(SoundType.GRASS).setDisplay("Sumpf").setMiningTool(Equipment.SHOVEL));
|
||||
|
||||
|
||||
|
||||
|
||||
for(BlockTallGrass.EnumType type : BlockTallGrass.EnumType.values()) {
|
||||
register(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay(type.getDisplay()).setMiningTool(HarvestTool.SHEARS));
|
||||
register(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay(type.getDisplay()).setMiningTool(Equipment.SHEARS));
|
||||
}
|
||||
register("deadbush", (new BlockDeadBush()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Toter Busch"));
|
||||
for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
|
||||
|
@ -363,8 +363,8 @@ public abstract class BlockRegistry {
|
|||
Block cactus = (new BlockCactus()).setHardness(0.4F).setSound(SoundType.CLOTH).setDisplay("Kaktus");
|
||||
register("cactus", cactus);
|
||||
register("reeds", (new BlockReed()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS));
|
||||
register("vine", (new BlockVine(false)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Ranken").setMiningTool(HarvestTool.SHEARS));
|
||||
register("swamp_vine", (new BlockVine(true)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Sumpfranken").setMiningTool(HarvestTool.SHEARS));
|
||||
register("vine", (new BlockVine(false)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Ranken").setMiningTool(Equipment.SHEARS));
|
||||
register("swamp_vine", (new BlockVine(true)).setHardness(0.2F).setSound(SoundType.GRASS).setDisplay("Sumpfranken").setMiningTool(Equipment.SHEARS));
|
||||
register("waterlily", (new BlockLilyPad()).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("Seerosenblatt"));
|
||||
|
||||
|
||||
|
@ -407,9 +407,9 @@ public abstract class BlockRegistry {
|
|||
|
||||
|
||||
register("lapis_block", (new Block(Material.SOLID)).setHardness(3.0F).setResistance(5.0F)
|
||||
.setSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.GEMS).setMiningTool(HarvestTool.PICKAXE, 1));
|
||||
.setSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.GEMS).setMiningTool(Equipment.PICKAXE, 1));
|
||||
register("emerald_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
|
||||
.setSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.GEMS).setMiningTool(HarvestTool.PICKAXE, 2));
|
||||
.setSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.GEMS).setMiningTool(Equipment.PICKAXE, 2));
|
||||
register("charged_block", (new BlockMagnetic(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
|
||||
.setSound(SoundType.STONE).setDisplay("Geladener Block").setTab(CheatTab.GEMS));
|
||||
|
||||
|
@ -424,7 +424,7 @@ public abstract class BlockRegistry {
|
|||
|
||||
|
||||
for(Color color : Color.values()) {
|
||||
register(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle").setMiningTool(HarvestTool.SHEARS));
|
||||
register(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle").setMiningTool(Equipment.SHEARS));
|
||||
}
|
||||
for(Color color : Color.values()) {
|
||||
register(color.getName() + "_carpet", (new BlockCarpet(color)).setHardness(0.1F).setSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setOpacity(0));
|
||||
|
@ -433,7 +433,7 @@ public abstract class BlockRegistry {
|
|||
register(color.getName() + "_bed", (new BlockBed(color)).setSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett"));
|
||||
}
|
||||
|
||||
register("ladder", (new BlockLadder()).setHardness(0.4F).setSound(SoundType.LADDER).setDisplay("Leiter").setMiningTool(HarvestTool.AXE));
|
||||
register("ladder", (new BlockLadder()).setHardness(0.4F).setSound(SoundType.LADDER).setDisplay("Leiter").setMiningTool(Equipment.AXE));
|
||||
register("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setSound(SoundType.WOOD).setDisplay("Bücherregal"));
|
||||
register("cake", (new BlockCake()).setHardness(0.5F).setSound(SoundType.CLOTH).setDisplay("Kuchen").setTab(CheatTab.DECORATION));
|
||||
register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setSound(SoundType.STONE)
|
||||
|
@ -466,7 +466,7 @@ public abstract class BlockRegistry {
|
|||
register("portal_frame", (new BlockPortalFrame()).setSound(SoundType.GLASS).setLight(0.125F).setHardness(5.0F)
|
||||
.setDisplay("Portalrahmen").setResistance(2000.0F).setTab(CheatTab.TECHNOLOGY));
|
||||
|
||||
register("farmland", (new BlockFarmland()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Ackerboden").setMiningTool(HarvestTool.SHOVEL).setTab(CheatTab.PLANTS));
|
||||
register("farmland", (new BlockFarmland()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Ackerboden").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.PLANTS));
|
||||
register("wheats", (new BlockCrops()).setDisplay("Getreide"));
|
||||
register("carrots", (new BlockCarrot()).setDisplay("Karotten"));
|
||||
register("potatoes", (new BlockPotato()).setDisplay("Kartoffeln"));
|
||||
|
@ -478,12 +478,12 @@ public abstract class BlockRegistry {
|
|||
for(MetalType metal : MetalType.values()) {
|
||||
// String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
|
||||
register(metal.name + "_block", (new BlockMetalBlock(metal)).setHardness(5.0F).setResistance(10.0F)
|
||||
.setDisplay(metal.display + "block").setMiningTool(HarvestTool.PICKAXE, 1));
|
||||
.setDisplay(metal.display + "block").setMiningTool(Equipment.PICKAXE, 1));
|
||||
}
|
||||
for(OreType ore : OreType.values()) {
|
||||
// String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1);
|
||||
register(ore.name + "_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F).setSound(SoundType.STONE)
|
||||
.setDisplay(ore.display + "block").setTab(CheatTab.GEMS).setMiningTool(HarvestTool.PICKAXE, ore.material.getHarvestLevel() - 1));
|
||||
.setDisplay(ore.display + "block").setTab(CheatTab.GEMS).setMiningTool(Equipment.PICKAXE, ore.material.getHarvestLevel() - 1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -636,7 +636,7 @@ public abstract class BlockRegistry {
|
|||
register("hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Trichter"));
|
||||
register("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Tianreaktor"));
|
||||
|
||||
register("rail", (new BlockRail()).setHardness(0.7F).setSound(SoundType.STONE).setDisplay("Schiene").setMiningTool(HarvestTool.PICKAXE, 0));
|
||||
register("rail", (new BlockRail()).setHardness(0.7F).setSound(SoundType.STONE).setDisplay("Schiene").setMiningTool(Equipment.PICKAXE, 0));
|
||||
|
||||
register("lever", (new BlockLever()).setHardness(0.5F).setSound(SoundType.WOOD).setDisplay("Hebel"));
|
||||
|
||||
|
|
|
@ -19,16 +19,10 @@ import common.item.Item;
|
|||
import common.item.ItemStack;
|
||||
import common.item.material.ItemDye;
|
||||
import common.util.Color;
|
||||
import common.util.Equipment;
|
||||
|
||||
public abstract class CraftingRegistry
|
||||
{
|
||||
private static final String[][] TOOLS = new String[][] {
|
||||
{"XXX", " # ", " # "}, {"X", "#", "#"}, {"XX", "X#", " #"}
|
||||
};
|
||||
private static final String[][] WEAPONS = new String[][] {{"X", "X", "#"}};
|
||||
private static final String[][] ARMOR = new String[][] {
|
||||
{"XXX", "X X"}, {"X X", "XXX", "XXX"}, {"XXX", "X X", "X X"}, {"X X", "X X"}
|
||||
};
|
||||
private static final Object[][] COMPRESSED = new Object[][] {
|
||||
{Items.emerald_block, new ItemStack(Items.emerald, 9)},
|
||||
{Items.lapis_block, new ItemStack(Items.lapis_lazuli, 9)},
|
||||
|
@ -39,53 +33,29 @@ public abstract class CraftingRegistry
|
|||
};
|
||||
|
||||
private static final List<IRecipe> recipes = Lists.<IRecipe>newArrayList();
|
||||
|
||||
private static void registerTools(ToolMaterial material, Item item, String name) {
|
||||
for(Equipment tool : Equipment.values()) {
|
||||
if(tool.getRecipe().length > 0 && tool.canRegister(material))
|
||||
add(new ItemStack(ItemRegistry.byName(name + "_" + tool.getName())), tool.getRecipe(), '#', Items.stick, 'X', item);
|
||||
}
|
||||
}
|
||||
|
||||
static void register()
|
||||
{
|
||||
for(OreType ore : OreType.values()) {
|
||||
Item item = ItemRegistry.byName(ore.item);
|
||||
ore.material.addRepairItem(item);
|
||||
if(ore.material.hasTools()) {
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(ore.material.hasExtras()) {
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_shears")), " #", "# ", '#', item);
|
||||
}
|
||||
if(ore.material.hasWeapons()) {
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(ore.material.hasArmor()) {
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_helmet")), ARMOR[0], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_chestplate")), ARMOR[1], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_leggings")), ARMOR[2], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(ore.name + "_boots")), ARMOR[3], 'X', item);
|
||||
}
|
||||
registerTools(ore.material, item, ore.name);
|
||||
Item block = ItemRegistry.byName(ore.name + "_block");
|
||||
add(new ItemStack(block), "###", "###", "###", '#', item);
|
||||
add(new ItemStack(item, 9), "#", '#', block);
|
||||
}
|
||||
for(MetalType metal : MetalType.values()) {
|
||||
Item item = ItemRegistry.byName(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot"));
|
||||
if(metal.material != null)
|
||||
if(metal.material != null) {
|
||||
metal.material.addRepairItem(item);
|
||||
if(metal.material != null && metal.material.hasTools()) {
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(metal.material != null && metal.material.hasExtras()) {
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_shears")), " #", "# ", '#', item);
|
||||
}
|
||||
if(metal.material != null && metal.material.hasWeapons()) {
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(metal.material != null && metal.material.hasArmor()) {
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_helmet")), ARMOR[0], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_chestplate")), ARMOR[1], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_leggings")), ARMOR[2], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(metal.name + "_boots")), ARMOR[3], 'X', item);
|
||||
registerTools(metal.material, item, metal.name);
|
||||
}
|
||||
Item block = ItemRegistry.byName(metal.name + "_block");
|
||||
add(new ItemStack(block), "###", "###", "###", '#', item);
|
||||
|
@ -95,23 +65,7 @@ public abstract class CraftingRegistry
|
|||
for(String itm : tool.items) {
|
||||
Item item = ItemRegistry.byName(itm);
|
||||
tool.material.addRepairItem(item);
|
||||
if(tool.material.hasTools()) {
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(tool.material.hasExtras()) {
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_shears")), " #", "# ", '#', item);
|
||||
}
|
||||
if(tool.material.hasWeapons()) {
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item);
|
||||
}
|
||||
if(tool.material.hasArmor()) {
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_helmet")), ARMOR[0], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_chestplate")), ARMOR[1], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_leggings")), ARMOR[2], 'X', item);
|
||||
add(new ItemStack(ItemRegistry.byName(tool.name + "_boots")), ARMOR[3], 'X', item);
|
||||
}
|
||||
registerTools(tool.material, item, tool.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.Block;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
import common.block.liquid.BlockLiquid;
|
||||
|
@ -37,7 +36,7 @@ import common.item.material.ItemBucket;
|
|||
import common.item.material.ItemDye;
|
||||
import common.item.material.ItemEnchantedBook;
|
||||
import common.item.material.ItemGrindedBones;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.item.material.ItemAnimalArmor;
|
||||
import common.item.material.ItemMetal;
|
||||
import common.item.material.ItemRecord;
|
||||
import common.item.material.ItemSeeds;
|
||||
|
@ -77,7 +76,7 @@ import common.item.weapon.ItemTrident;
|
|||
import common.log.Log;
|
||||
import common.util.Pair;
|
||||
import common.util.Color;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.util.Util;
|
||||
import common.world.Weather;
|
||||
|
||||
|
@ -127,24 +126,10 @@ public abstract class ItemRegistry {
|
|||
}
|
||||
|
||||
private static void registerTools(ToolMaterial material, String name, String prefix) {
|
||||
if(material.hasTools()) {
|
||||
register(name + "_shovel", (new ItemTool(material, HarvestTool.SHOVEL)).setDisplay(prefix + "schaufel"));
|
||||
register(name + "_pickaxe", (new ItemTool(material, HarvestTool.PICKAXE)).setDisplay(prefix + "spitzhacke"));
|
||||
register(name + "_axe", (new ItemTool(material, HarvestTool.AXE)).setDisplay(prefix + "axt"));
|
||||
}
|
||||
if(material.hasExtras()) {
|
||||
register(name + "_shears", (new ItemTool(material, HarvestTool.SHEARS)).setDisplay(prefix + "schere"));
|
||||
register(name + "_horse_armor", (new ItemHorseArmor(material, name)).setDisplay(prefix + "pferderüstung"));
|
||||
}
|
||||
if(material.hasWeapons()) {
|
||||
register(name + "_sword", (new ItemTool(material, HarvestTool.SWORD)).setDisplay(prefix + "schwert"));
|
||||
}
|
||||
if(material.hasArmor()) {
|
||||
register(name + "_helmet", (new ItemArmor(material, name, UsageSlot.HEAD)).setDisplay(prefix == null ? "Kappe" : prefix + "helm"));
|
||||
register(name + "_chestplate", (new ItemArmor(material, name, UsageSlot.BODY)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer"));
|
||||
register(name + "_leggings", (new ItemArmor(material, name, UsageSlot.LEGS)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz"));
|
||||
register(name + "_boots", (new ItemArmor(material, name, UsageSlot.FEET)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel"));
|
||||
}
|
||||
for(Equipment tool : Equipment.values()) {
|
||||
if(tool.canRegister(material))
|
||||
register(name + "_" + tool.getName(), (tool.isArmor() ? (tool.isAnimalArmor() ? new ItemAnimalArmor(material, name) : new ItemArmor(material, name, tool)) : new ItemTool(material, tool)).setDisplay(tool.getDisplay(prefix, prefix == null)));
|
||||
}
|
||||
}
|
||||
|
||||
static void register() {
|
||||
|
|
|
@ -24,7 +24,7 @@ import common.item.material.ItemBucket;
|
|||
import common.item.material.ItemDye;
|
||||
import common.item.material.ItemEnchantedBook;
|
||||
import common.item.material.ItemGrindedBones;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.item.material.ItemAnimalArmor;
|
||||
import common.item.material.ItemMetal;
|
||||
import common.item.material.ItemRecord;
|
||||
import common.item.material.ItemSeeds;
|
||||
|
@ -302,7 +302,7 @@ public abstract class Items {
|
|||
public static final ItemArmor diamond_boots = get("diamond_boots");
|
||||
public static final ItemArmor diamond_chestplate = get("diamond_chestplate");
|
||||
public static final ItemArmor diamond_helmet = get("diamond_helmet");
|
||||
public static final ItemHorseArmor diamond_horse_armor = get("diamond_horse_armor");
|
||||
public static final ItemAnimalArmor diamond_horse_armor = get("diamond_horse_armor");
|
||||
public static final ItemArmor diamond_leggings = get("diamond_leggings");
|
||||
public static final Item diamond_ore = get("diamond_ore");
|
||||
public static final ItemTool diamond_pickaxe = get("diamond_pickaxe");
|
||||
|
@ -358,7 +358,7 @@ public abstract class Items {
|
|||
public static final ItemArmor gold_boots = get("gold_boots");
|
||||
public static final ItemArmor gold_chestplate = get("gold_chestplate");
|
||||
public static final ItemArmor gold_helmet = get("gold_helmet");
|
||||
public static final ItemHorseArmor gold_horse_armor = get("gold_horse_armor");
|
||||
public static final ItemAnimalArmor gold_horse_armor = get("gold_horse_armor");
|
||||
public static final ItemMetal gold_ingot = get("gold_ingot");
|
||||
public static final ItemArmor gold_leggings = get("gold_leggings");
|
||||
public static final Item gold_nugget = get("gold_nugget");
|
||||
|
@ -408,7 +408,7 @@ public abstract class Items {
|
|||
public static final ItemArmor iron_chestplate = get("iron_chestplate");
|
||||
public static final Item iron_door = get("iron_door");
|
||||
public static final ItemArmor iron_helmet = get("iron_helmet");
|
||||
public static final ItemHorseArmor iron_horse_armor = get("iron_horse_armor");
|
||||
public static final ItemAnimalArmor iron_horse_armor = get("iron_horse_armor");
|
||||
public static final ItemMetal iron_ingot = get("iron_ingot");
|
||||
public static final ItemArmor iron_leggings = get("iron_leggings");
|
||||
public static final Item iron_ore = get("iron_ore");
|
||||
|
|
|
@ -2,15 +2,11 @@ package common.init;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import common.attributes.UsageSlot;
|
||||
import common.collect.Sets;
|
||||
import common.item.Item;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ToolMaterial {
|
||||
private static final int[] MAX_DAMAGE = new int[] {11, 16, 15, 13};
|
||||
private static final float[] RAD_REDUCE = new float[] {1.0f, 1.7f, 1.6f, 1.4f};
|
||||
private static final float[] MAG_REDUCE = new float[] {1.0f, 1.2f, 1.1f, 1.0f};
|
||||
|
||||
private final int harvestLevel;
|
||||
private final int durability;
|
||||
private final int efficiency;
|
||||
|
@ -121,20 +117,20 @@ public class ToolMaterial {
|
|||
return this.repair.contains(item);
|
||||
}
|
||||
|
||||
public int getDurability(UsageSlot armorType) {
|
||||
return armorType.getArmorSlot() < 0 ? 0 : MAX_DAMAGE[armorType.getArmorSlot()] * this.maxDamageFactor;
|
||||
public int getDurability(Equipment armorType) {
|
||||
return armorType.getDamage() * this.maxDamageFactor;
|
||||
}
|
||||
|
||||
public float getRadiationReduction(UsageSlot armorType) {
|
||||
return armorType.getArmorSlot() < 0 ? 0.0f : RAD_REDUCE[armorType.getArmorSlot()] * this.radiationResistance;
|
||||
public float getRadiationReduction(Equipment armorType) {
|
||||
return armorType.getPhysicalResistance() * this.radiationResistance;
|
||||
}
|
||||
|
||||
public float getMagicReduction(UsageSlot armorType) {
|
||||
return armorType.getArmorSlot() < 0 ? 0.0f : MAG_REDUCE[armorType.getArmorSlot()] * this.magicResistance;
|
||||
public float getMagicReduction(Equipment armorType) {
|
||||
return armorType.getMagicalResistance() * this.magicResistance;
|
||||
}
|
||||
|
||||
public int getDamageReduction(UsageSlot armorType) {
|
||||
return armorType.getArmorSlot() < 0 ? 0 : this.damageReduction[armorType.getArmorSlot()];
|
||||
public int getDamageReduction(Equipment armorType) {
|
||||
return armorType.getIndex() >= this.damageReduction.length ? 0 : this.damageReduction[armorType.getIndex()];
|
||||
}
|
||||
|
||||
public int getArmorEnchantability() {
|
||||
|
|
|
@ -3,12 +3,12 @@ package common.inventory;
|
|||
import java.util.List;
|
||||
|
||||
import common.attributes.AttributeMap;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.CraftingRegistry;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ContainerPlayer extends Container {
|
||||
private final InventoryCrafting baseCrafting = new InventoryCrafting(new Container() {
|
||||
|
@ -42,10 +42,10 @@ public class ContainerPlayer extends Container {
|
|||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 4; ++k)
|
||||
for (Equipment slot : Equipment.ARMOR)
|
||||
{
|
||||
final int k_f = k;
|
||||
this.addSlotToContainer(new Slot(playerInventory, playerInventory.getSizeInventory() - 1 - k, 8, 8 + k * 18)
|
||||
final Equipment type = slot;
|
||||
this.addSlotToContainer(new Slot(playerInventory, 27 + 9 + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
|
||||
{
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
|
@ -53,12 +53,8 @@ public class ContainerPlayer extends Container {
|
|||
}
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == k_f; // : (stack.getItem() != Items.pumpkin && stack.getItem() != Items.skull ? false : k_f == 0));
|
||||
return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType() == type;
|
||||
}
|
||||
// public String getSlotTexture()
|
||||
// {
|
||||
// return ItemArmor.EMPTY_SLOT_NAMES[k_f];
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -81,7 +77,7 @@ public class ContainerPlayer extends Container {
|
|||
protected Slot addSlotToContainer(Slot slotIn)
|
||||
{
|
||||
slotIn = super.addSlotToContainer(slotIn);
|
||||
if(slotIn.slotNumber >= 9)
|
||||
if(slotIn.slotNumber >= 5 + Equipment.ARMOR_SLOTS)
|
||||
this.lastStacks.add((ItemStack)null);
|
||||
return slotIn;
|
||||
}
|
||||
|
@ -91,24 +87,24 @@ public class ContainerPlayer extends Container {
|
|||
for (int i = 0; i < this.inventorySlots.size(); ++i)
|
||||
{
|
||||
Slot slot = this.inventorySlots.get(i);
|
||||
if(slot.slotNumber >= 9) {
|
||||
if(slot.slotNumber >= 5 + Equipment.ARMOR_SLOTS) {
|
||||
ItemStack current = slot.getStack();
|
||||
ItemStack last = (ItemStack)this.lastStacks.get(i - 9);
|
||||
ItemStack last = (ItemStack)this.lastStacks.get(i - (5 + Equipment.ARMOR_SLOTS));
|
||||
|
||||
if (!ItemStack.allEquals(last, current))
|
||||
{
|
||||
if (last != null)
|
||||
{
|
||||
this.attributes.remove(last.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex());
|
||||
this.attributes.remove(last.getAttributeModifiers(Equipment.PICKAXE), slot.getIndex());
|
||||
}
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
this.attributes.add(current.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex(), current.getSize());
|
||||
this.attributes.add(current.getAttributeModifiers(Equipment.PICKAXE), slot.getIndex(), current.getSize());
|
||||
}
|
||||
|
||||
last = current == null ? null : current.copy();
|
||||
this.lastStacks.set(i - 9, last);
|
||||
this.lastStacks.set(i - (5 + Equipment.ARMOR_SLOTS), last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +173,7 @@ public class ContainerPlayer extends Container {
|
|||
|
||||
if (index == 0)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 45, true))
|
||||
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -186,42 +182,42 @@ public class ContainerPlayer extends Container {
|
|||
}
|
||||
else if (index >= 1 && index < 5)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 45, false))
|
||||
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (index >= 5 && index < 9)
|
||||
else if (index >= 5 && index < 5 + Equipment.ARMOR_SLOTS)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 45, false))
|
||||
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot())).getHasStack())
|
||||
else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + Equipment.ARMOR_SLOTS + ((ItemArmor)itemstack.getItem()).getArmorType().getIndex())).getHasStack())
|
||||
{
|
||||
int i = 5 + ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot();
|
||||
int idx = 5 + Equipment.ARMOR_SLOTS + ((ItemArmor)itemstack.getItem()).getArmorType().getIndex();
|
||||
|
||||
if (!this.mergeItemStack(itemstack1, i, i + 1, false))
|
||||
if (!this.mergeItemStack(itemstack1, idx, idx + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (index >= 9 && index < 36)
|
||||
else if (index >= 5 + Equipment.ARMOR_SLOTS && index < 5 + Equipment.ARMOR_SLOTS + 27)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 36, 45, false))
|
||||
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS + 27, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (index >= 36 && index < 45)
|
||||
else if (index >= 5 + Equipment.ARMOR_SLOTS + 27 && index < 5 + Equipment.ARMOR_SLOTS + 27 + 9)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 36, false))
|
||||
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 9, 45, false))
|
||||
else if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import common.item.ItemStack;
|
|||
import common.item.material.ItemArmor;
|
||||
import common.item.tool.ItemTool;
|
||||
import common.tags.TagObject;
|
||||
import common.util.Equipment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryPlayer implements IInventory
|
||||
|
@ -17,7 +19,7 @@ public class InventoryPlayer implements IInventory
|
|||
public ItemStack[] mainInventory = new ItemStack[36];
|
||||
|
||||
/** An array of 4 item stacks containing the currently worn armor pieces. */
|
||||
public ItemStack[] armorInventory = new ItemStack[4];
|
||||
public ItemStack[] armorInventory = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
|
||||
/** The index of the currently held item (0-8). */
|
||||
public int currentItem;
|
||||
|
@ -459,7 +461,7 @@ public class InventoryPlayer implements IInventory
|
|||
public void fromTag(List<TagObject> list)
|
||||
{
|
||||
this.mainInventory = new ItemStack[36];
|
||||
this.armorInventory = new ItemStack[4];
|
||||
this.armorInventory = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
|
@ -487,7 +489,7 @@ public class InventoryPlayer implements IInventory
|
|||
*/
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.mainInventory.length + 4;
|
||||
return this.mainInventory.length + this.armorInventory.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -521,16 +523,6 @@ public class InventoryPlayer implements IInventory
|
|||
return stack != null && stack.getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() && (!tool.getToolType().isLevelled() || tool.getToolMaterial().getHarvestLevel() >= block.getMiningLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a player armor item (as itemstack) contained in specified armor slot.
|
||||
*
|
||||
* @param slotIn the slot index requested
|
||||
*/
|
||||
public ItemStack armorItemInSlot(int slotIn)
|
||||
{
|
||||
return this.armorInventory[slotIn];
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the damage values and maximum damage values of each armor item, returns the current armor value.
|
||||
*/
|
||||
|
@ -542,7 +534,7 @@ public class InventoryPlayer implements IInventory
|
|||
{
|
||||
if (this.armorInventory[j] != null && this.armorInventory[j].getItem() instanceof ItemArmor)
|
||||
{
|
||||
int k = ((ItemArmor)this.armorInventory[j].getItem()).damageReduceAmount;
|
||||
int k = ((ItemArmor)this.armorInventory[j].getItem()).getArmorValue();
|
||||
i += k;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package common.item;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.Block;
|
||||
import common.block.tech.BlockDispenser;
|
||||
import common.entity.Entity;
|
||||
|
@ -246,9 +245,9 @@ public class Item {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot) {
|
||||
public void getModifiers(Map<Attribute, Float> map) {
|
||||
if(this.block != null)
|
||||
this.block.getModifiers(map, slot);
|
||||
this.block.getModifiers(map);
|
||||
}
|
||||
|
||||
public float getRadiation(ItemStack stack) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.enchantment.Enchantment;
|
||||
|
@ -14,10 +13,12 @@ import common.enchantment.EnchantmentHelper;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.ItemRegistry;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.weapon.ItemBow;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.util.Color;
|
||||
import common.util.Equipment;
|
||||
|
||||
public final class ItemStack {
|
||||
public static final int MAX_SIZE = 67108864;
|
||||
|
@ -264,9 +265,10 @@ public final class ItemStack {
|
|||
return this.repairCost;
|
||||
}
|
||||
|
||||
public Map<Attribute, Float> getAttributeModifiers(UsageSlot slot) {
|
||||
public Map<Attribute, Float> getAttributeModifiers(Equipment slot) {
|
||||
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
|
||||
this.item.getModifiers(map, slot);
|
||||
if(slot == null || (slot.isArmor() ? (this.item instanceof ItemArmor armor && armor.getArmorType() == slot) : !(this.item instanceof ItemArmor)))
|
||||
this.item.getModifiers(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package common.item.consumable;
|
|||
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
|
@ -38,9 +37,8 @@ public class ItemMilkBottle extends Item {
|
|||
return itemStackIn;
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot) {
|
||||
if(slot == null || slot == UsageSlot.INVENTORY)
|
||||
map.put(Attribute.RADIATION, -2.0f);
|
||||
public void getModifiers(Map<Attribute, Float> map) {
|
||||
map.put(Attribute.RADIATION, -2.0f);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
|
|
47
common/src/main/java/common/item/material/ItemAnimalArmor.java
Executable file
47
common/src/main/java/common/item/material/ItemAnimalArmor.java
Executable file
|
@ -0,0 +1,47 @@
|
|||
package common.item.material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.ToolMaterial;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.util.Clientside;
|
||||
import common.util.Color;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ItemAnimalArmor extends Item {
|
||||
private final ToolMaterial material;
|
||||
@Clientside
|
||||
private final String texture;
|
||||
|
||||
public ItemAnimalArmor(ToolMaterial material, String texture) {
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.setUnstackable();
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.isMagnetic())
|
||||
this.setMagnetic();
|
||||
}
|
||||
|
||||
public int getArmorValue() {
|
||||
return this.material.getDamageReduction(Equipment.CHESTPLATE);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public String getArmorTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public boolean hasBuiltinModel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip) {
|
||||
if(this.material.getDamageReduction(Equipment.CHESTPLATE) > 0)
|
||||
tooltip.add(Color.BLUE + "+" + this.material.getDamageReduction(Equipment.CHESTPLATE) + " Rüstungspunkte");
|
||||
}
|
||||
}
|
|
@ -5,9 +5,7 @@ import java.util.Map;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.ToolMaterial;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
|
@ -16,7 +14,9 @@ import common.tileentity.TileEntity;
|
|||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.Clientside;
|
||||
import common.util.Color;
|
||||
import common.util.Facing;
|
||||
import common.util.Equipment;
|
||||
import common.util.Serverside;
|
||||
import common.util.Vec3;
|
||||
import common.world.AWorldServer;
|
||||
|
@ -24,18 +24,16 @@ import common.world.World;
|
|||
|
||||
public class ItemArmor extends Item
|
||||
{
|
||||
public final UsageSlot armorType;
|
||||
public final int damageReduceAmount;
|
||||
private final ToolMaterial material;
|
||||
private final Equipment type;
|
||||
@Clientside
|
||||
private final String texture;
|
||||
|
||||
public ItemArmor(ToolMaterial material, String texture, UsageSlot armorType)
|
||||
public ItemArmor(ToolMaterial material, String texture, Equipment armorType)
|
||||
{
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.armorType = armorType;
|
||||
this.damageReduceAmount = material.getDamageReduction(armorType);
|
||||
this.type = armorType;
|
||||
this.setMaxDamage(material.getDurability(armorType));
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.canBeDyed())
|
||||
|
@ -51,14 +49,19 @@ public class ItemArmor extends Item
|
|||
{
|
||||
return this.material.getArmorEnchantability();
|
||||
}
|
||||
|
||||
public Equipment getArmorType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the armor material for this armor item.
|
||||
*/
|
||||
public ToolMaterial getArmorMaterial()
|
||||
{
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public int getArmorValue() {
|
||||
return this.material.getDamageReduction(this.type);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public String getArmorTexture()
|
||||
|
@ -66,6 +69,13 @@ public class ItemArmor extends Item
|
|||
return this.texture;
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
|
||||
{
|
||||
if(this.material.getDamageReduction(this.type) > 0)
|
||||
tooltip.add(Color.BLUE + "+" + this.material.getDamageReduction(this.type) + " Rüstungspunkte");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
|
@ -79,13 +89,12 @@ public class ItemArmor extends Item
|
|||
*/
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
||||
{
|
||||
int i = ItemArmor.getArmorPosition(itemStackIn) - 1;
|
||||
ItemStack itemstack = playerIn.getArmor(i);
|
||||
ItemStack itemstack = playerIn.getArmor(this.type);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
playerIn.setItem(i, itemStackIn.copy());
|
||||
itemStackIn.setSize(0);
|
||||
playerIn.setArmor(this.type, itemStackIn.copy());
|
||||
itemStackIn.decrSize();
|
||||
}
|
||||
|
||||
return itemStackIn;
|
||||
|
@ -95,44 +104,17 @@ public class ItemArmor extends Item
|
|||
// return this.material.canBeDyed();
|
||||
// }
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
|
||||
public void getModifiers(Map<Attribute, Float> map)
|
||||
{
|
||||
if(slot != null && slot != this.armorType)
|
||||
return;
|
||||
if(this.material.getRadiationReduction(this.armorType) > 0.0f)
|
||||
map.put(Attribute.RADIATION_RESISTANCE, this.material.getRadiationReduction(this.armorType));
|
||||
if(this.material.getMagicReduction(this.armorType) > 0.0f)
|
||||
map.put(Attribute.MAGIC_RESISTANCE, this.material.getMagicReduction(this.armorType));
|
||||
if(this.material.getRadiationReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.RADIATION_RESISTANCE, this.material.getRadiationReduction(this.type));
|
||||
if(this.material.getMagicReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.MAGIC_RESISTANCE, this.material.getMagicReduction(this.type));
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public boolean hasBuiltinModel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getArmorPosition(ItemStack stack) {
|
||||
// if(stack.getItem() != Items.pumpkin && stack.getItem() != Items.skull) {
|
||||
if(stack.getItem() instanceof ItemArmor) {
|
||||
switch(((ItemArmor)stack.getItem()).armorType) {
|
||||
case HEAD:
|
||||
return 4;
|
||||
|
||||
case BODY:
|
||||
return 3;
|
||||
|
||||
case LEGS:
|
||||
return 2;
|
||||
|
||||
case FEET:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
// }
|
||||
// else {
|
||||
// return 4;
|
||||
// }
|
||||
return this.type.isArmorRendered();
|
||||
}
|
||||
|
||||
@Serverside
|
||||
|
@ -142,21 +124,16 @@ public class ItemArmor extends Item
|
|||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
BoundingBox axisalignedbb = new BoundingBox((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1));
|
||||
List<EntityLiving> list = world.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate<EntityLiving>() {
|
||||
public boolean test(EntityLiving entity) {
|
||||
return entity.isEntityAlive() && entity instanceof EntityNPC &&
|
||||
entity.getItem(getArmorPosition(stack)) != null;
|
||||
List<EntityNPC> list = world.<EntityNPC>getEntitiesWithinAABB(EntityNPC.class, axisalignedbb, new Predicate<EntityNPC>() {
|
||||
public boolean test(EntityNPC entity) {
|
||||
return entity.isEntityAlive() && entity.getArmor(ItemArmor.this.type) == null;
|
||||
}
|
||||
});
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
EntityLiving entitylivingbase = (EntityLiving)list.get(0);
|
||||
int l = entitylivingbase.isPlayer() ? 1 : 0;
|
||||
int i1 = getArmorPosition(stack);
|
||||
ItemStack itemstack = stack.copy(1);
|
||||
entitylivingbase.setItem(i1 - l, itemstack);
|
||||
|
||||
EntityNPC entitylivingbase = list.get(0);
|
||||
entitylivingbase.setArmor(this.type, stack.copy(1));
|
||||
stack.decrSize();
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.Queue;
|
|||
import java.util.Set;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
|
@ -136,8 +135,8 @@ public class ItemBucket extends Item
|
|||
return this.liquid;
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot) {
|
||||
if(this.liquid == Blocks.flowing_milk && (slot == null || slot == UsageSlot.INVENTORY))
|
||||
public void getModifiers(Map<Attribute, Float> map) {
|
||||
if(this.liquid == Blocks.flowing_milk)
|
||||
map.put(Attribute.RADIATION, -5.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package common.item.material;
|
||||
|
||||
import common.attributes.UsageSlot;
|
||||
import common.init.ToolMaterial;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.util.Clientside;
|
||||
|
||||
public class ItemHorseArmor extends Item {
|
||||
private final ToolMaterial material;
|
||||
@Clientside
|
||||
private final String texture;
|
||||
|
||||
public ItemHorseArmor(ToolMaterial material, String texture) {
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.setUnstackable();
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.isMagnetic())
|
||||
this.setMagnetic();
|
||||
}
|
||||
|
||||
public int getArmorValue() {
|
||||
return this.material.getDamageReduction(UsageSlot.BODY);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public String getArmorTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public boolean hasBuiltinModel() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package common.item.material;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.UsageSlot;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.MetalType;
|
||||
import common.item.Item;
|
||||
|
@ -37,9 +36,9 @@ public class ItemMetal extends Item {
|
|||
// return this.metal.radioactivity > 0.0f ? ChatFormat.GREEN : super.getColor(stack);
|
||||
// }
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
|
||||
public void getModifiers(Map<Attribute, Float> map)
|
||||
{
|
||||
if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f)
|
||||
if(this.metal.radioactivity > 0.0f)
|
||||
map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@ import common.item.WieldType;
|
|||
import common.util.BlockPos;
|
||||
import common.util.Clientside;
|
||||
import common.util.Color;
|
||||
import common.util.HarvestTool;
|
||||
import common.util.Equipment;
|
||||
import common.world.World;
|
||||
|
||||
public class ItemTool extends Item {
|
||||
private final ToolMaterial material;
|
||||
private final HarvestTool type;
|
||||
private final Equipment type;
|
||||
|
||||
public ItemTool(ToolMaterial material, HarvestTool type) {
|
||||
public ItemTool(ToolMaterial material, Equipment type) {
|
||||
this.material = material;
|
||||
this.type = type;
|
||||
this.setMaxDamage(material.getDurability());
|
||||
|
@ -36,14 +36,10 @@ public class ItemTool extends Item {
|
|||
{
|
||||
if(this.type.isLevelled())
|
||||
tooltip.add(Color.VIOLET + "Level " + (this.getToolMaterial().getHarvestLevel() + 1));
|
||||
tooltip.add(Color.DARK_GREEN + "+ " + (this.material.getEfficiency() - 1) + " Abbaueffizienz");
|
||||
tooltip.add(Color.DARK_GREEN + "+" + (this.material.getEfficiency() - 1) + " Abbaueffizienz");
|
||||
int damage = this.getAttackDamageBonus(stack);
|
||||
if(damage != 0) {
|
||||
if(damage > 0)
|
||||
tooltip.add(Color.BLUE + String.format("+%d Angriffsschaden", damage));
|
||||
else
|
||||
tooltip.add(Color.RED + String.format("-%d Angriffsschaden", damage));
|
||||
}
|
||||
if(damage > 0)
|
||||
tooltip.add(Color.BLUE + "+" + damage + " Angriffsschaden");
|
||||
}
|
||||
|
||||
public int getAttackDamageBonus(ItemStack stack) {
|
||||
|
@ -65,7 +61,7 @@ public class ItemTool extends Item {
|
|||
return this.material;
|
||||
}
|
||||
|
||||
public HarvestTool getToolType() {
|
||||
public Equipment getToolType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
|
147
common/src/main/java/common/util/Equipment.java
Normal file
147
common/src/main/java/common/util/Equipment.java
Normal file
|
@ -0,0 +1,147 @@
|
|||
package common.util;
|
||||
|
||||
import common.enchantment.EnchantmentType;
|
||||
import common.init.ToolMaterial;
|
||||
|
||||
public enum Equipment implements Identifyable, Displayable {
|
||||
PICKAXE("pickaxe", "Spitzhacke", ItemType.LEVELLED, 2, "XXX", " # ", " # "),
|
||||
AXE("axe", "Axt", ItemType.TOOL, 3, "XX", "X#", " #"),
|
||||
SHOVEL("shovel", "Schaufel", ItemType.TOOL, 1, "X", "#", "#"),
|
||||
SHEARS("shears", "Schere", ItemType.OPTIONAL, " X", "X "),
|
||||
SWORD("sword", "Schwert", ItemType.MELEE, 4, "X", "X", "#"),
|
||||
HELMET("helmet", "Helm", "Kappe", 11, 0, EnchantmentType.ARMOR_HEAD, 1.0f, 1.0f, "XXX", "X X"),
|
||||
CHESTPLATE("chestplate", "Brustpanzer", "Jacke", 16, 1, EnchantmentType.ARMOR_TORSO, 1.7f, 1.2f, "X X", "XXX", "XXX"),
|
||||
LEGGINGS("leggings", "Beinschutz", "Hose", 15, 2, EnchantmentType.ARMOR_LEGS, 1.6f, 1.1f, "XXX", "X X", "X X"),
|
||||
BOOTS("boots", "Stiefel", "Stiefel", 13, 3, EnchantmentType.ARMOR_FEET, 1.4f, 1.0f, "X X", "X X"),
|
||||
HORSE_ARMOR("horse_armor", "Pferderüstung", ItemType.ANIMAL, 16, "X X", "XXX", "XXX");
|
||||
|
||||
public static final int ARMOR_SLOTS;
|
||||
public static final Equipment[] ARMOR;
|
||||
|
||||
private final String name;
|
||||
private final String display;
|
||||
private final String altDisplay;
|
||||
private final String[] recipe;
|
||||
private final ItemType type;
|
||||
private final int damage;
|
||||
private final int index;
|
||||
private final float phyResist;
|
||||
private final float magicResist;
|
||||
private final EnchantmentType enchType;
|
||||
|
||||
static {
|
||||
int slots = 0;
|
||||
for(Equipment slot : values()) {
|
||||
if(slot.index >= 0)
|
||||
++slots;
|
||||
}
|
||||
ARMOR_SLOTS = slots;
|
||||
ARMOR = new Equipment[slots];
|
||||
for(Equipment slot : values()) {
|
||||
if(slot.index >= 0)
|
||||
ARMOR[slot.index] = slot;
|
||||
}
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, String altDisplay, ItemType type, int damage, int index, EnchantmentType ench, float phy, float mag, String ... recipe) {
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
this.altDisplay = altDisplay;
|
||||
this.type = type;
|
||||
this.damage = damage;
|
||||
this.recipe = recipe;
|
||||
this.index = index;
|
||||
this.phyResist = phy;
|
||||
this.magicResist = mag;
|
||||
this.enchType = ench;
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, ItemType type, int damage, String ... recipe) {
|
||||
this(name, display, null, type, damage, -1, null, 0.0f, 0.0f, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, ItemType type, String ... recipe) {
|
||||
this(name, display, type, -1, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, String altDisplay, int damage, int index, EnchantmentType ench, float rad, float mag, String ... recipe) {
|
||||
this(name, display, altDisplay, ItemType.ARMOR, damage, index, ench, rad, mag, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float rad, float mag, String ... recipe) {
|
||||
this(name, display, null, ItemType.AUX, damage, index, ench, rad, mag, recipe);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public String getDisplay(String prefix, boolean alt) {
|
||||
String display = alt && this.altDisplay != null ? this.altDisplay : this.display;
|
||||
return prefix == null ? display : prefix + display.toLowerCase();
|
||||
}
|
||||
|
||||
public boolean canRegister(ToolMaterial material) {
|
||||
return this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras()) : (this.isMelee() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools()));
|
||||
}
|
||||
|
||||
public ItemType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isLevelled() {
|
||||
return this.type == ItemType.LEVELLED;
|
||||
}
|
||||
|
||||
public boolean isMelee() {
|
||||
return this.type == ItemType.MELEE;
|
||||
}
|
||||
|
||||
public boolean isOptional() {
|
||||
return this.type == ItemType.OPTIONAL;
|
||||
}
|
||||
|
||||
public boolean isArmor() {
|
||||
return this.type == ItemType.ARMOR || this.type == ItemType.AUX || this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
public boolean isArmorRendered() {
|
||||
return this.type == ItemType.ARMOR || this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
public boolean isAnimalArmor() {
|
||||
return this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
public String[] getRecipe() {
|
||||
return this.recipe;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public float getPhysicalResistance() {
|
||||
return this.phyResist;
|
||||
}
|
||||
|
||||
public float getMagicalResistance() {
|
||||
return this.magicResist;
|
||||
}
|
||||
|
||||
public EnchantmentType getEnchantmentType() {
|
||||
return this.enchType;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package common.util;
|
||||
|
||||
public enum HarvestTool implements Displayable {
|
||||
PICKAXE("Spitzhacke", true, 2),
|
||||
AXE("Axt", 3),
|
||||
SHOVEL("Schaufel", 1),
|
||||
SHEARS("Schere"),
|
||||
SWORD("Schwert", 4, true);
|
||||
|
||||
private final String display;
|
||||
private final boolean levelled;
|
||||
private final boolean melee;
|
||||
private final int damage;
|
||||
|
||||
private HarvestTool(String display, boolean levelled, int damage, boolean melee) {
|
||||
this.display = display;
|
||||
this.levelled = levelled;
|
||||
this.damage = damage;
|
||||
this.melee = melee;
|
||||
}
|
||||
|
||||
private HarvestTool(String display, boolean levelled, int damage) {
|
||||
this(display, levelled, damage, false);
|
||||
}
|
||||
|
||||
private HarvestTool(String display, int damage, boolean melee) {
|
||||
this(display, false, damage, melee);
|
||||
}
|
||||
|
||||
private HarvestTool(String display, int damage) {
|
||||
this(display, false, damage, false);
|
||||
}
|
||||
|
||||
private HarvestTool(String display) {
|
||||
this(display, false, -1, false);
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public boolean isLevelled() {
|
||||
return this.levelled;
|
||||
}
|
||||
|
||||
public boolean isMelee() {
|
||||
return this.melee;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
}
|
5
common/src/main/java/common/util/ItemType.java
Normal file
5
common/src/main/java/common/util/ItemType.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package common.util;
|
||||
|
||||
public enum ItemType {
|
||||
TOOL, LEVELLED, OPTIONAL, MELEE, ARMOR, AUX, ANIMAL;
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.util.Equipment;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
|
@ -25,8 +26,9 @@ public class CommandClear extends Command {
|
|||
}
|
||||
else {
|
||||
((EntityNPC)entity).getExtendedInventory().clear();
|
||||
for(int z = 0; z < 5; z++) {
|
||||
((EntityNPC)entity).setItem(z, null);
|
||||
((EntityNPC)entity).setHeldItem(null);
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
((EntityNPC)entity).setArmor(slot, null);
|
||||
}
|
||||
}
|
||||
exec.log("Inventar von %s gelöscht", entity.getCommandName());
|
||||
|
|
|
@ -1101,7 +1101,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
{
|
||||
if(this.onPlayerInteract(true, pos)) {
|
||||
this.sendPacket(new SPacketBlockChange(this.entity.worldObj, pos));
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().isEmpty())
|
||||
if(this.entity.getHeldItem() != null && this.entity.getHeldItem().isEmpty())
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
return;
|
||||
|
@ -1211,7 +1211,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
ItemStack itemstack1 = this.entity.getCurrentEquippedItem();
|
||||
ItemStack itemstack1 = this.entity.getHeldItem();
|
||||
boolean flag = this.entity.canHarvestBlock(iblockstate.getBlock());
|
||||
|
||||
if (itemstack1 != null)
|
||||
|
@ -1323,7 +1323,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
|
||||
private boolean onPlayerInteract(boolean primary, BlockPos pos) {
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().getItem().onAction(this.entity.getCurrentEquippedItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
if(this.entity.getHeldItem() != null && this.entity.getHeldItem().getItem().onAction(this.entity.getHeldItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -2634,7 +2634,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
break;
|
||||
|
||||
case ITEM_ACTION:
|
||||
ItemStack item = this.entity.getCurrentEquippedItem();
|
||||
ItemStack item = this.entity.getHeldItem();
|
||||
if(item != null) {
|
||||
item.getItem().onAction(item, this.entity, this.entity.worldObj,
|
||||
ItemControl.values()[packetIn.getAuxData() % ItemControl.values().length], null);
|
||||
|
@ -2703,8 +2703,8 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(this.entity.getCurrentEquippedItem() != null) {
|
||||
ItemStack stack = this.entity.getCurrentEquippedItem();
|
||||
else if(this.entity.getHeldItem() != null) {
|
||||
ItemStack stack = this.entity.getHeldItem();
|
||||
stack.setSize(stack.getMaxStackSize());
|
||||
stack.setRepairCost(0);
|
||||
if(stack.getItem().getMaxDamage() > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue