Skip to content

Commit

Permalink
new tool
Browse files Browse the repository at this point in the history
  • Loading branch information
huige233 committed Aug 5, 2022
1 parent 0acf5c1 commit 73191df
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/huige233/transcend/blocks/voidblock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions src/main/java/huige233/transcend/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
7 changes: 7 additions & 0 deletions src/main/java/huige233/transcend/items/ItemBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -36,4 +37,10 @@ public EnumRarity getRarity(ItemStack stack )
return(ModItems.COSMIC_RARITY);
}

public ItemBase setRangedWeapon()
{
isRangedWeapon = true;
return this;
}

}
102 changes: 102 additions & 0 deletions src/main/java/huige233/transcend/items/ItemTranscendShield.java
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 src/main/java/huige233/transcend/items/tools/ItemAdapting.java
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){

}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/transcend/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/transcend/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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=超越合金
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "transcend:items/transcend_shield"
}
}

0 comments on commit 73191df

Please sign in to comment.