diff --git a/build.gradle b/build.gradle index 93edd80..d2a2776 100644 --- a/build.gradle +++ b/build.gradle @@ -85,7 +85,7 @@ repositories { } maven { url = "http://maven.cil.li/" } maven { url = "https://maven.ellpeck.de/" } - maven { url "https://www.cursemaven.com"} + maven { url ="https://www.cursemaven.com"} maven { name = 'GitHub Maven' url = "https://jitpack.io" diff --git a/src/main/java/huige233/transcend/blocks/voidblock.java b/src/main/java/huige233/transcend/blocks/voidblock.java index a0a9a19..51b2d18 100644 --- a/src/main/java/huige233/transcend/blocks/voidblock.java +++ b/src/main/java/huige233/transcend/blocks/voidblock.java @@ -5,6 +5,7 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.EnumBlockRenderType; @@ -64,4 +65,8 @@ public EnumBlockRenderType getRenderType(IBlockState state) { public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return Block.NULL_AABB; } + @Override + public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { + return false; + } } diff --git a/src/main/java/huige233/transcend/init/ModItems.java b/src/main/java/huige233/transcend/init/ModItems.java index f5bb81c..34c8044 100644 --- a/src/main/java/huige233/transcend/init/ModItems.java +++ b/src/main/java/huige233/transcend/init/ModItems.java @@ -3,6 +3,7 @@ import huige233.transcend.Main; import huige233.transcend.compat.ThaumcraftCompat; import huige233.transcend.items.ItemBase; +import huige233.transcend.items.ItemTranscendShield; import huige233.transcend.items.armor.ArmorBase; import huige233.transcend.items.tools.*; import huige233.transcend.util.Reference; @@ -53,4 +54,5 @@ public class ModItems { public static final ItemSword WARP_SWORD = new ToolWarp("warp_sword",Main.TranscendTab,warpsword); public static final ToolMaterial Invulnera = EnumHelper.addToolMaterial("Invulnera",0,0,1,-4,0); public static final ItemSword Invulnerable = new ItemInvulnerable("invulnerable",Invulnera); + public static final Item TRANSCEND_SHIELD = new ItemTranscendShield("transcend_shield",Main.TranscendTab); } diff --git a/src/main/java/huige233/transcend/items/ItemBase.java b/src/main/java/huige233/transcend/items/ItemBase.java index 1194c07..130465d 100644 --- a/src/main/java/huige233/transcend/items/ItemBase.java +++ b/src/main/java/huige233/transcend/items/ItemBase.java @@ -13,6 +13,7 @@ import net.minecraftforge.fml.common.Loader; public class ItemBase extends Item implements IHasModel { + private boolean isRangedWeapon = false; public ItemBase(String name, CreativeTabs tab) { setTranslationKey(name).setRegistryName(name).setCreativeTab(tab); ModItems.ITEMS.add(this); @@ -36,4 +37,10 @@ public EnumRarity getRarity(ItemStack stack ) return(ModItems.COSMIC_RARITY); } + public ItemBase setRangedWeapon() + { + isRangedWeapon = true; + return this; + } + } diff --git a/src/main/java/huige233/transcend/items/ItemTranscendShield.java b/src/main/java/huige233/transcend/items/ItemTranscendShield.java new file mode 100644 index 0000000..ca2d9c5 --- /dev/null +++ b/src/main/java/huige233/transcend/items/ItemTranscendShield.java @@ -0,0 +1,102 @@ +package huige233.transcend.items; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import huige233.transcend.items.tools.ItemAdapting; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Enchantments; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.EnumAction; +import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import javax.annotation.Nullable; +import java.util.UUID; + +public class ItemTranscendShield extends ItemAdapting { + protected static final UUID OFF_HAND_MODIFIER = UUID.fromString("9271eeea-5f74-4e12-97b6-7cf3c60ef7a0"); + protected static final UUID MAIN_HAND_MODIFIER = UUID.fromString("7d766720-0695-46c6-b320-44529f3da63f"); + public ItemTranscendShield(String name,CreativeTabs tab){ + super(name); + setRangedWeapon(); + setCreativeTab(tab); + useable = true; + this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() + { + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) + { + return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; + } + }); + } + public boolean isShield(ItemStack stack,EntityLivingBase entity){ + return true; + } + + public boolean hasCustomEntity(ItemStack stack) { + return true; + } + public EnumAction getItemUseAction(ItemStack stack) { + return EnumAction.BLOCK; + } + public int getMaxItemUseDuration(ItemStack stack){ + return 72000; + } + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + ItemStack itemStack = player.getHeldItem(hand); + player.setActiveHand(hand); + return new ActionResult<>(EnumActionResult.SUCCESS,itemStack); + } + @Override + public void onPlayerStoppedUsing(ItemStack stack,World world,EntityLivingBase entity,int timeLeft){ + + } + @Override + public int getMaxDamage(ItemStack stack) { + return 0; + } + public void setDamage(ItemStack stack, int damage) { + super.setDamage(stack, 0); + } + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { + if (enchantment == Enchantments.PUNCH || enchantment == Enchantments.INFINITY) + { + return false; + } + if (enchantment == Enchantments.POWER || enchantment == Enchantments.UNBREAKING) + { + return true; + } + return super.canApplyAtEnchantingTable(stack, enchantment); + } + public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) + { + Multimap multimap = HashMultimap.create(); + if (equipmentSlot == EntityEquipmentSlot.OFFHAND ) + { + multimap.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(OFF_HAND_MODIFIER, "Weapon modifier", (double)getPower(stack), 0)); + } + + if (equipmentSlot == EntityEquipmentSlot.MAINHAND) + { + multimap.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(MAIN_HAND_MODIFIER, "Weapon modifier", (double)getPower(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(MAIN_HAND_MODIFIER, "Weapon modifier", (double)getPower(stack) / 2f, 0)); + } + + return multimap; + } +} diff --git a/src/main/java/huige233/transcend/items/tools/ItemAdapting.java b/src/main/java/huige233/transcend/items/tools/ItemAdapting.java new file mode 100644 index 0000000..c8728bf --- /dev/null +++ b/src/main/java/huige233/transcend/items/tools/ItemAdapting.java @@ -0,0 +1,71 @@ +package huige233.transcend.items.tools; + +import huige233.transcend.Main; +import huige233.transcend.items.ItemBase; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Enchantments; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.world.World; + +public class ItemAdapting extends ItemBase { + protected boolean useable = false; + public ItemAdapting(String name){ + super(name, Main.TranscendTab); + } + public float getPower(ItemStack stack) { + return 999999f; + } + public float getRange(ItemStack stack) { + return 999999f; + } + public int getCoolDownTicks(ItemStack stack) { + return (int) 1; + } + + @Override + public int getMaxDamage(ItemStack stack) { + return 99999; + } + public int getMaxItemUseDuration(ItemStack stack){ + return 72000; + } + public EnumAction getItemUseAction(ItemStack stack){ + return EnumAction.BOW; + } + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { + if (enchantment == Enchantments.PUNCH || enchantment == Enchantments.INFINITY) + { + return false; + } + if (enchantment == Enchantments.POWER || enchantment == Enchantments.UNBREAKING) + { + return true; + } + return super.canApplyAtEnchantingTable(stack, enchantment); + } + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity,int timeLeft){ + if(!useable){ + return; + } + onCreatureStoppedUsing(stack,world,entity,timeLeft); + entity.swingArm(entity.getHeldItemMainhand() == stack ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND); + if(!world.isRemote){ + if(entity instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) entity; + { + p.getCooldownTracker().setCooldown(this,getCoolDownTicks(stack)); + } + } + } + } + public void onCreatureStoppedUsing(ItemStack stack,World world,EntityLivingBase entity,int timeLeft){ + + } +} diff --git a/src/main/resources/assets/transcend/lang/en_US.lang b/src/main/resources/assets/transcend/lang/en_US.lang index 2295bc8..b17c928 100644 --- a/src/main/resources/assets/transcend/lang/en_US.lang +++ b/src/main/resources/assets/transcend/lang/en_US.lang @@ -22,6 +22,7 @@ item.transcend_vis.name=Transcend Vis Ring item.warp_sword.name=Warp Sword item.transcend.sword.destruction.name=Transcend Sword (Destruction of posture) item.invulnerable.name=Invulnerable Tool +item.transcend_shield.name=Transcend Shield material.flawless.name=Flawless Alloy material.transcend.name=Transcend Alloy diff --git a/src/main/resources/assets/transcend/lang/zh_CN.lang b/src/main/resources/assets/transcend/lang/zh_CN.lang index a2e2f4a..d486a53 100644 --- a/src/main/resources/assets/transcend/lang/zh_CN.lang +++ b/src/main/resources/assets/transcend/lang/zh_CN.lang @@ -22,6 +22,7 @@ item.transcend_vis.name=超越魔力指环 item.warp_sword.name=扭曲之剑 item.transcend.sword.destruction.name=超越之剑(毁灭姿态) item.invulnerable.name=无敌工具 +item.transcend_shield.name=超越盾牌 material.flawless.name=完美合金 material.transcend.name=超越合金 diff --git a/src/main/resources/assets/transcend/models/item/transcend_shield.json b/src/main/resources/assets/transcend/models/item/transcend_shield.json new file mode 100644 index 0000000..ae5cea5 --- /dev/null +++ b/src/main/resources/assets/transcend/models/item/transcend_shield.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "transcend:items/transcend_shield" + } +} \ No newline at end of file