-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/java/huige233/transcend/items/ItemTranscendShield.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ItemStack> 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<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) | ||
{ | ||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>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; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/huige233/transcend/items/tools/ItemAdapting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/transcend/models/item/transcend_shield.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "transcend:items/transcend_shield" | ||
} | ||
} |