From 783d38b3cde1101f2a5d9f26f9e07d3a5b05569c Mon Sep 17 00:00:00 2001 From: huige <61108540+huige233@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:53:00 +0800 Subject: [PATCH] add any character and fix any bug also remove HIM --- build.gradle | 2 +- .../huige233/transcend/compat/PsiCompat.java | 4 --- .../huige233/transcend/init/ModItems.java | 1 - .../transcend/items/armor/ArmorBase.java | 33 ++++++++++++++++--- .../huige233/transcend/items/fireimmune.java | 2 +- .../transcend/items/tools/ToolPickaxe.java | 16 +++++++++ .../transcend/items/tools/ToolSword.java | 20 +++++++++++ .../huige233/transcend/proxy/CommonProxy.java | 3 +- .../huige233/transcend/util/Reference.java | 2 +- .../models/block/transcend_block.json | 2 +- .../models/item/transcend_block.json | 2 +- src/main/resources/mcmod.info | 2 +- 12 files changed, 72 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 1f23665..1da8997 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ apply plugin: "net.minecraftforge.gradle.forge" apply plugin: 'org.spongepowered.mixin' group = 'huige233' -version = '1.0.4' +version = '1.0.5' archivesBaseName = 'transcend' minecraft { diff --git a/src/main/java/huige233/transcend/compat/PsiCompat.java b/src/main/java/huige233/transcend/compat/PsiCompat.java index 2b412f1..4e7eaf0 100644 --- a/src/main/java/huige233/transcend/compat/PsiCompat.java +++ b/src/main/java/huige233/transcend/compat/PsiCompat.java @@ -13,12 +13,10 @@ import vazkii.psi.api.cad.RegenPsiEvent; import vazkii.psi.common.core.handler.PlayerDataHandler; -@Mod.EventBusSubscriber public class PsiCompat { public static boolean enabled = false; public static void onPlayerAttack(EntityPlayer player, EntityPlayer attacker) { - if (!enabled) return; if(player.world.isRemote) return; PlayerDataHandler.PlayerData data = PlayerDataHandler.get(attacker); ItemStack cadItem = PsiAPI.getPlayerCAD(attacker); @@ -34,7 +32,6 @@ public static void onPlayerAttack(EntityPlayer player, EntityPlayer attacker) { public void hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase player) { - if (!enabled) return; if(player.world.isRemote) {return;} if(target instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) target; @@ -60,7 +57,6 @@ public void hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase @SubscribeEvent public static void onPsiRegen(RegenPsiEvent event) { - if (!enabled) return; EntityPlayer player = event.getPlayer(); //if(player.world.isRemote) return; if(ArmorUtils.fullEquipped(player)){ diff --git a/src/main/java/huige233/transcend/init/ModItems.java b/src/main/java/huige233/transcend/init/ModItems.java index ce23451..40719fd 100644 --- a/src/main/java/huige233/transcend/init/ModItems.java +++ b/src/main/java/huige233/transcend/init/ModItems.java @@ -5,7 +5,6 @@ import huige233.transcend.items.armor.ArmorBase; import huige233.transcend.items.tools.*; import huige233.transcend.util.Reference; -import joptsimple.OptionSpec; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.*; diff --git a/src/main/java/huige233/transcend/items/armor/ArmorBase.java b/src/main/java/huige233/transcend/items/armor/ArmorBase.java index 41721c4..6415127 100644 --- a/src/main/java/huige233/transcend/items/armor/ArmorBase.java +++ b/src/main/java/huige233/transcend/items/armor/ArmorBase.java @@ -19,6 +19,7 @@ import net.minecraft.init.MobEffects; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; @@ -35,6 +36,7 @@ import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.UUID; @Mod.EventBusSubscriber(modid = Reference.MOD_ID) public class ArmorBase extends ItemArmor implements IHasModel { @@ -132,17 +134,38 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not } else if (ArmorUtils.fullEquipped(player)) { if(!player.world.isRemote) { Multimap attributes = HashMultimap.create(); - fillModifiers(attributes); - player.getAttributeMap().applyAttributeModifiers(attributes); if(attributes.isEmpty()) return; - attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier("Flawless", 1000, 0).setSaved(false)); + player.setHealth(player.getMaxHealth()); } } } - private void fillModifiers(Multimap attributes) { - attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier( "transcend", 1000, 0).setSaved(false)); + @Override + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { + Multimap attrib = super.getAttributeModifiers(slot, stack); + Item item = stack.getItem(); + UUID uuid = new UUID(slot.toString().hashCode(), 0); + if (slot == EntityEquipmentSlot.HEAD) { + if(item == ModItems.FLAWLESS_HELMET) { + attrib.put(SharedMonsterAttributes.LUCK.getName(), new AttributeModifier(uuid, "Flawless", 1000, 0)); + } + } else if (slot == EntityEquipmentSlot.CHEST) { + if(item == ModItems.FLAWLESS_CHESTPLATE) { + attrib.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(uuid, "Flawless", 1000, 0)); + } + } else if (slot == EntityEquipmentSlot.LEGS) { + if(item == ModItems.FLAWLESS_LEGGINGS) { + attrib.put(SharedMonsterAttributes.FOLLOW_RANGE.getName(), new AttributeModifier(uuid, "Flawless", 1000, 0)); + } + } else if (slot == EntityEquipmentSlot.FEET) { + if(item == ModItems.FLAWLESS_BOOTS) { + attrib.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(uuid, "Flawless", 0.2, 1)); + } + } else if(slot == armorType) { + attrib.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(uuid, "Flawless", 1000, 0)); + } + return attrib; } public boolean hasCustomEntity(ItemStack stack) { diff --git a/src/main/java/huige233/transcend/items/fireimmune.java b/src/main/java/huige233/transcend/items/fireimmune.java index b0ed1ac..11a902a 100644 --- a/src/main/java/huige233/transcend/items/fireimmune.java +++ b/src/main/java/huige233/transcend/items/fireimmune.java @@ -13,7 +13,7 @@ public class fireimmune extends EntityItem { public fireimmune(World world, Entity location, ItemStack stack) { this(world, location.posX, location.posY, location.posZ, stack); - this.setPickupDelay(20); + this.setPickupDelay(0); this.motionX = location.motionX; this.motionY = location.motionY; this.motionZ = location.motionZ; diff --git a/src/main/java/huige233/transcend/items/tools/ToolPickaxe.java b/src/main/java/huige233/transcend/items/tools/ToolPickaxe.java index bc86b35..f641ffd 100644 --- a/src/main/java/huige233/transcend/items/tools/ToolPickaxe.java +++ b/src/main/java/huige233/transcend/items/tools/ToolPickaxe.java @@ -1,5 +1,6 @@ package huige233.transcend.items.tools; +import com.google.common.collect.Multimap; import huige233.transcend.Main; import huige233.transcend.init.ModItems; import huige233.transcend.items.fireimmune; @@ -7,8 +8,11 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; +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.EnumRarity; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; @@ -17,6 +21,8 @@ import net.minecraft.util.EnumHand; import net.minecraft.world.World; +import java.util.UUID; + public class ToolPickaxe extends ItemPickaxe implements IHasModel { public ToolPickaxe(String name, CreativeTabs tab, ToolMaterial material) { super(material); @@ -50,6 +56,16 @@ public Entity createEntity(World world,Entity location, ItemStack itemstack) { return new fireimmune(world,location,itemstack); } + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { + Multimap attrib = super.getAttributeModifiers(slot, stack); + UUID uuid = new UUID((slot.toString()).hashCode(), 0); + if(slot == EntityEquipmentSlot.MAINHAND) { + attrib.put(EntityPlayer.REACH_DISTANCE.getName(), + new AttributeModifier(uuid,"Pickaxe modifier",256,0)); + } + return attrib; + } + public EnumRarity getRarity(ItemStack stack ) { return(ModItems.COSMIC_RARITY); diff --git a/src/main/java/huige233/transcend/items/tools/ToolSword.java b/src/main/java/huige233/transcend/items/tools/ToolSword.java index 9af713b..7ad28a0 100644 --- a/src/main/java/huige233/transcend/items/tools/ToolSword.java +++ b/src/main/java/huige233/transcend/items/tools/ToolSword.java @@ -1,21 +1,29 @@ package huige233.transcend.items.tools; +import com.google.common.collect.Multimap; import huige233.transcend.Main; import huige233.transcend.init.ModItems; import huige233.transcend.items.fireimmune; import huige233.transcend.lib.TranscendDamageSources; import huige233.transcend.util.ArmorUtils; import huige233.transcend.util.IHasModel; +import huige233.transcend.util.Reference; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; 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.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.EnumHand; import net.minecraft.world.World; +import javax.annotation.Nonnull; +import java.util.UUID; + public class ToolSword extends ItemSword implements IHasModel { public ToolSword(String name, CreativeTabs tab,ToolMaterial material) { @@ -58,6 +66,18 @@ public Entity createEntity(World world,Entity location, ItemStack itemstack) { return new fireimmune(world,location,itemstack); } + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { + Multimap attrib = super.getAttributeModifiers(slot, stack); + UUID uuid = new UUID((slot.toString()).hashCode(), 0); + if(slot == EntityEquipmentSlot.MAINHAND) { + attrib.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), + new AttributeModifier(uuid,"Weapon modifier",0.99,1)); + attrib.put(EntityPlayer.REACH_DISTANCE.getName(), + new AttributeModifier(uuid,"Weapon modifier",256,0)); + } + return attrib; + } + public EnumRarity getRarity(ItemStack stack ) { return(ModItems.COSMIC_RARITY); diff --git a/src/main/java/huige233/transcend/proxy/CommonProxy.java b/src/main/java/huige233/transcend/proxy/CommonProxy.java index 4656807..c269fed 100644 --- a/src/main/java/huige233/transcend/proxy/CommonProxy.java +++ b/src/main/java/huige233/transcend/proxy/CommonProxy.java @@ -3,6 +3,7 @@ import huige233.transcend.compat.Avartiabreak; import huige233.transcend.compat.PsiCompat; import net.minecraft.item.Item; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -21,7 +22,7 @@ public void preInit( FMLPreInitializationEvent event ) public void init( FMLInitializationEvent event ) { if(Loader.isModLoaded("psi")){ - PsiCompat.enabled = true; + MinecraftForge.EVENT_BUS.register(PsiCompat.class); } if(Loader.isModLoaded("avartia")) { Avartiabreak.enabled = true; diff --git a/src/main/java/huige233/transcend/util/Reference.java b/src/main/java/huige233/transcend/util/Reference.java index 4f0a469..ccc1b59 100644 --- a/src/main/java/huige233/transcend/util/Reference.java +++ b/src/main/java/huige233/transcend/util/Reference.java @@ -3,7 +3,7 @@ public class Reference { public static final String MOD_ID = "transcend"; public static final String NAME = "Transcend"; - public static final String VERSION = "1.0.4"; + public static final String VERSION = "1.0.5"; public static final String ACCEPTED_VERSIONS = "[1.12.2]"; public static final String CLIENT_PROXY_CLASS = "huige233.transcend.proxy.ClientProxy"; public static final String COMMON_PROXY_CLASS = "huige233.transcend.proxy.CommonProxy"; diff --git a/src/main/resources/assets/transcend/models/block/transcend_block.json b/src/main/resources/assets/transcend/models/block/transcend_block.json index 2aafe60..45c50c2 100644 --- a/src/main/resources/assets/transcend/models/block/transcend_block.json +++ b/src/main/resources/assets/transcend/models/block/transcend_block.json @@ -1,6 +1,6 @@ { "parent": "block/cube_all", "textures": { - "all": "transcend:block/transcend_block" + "all": "transcend:blocks/transcend_block" } } \ No newline at end of file diff --git a/src/main/resources/assets/transcend/models/item/transcend_block.json b/src/main/resources/assets/transcend/models/item/transcend_block.json index 3613656..2986ded 100644 --- a/src/main/resources/assets/transcend/models/item/transcend_block.json +++ b/src/main/resources/assets/transcend/models/item/transcend_block.json @@ -1,3 +1,3 @@ { - "parent" : "transcend:transcend_block" + "parent" : "transcend:block/transcend_block" } \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 0c685a9..68d6e34 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "transcend", "name": "transcend", "description": "Tconstruct, an accessory, offers supermodel metal", - "version": "1.0.4", + "version": "1.0.5", "mcversion": "1.12.2", "url": "", "updateUrl": "",