Skip to content

Commit

Permalink
add a new weapon and add new character
Browse files Browse the repository at this point in the history
  • Loading branch information
huige233 committed Apr 17, 2022
1 parent bfd2b7d commit 76ed2c7
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 27 deletions.
34 changes: 31 additions & 3 deletions src/main/java/huige233/transcend/compat/PsiCompat.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package huige233.transcend.compat;

import huige233.transcend.init.ModItems;
import huige233.transcend.lib.TranscendDamageSources;
import huige233.transcend.util.ArmorUtils;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.EnumHand;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.psi.api.PsiAPI;
Expand All @@ -22,15 +27,38 @@ public static void onPlayerAttack(EntityPlayer player, EntityPlayer attacker) {
if(cadItem != null && cadItem.getItem() instanceof ICAD) {
ICAD cad = (ICAD) cadItem.getItem();
int storedPsi = cad.getStoredPsi(cadItem);
// data.deductPsi(data.getAvailablePsi() + storedPsi, cd, true);
data.deductPsi(data.getAvailablePsi() + storedPsi, 200, true);
}else {
// data.deductPsi(data.getAvailablePsi(), cd, true);
data.deductPsi(data.getAvailablePsi(), 200, true);
}

}



public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase player) {
if(player.world.isRemote) {return true;}
if(target instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) target;
if(ArmorUtils.fullEquipped(p)){
target.setHealth(target.getHealth()-4);
return true;
}
if(p.getHeldItem(EnumHand.MAIN_HAND)!=null && p.getHeldItem(EnumHand.MAIN_HAND).getItem()== ModItems.TRANSCEND_SWORD&&p.isHandActive()) {
return true;
}
}
EntityPlayer t = (EntityPlayer) target;
PlayerDataHandler.PlayerData data = PlayerDataHandler.get(t);
ItemStack cadItem = PsiAPI.getPlayerCAD(t);
if(cadItem != null && cadItem.getItem() instanceof ICAD) {
ICAD cad = (ICAD) cadItem.getItem();
int storedPsi = cad.getStoredPsi(cadItem);
data.deductPsi((data.getAvailablePsi() + storedPsi)*10, 2000, true);
}else {
data.deductPsi(data.getAvailablePsi()*10, 2000, true);
}
return true;
}

@SubscribeEvent
public static void onPsiRegen(RegenPsiEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public static boolean shouldHit(int level, Random rnd){
return false;
}
}
public static final DamageSource FLAWLESS = (new DamageSource("flawless")).setDamageIsAbsolute().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode().setMagicDamage().setExplosion();



public void onUserHurt(EntityLivingBase user, Entity attacker, int level){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/huige233/transcend/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ModItems {
public static final Item FLAWLESS_CHESTPLATE = new ArmorBase("flawless_chestplate", ARMOR_MATERIAL_FLAWLESS, 1, EntityEquipmentSlot.CHEST, Main.TranscendTab);
public static final Item FLAWLESS_LEGGINGS = new ArmorBase("flawless_leggings", ARMOR_MATERIAL_FLAWLESS, 2, EntityEquipmentSlot.LEGS, Main.TranscendTab);
public static final Item FLAWLESS_BOOTS = new ArmorBase("flawless_boots", ARMOR_MATERIAL_FLAWLESS, 2, EntityEquipmentSlot.FEET, Main.TranscendTab);
public static final ToolMaterial transcend_tool = EnumHelper.addToolMaterial("TRANSCEND",99,-1,9999,2147483647.0f,100000);
public static final ToolMaterial transcend_tool = EnumHelper.addToolMaterial("TRANSCEND",99,-1,9999,9999.0f,100000);
public static final ItemSword TRANSCEND_SWORD = new ToolSword("transcend_sword",Main.TranscendTab,transcend_tool);
public static final ItemAxe TRANSCEND_AXE = new ToolAxe("transcend_axe",Main.TranscendTab,transcend_tool);
public static final ItemPickaxe TRANSCEND_PICKAXE = new ToolPickaxe("transcend_pickaxe",Main.TranscendTab,transcend_tool);
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/huige233/transcend/items/armor/ArmorBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package huige233.transcend.items.armor;

import com.google.common.collect.Collections2;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import huige233.transcend.Main;
import huige233.transcend.compat.PsiCompat;
import huige233.transcend.init.ModItems;
Expand All @@ -8,12 +12,16 @@
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.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
Expand All @@ -28,6 +36,8 @@
import org.jetbrains.annotations.NotNull;
import vazkii.psi.api.PsiAPI;

import java.util.List;

@Mod.EventBusSubscriber(modid = Reference.MOD_ID)
public class ArmorBase extends ItemArmor implements IHasModel {
public ArmorBase(String name, ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn, CreativeTabs tab) {
Expand Down Expand Up @@ -107,6 +117,10 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not
player.capabilities.allowFlying = true;
player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 14, false, false));
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 300, 14, false, false));
List<PotionEffect> effects = Lists.newArrayList(player.getActivePotionEffects());
for(PotionEffect potion : Collections2.filter(effects,potion -> potion.getPotion().isBadEffect())) {
player.removePotionEffect(potion.getPotion());
}
} else if (this.armorType == EntityEquipmentSlot.LEGS) {
player.getFoodStats().addStats(20, 20.0f);
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 300, 2, false, false));
Expand All @@ -115,9 +129,21 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not
player.setFire(0);
player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 300, 9, false, false));
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 300, 44, false, false));
if(player.isBurning()) {
player.extinguish();
}
} else if (ArmorUtils.fullEquipped(player)) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
fillModifiers(attributes);
player.getAttributeMap().applyAttributeModifiers(attributes);
}
}
}

private void fillModifiers(Multimap<String, AttributeModifier> attributes) {
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier( "transcend", 1000, 0).setSaved(false));
}

@SideOnly(Side.CLIENT)
public boolean hasEffect(@NotNull ItemStack stack) {
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/huige233/transcend/items/tools/ToolSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

import huige233.transcend.Main;
import huige233.transcend.init.ModItems;
import huige233.transcend.lib.TranscendDamageSources;
import huige233.transcend.util.ArmorUtils;
import huige233.transcend.util.IHasModel;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

import java.util.List;


public class ToolSword extends ItemSword implements IHasModel {
Expand All @@ -20,5 +32,26 @@ public ToolSword(String name, CreativeTabs tab,ToolMaterial material) {
public void registerModels() {
Main.proxy.registerItemRenderer(this,0,"inventory");
}

@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase player) {
if(player.world.isRemote) {return true;}
if(target instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) target;
if(ArmorUtils.fullEquipped(p)){
target.setHealth(target.getHealth()-4);
return true;
}
if(p.getHeldItem(EnumHand.MAIN_HAND) != null && p.getHeldItem(EnumHand.MAIN_HAND).getItem()==ModItems.TRANSCEND_SWORD&&p.isHandActive()) {
return true;
}
}
//target.recentlyHit = 60;
target.setHealth(0);
target.getCombatTracker().trackDamage(new TranscendDamageSources(player),target.getHealth(),target.getMaxHealth()*100);
target.onDeath(new EntityDamageSource("transcend",player));
return true;
}
}


36 changes: 22 additions & 14 deletions src/main/java/huige233/transcend/lib/TranscendDamageSources.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package huige233.transcend.lib;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
public class TranscendDamageSources {
public static final DamageSource FLAWLESS = (new DamageSource( "flawless" ) ).setDamageIsAbsolute().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode().setMagicDamage().setExplosion();
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;

public static class DamageFLAWLESS extends DamageSource {
public DamageFLAWLESS()
{
super("flawless");
setDamageAllowedInCreativeMode();
setDamageBypassesArmor();
setDamageIsAbsolute();
setMagicDamage();
setExplosion();
public class TranscendDamageSources extends EntityDamageSource{
public TranscendDamageSources(Entity source) {
super("flawless",source);
}
@Override
public ITextComponent getDeathMessage(EntityLivingBase entity) {
ItemStack itemstack = damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase) damageSourceEntity).getHeldItem(EnumHand.MAIN_HAND) : null;
String s = "death.attack.transcend";
int rando = entity.getEntityWorld().rand.nextInt(5);
if(rando != 0) {
s = s+ "." + rando;
}
return new TextComponentTranslation(s,entity.getDisplayName(),itemstack.getDisplayName());
}
public boolean isUnblockable()
{
return(true);
@Override
public boolean isDifficultyScaled() {
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/java/huige233/transcend/util/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.2";
public static final String VERSION = "1.0.3";
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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "transcend:item/transcend_axe"
"layer0": "transcend:items/transcend_axe"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "transcend:item/transcend_hoe"
"layer0": "transcend:items/transcend_hoe"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "transcend:item/transcend_pickaxe"
"layer0": "transcend:items/transcend_pickaxe"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "transcend:item/transcend_shovel"
"layer0": "transcend:items/transcend_shovel"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "transcend:item/transcend_sword"
"layer0": "transcend:items/transcend_sword"
}
}
Binary file modified src/main/resources/assets/transcend/textures/items/flawless.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "transcend",
"name": "transcend",
"description": "Tconstruct, an accessory, offers supermodel metal",
"version": "1.0.2",
"version": "1.0.3",
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",
Expand Down

0 comments on commit 76ed2c7

Please sign in to comment.