Skip to content

Commit

Permalink
An epic enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
huige233 committed Sep 4, 2022
1 parent 4b3f71d commit b699454
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class TiCConfig {
public static final AbstractTrait flawlesstrait = new TraitFlawless();
public static final AbstractTrait transcendtratt = new TraitTranscend();
public static final List<Material> materials = Lists.newArrayList();
public static Material flawless = mat("flawless", 0xfffff);
public static Material flawless = mat("flawless", 0x777777);
public static final Material transcend = mat("transcend",0x9e9e9e9);
private static Material mat(String name, int color) {
if (TinkerRegistry.getMaterial(name) == TinkerRegistry.getMaterial("unknown")){
Expand Down Expand Up @@ -109,7 +109,7 @@ public void postInit(FMLPostInitializationEvent event) {
@SideOnly(Side.CLIENT)
static void registerMaterialRendering()
{
flawless.setRenderInfo(new MaterialRenderInfo.Metal(0xffffff, 0.5f, 0.5f, 0.2f));
flawless.setRenderInfo(new MaterialRenderInfo.Metal(0x777777, 0.5f, 0.5f, 0.2f));
transcend.setRenderInfo(new MaterialRenderInfo.Metal(0x9e9e9e, 0.5f, 0.5f, 0.2f));
}
}
Expand Down
35 changes: 29 additions & 6 deletions src/main/java/huige233/transcend/items/armor/ArmorBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
Expand Down Expand Up @@ -140,16 +143,36 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not
if(player.isBurning()) {
player.extinguish();
}
} else if (ArmorUtils.fullEquipped(player)) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
if(attributes.isEmpty()) return;
player.setEntityInvulnerable(true);
player.setHealth(player.getMaxHealth());
}
if (ArmorUtils.fullEquipped(player)) {
player.setEntityInvulnerable(true);
player.setHealth(player.getMaxHealth());
if(player.getHeldItemMainhand().getItem()==ModItems.TRANSCEND_SWORD){
if(!ItemNBTHelper.getBoolean(player.getHeldItem(EnumHand.MAIN_HAND),"Invul",false)){
ItemNBTHelper.setBoolean(player.getHeldItem(EnumHand.MAIN_HAND),"Invul",true);
}
}
} else if(!ArmorUtils.fullEquipped(player)) {
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.TRANSCEND_SWORD) {
if (ItemNBTHelper.getBoolean(player.getHeldItem(EnumHand.MAIN_HAND), "Invul", false)) {
NonNullList<ItemStack> armor = player.inventory.armorInventory;
armor.set(3, new ItemStack(ModItems.FLAWLESS_HELMET));
armor.set(2, new ItemStack(ModItems.FLAWLESS_CHESTPLATE));
armor.set(1, new ItemStack(ModItems.FLAWLESS_LEGGINGS));
armor.set(0, new ItemStack(ModItems.FLAWLESS_BOOTS));
}
}
}
}

@SubscribeEvent
public void onPlayerRender(RenderPlayerEvent.Pre event){
EntityPlayer player = event.getEntityPlayer();
if(ArmorUtils.fullEquipped(player)){
event.setCanceled(true);
}
}

@Override
public Multimap<String,AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
Multimap<String, AttributeModifier> attrib = super.getAttributeModifiers(slot, stack);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/huige233/transcend/items/tools/ToolPickaxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import huige233.transcend.util.ArmorUtils;
import huige233.transcend.util.IHasModel;
import huige233.transcend.util.Reference;
import morph.avaritia.handler.AvaritiaEventHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
Expand All @@ -26,7 +24,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
Expand All @@ -35,6 +32,9 @@
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;

import java.util.Random;
import java.util.UUID;
Expand All @@ -49,6 +49,8 @@ public ToolPickaxe(String name, CreativeTabs tab, ToolMaterial material) {
ModItems.ITEMS.add(this);
}

private int tick = 0;

@Override
public void registerModels() {
Main.proxy.registerItemRenderer(this, 0, "inventory");
Expand All @@ -68,6 +70,7 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
return new ActionResult(EnumActionResult.PASS, stack);
}


@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) {
World world = player.world;
Expand Down
83 changes: 55 additions & 28 deletions src/main/java/huige233/transcend/items/tools/ToolSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import huige233.transcend.items.fireimmune;
import huige233.transcend.lib.TranscendDamageSources;
import huige233.transcend.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
Expand All @@ -19,26 +20,23 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.jetbrains.annotations.NotNull;
import vazkii.botania.api.mana.ICreativeManaProvider;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaTooltipDisplay;

import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -66,11 +64,13 @@ public ToolSword(String name, CreativeTabs tab, ToolMaterial material) {
}

public void getSubItems(@NotNull CreativeTabs tab, @NotNull NonNullList<ItemStack> stack) {
if(tab == Main.TranscendTab && Loader.isModLoaded("botania")) {
ItemStack create = new ItemStack(ModItems.TRANSCEND_SWORD);
setMana(create, MAX_MANA);
setStackCreative(create);
stack.add(create);
if(tab == Main.TranscendTab){
if(Loader.isModLoaded("botania")) {
ItemStack create = new ItemStack(ModItems.TRANSCEND_SWORD);
setMana(create, MAX_MANA);
setStackCreative(create);
stack.add(create);
}
}
}

Expand All @@ -85,6 +85,20 @@ public boolean hasEffect(@NotNull ItemStack par1ItemStack) {
return false;
}

@SubscribeEvent
public void onClientTick(ClientTickEvent event){
EntityPlayer player = Minecraft.getMinecraft().player;
if(ArmorUtils.fullEquipped(player)){
if(player.isDead){
player.isDead=false;
}
if(!player.world.playerEntities.contains(player)){
player.world.playerEntities.add(player);
player.world.onEntityAdded(player);
}
}
}

public boolean hitEntity(@NotNull ItemStack stack, @NotNull EntityLivingBase target, EntityLivingBase player) {
if (!player.world.isRemote) {
if (target instanceof EntityPlayer) {
Expand Down Expand Up @@ -119,45 +133,58 @@ public boolean hitEntity(@NotNull ItemStack stack, @NotNull EntityLivingBase tar
@Override
public boolean onLeftClickEntity(@NotNull ItemStack stack, @NotNull EntityPlayer player, Entity entity) {
if(!entity.world.isRemote) {
if(ItemNBTHelper.getBoolean(stack, "Destruction", false)) {
entity.setEntityInvulnerable(false);
entity.onKillCommand();
entity.isDead = true;
entity.hurtResistantTime=0;;
}
if(entity instanceof EntityPlayer) {
EntityPlayer t = (EntityPlayer) entity;
if(t.capabilities.isCreativeMode && !t.isDead && !ArmorUtils.fullEquipped(t)) {
if(!ArmorUtils.fullEquipped(t)) {
t.clearActivePotions();
t.inventory.dropAllItems();
t.attackEntityFrom((new TranscendDamageSources(player)).setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(), Float.MAX_VALUE);
t.setHealth(0);
t.onDeath(new EntityDamageSource("transcend", player));
return true;
} else {
EntityLivingBase en = (EntityLivingBase) entity;
en.setHealth(0.0f);
en.clearActivePotions();
en.attackEntityFrom((new TranscendDamageSources(player)).setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(), Float.MAX_VALUE);
en.onDeath(new EntityDamageSource("transcend",player));
}
}
if(ItemNBTHelper.getBoolean(stack, "Destruction", false)) {
if(entity instanceof EntityPlayer){
SwordUtil.killPlayer((EntityPlayer) entity,player);
} else if (entity instanceof EntityLivingBase) {
SwordUtil.killEntityLiving((EntityLivingBase) entity,player);
} else{
SwordUtil.killEntity(entity);
}
entity.onKillCommand();
}
}
return false;
}



@Override
public @NotNull ActionResult<ItemStack> onItemRightClick(@NotNull World world, EntityPlayer player, @NotNull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(player.isSneaking()) {
NBTTagCompound tags = stack.getTagCompound();
boolean destruction = ItemNBTHelper.getBoolean(stack,"Destruction",false);
if(tags == null) {
ItemNBTHelper.setBoolean(stack,"Destruction",false);
stack.setStackDisplayName(TextFormatting.RED + stack.getDisplayName());
} else {
if(!destruction) {
ItemNBTHelper.setBoolean(stack,"Destruction",true);
if(!world.isRemote) {
if (!player.isSneaking()) {
boolean destruction = ItemNBTHelper.getBoolean(stack, "Destruction", false);
if (!destruction) {
ItemNBTHelper.setBoolean(stack, "Destruction", true);
stack.setStackDisplayName(TextFormatting.RED + I18n.translateToLocal("item.transcend.sword.destruction.name"));
player.swingArm(hand);
} else {
ItemNBTHelper.setBoolean(stack,"Destruction",false);
ItemNBTHelper.setBoolean(stack, "Destruction", false);
stack.setStackDisplayName(TextFormatting.RED + I18n.translateToLocal("item.transcend_sword.name"));
player.swingArm(hand);
}
} else if (player.isSneaking()) {
if (ItemNBTHelper.getBoolean(stack, "Destruction", false)) {
int count = SwordUtil.killRangeEntity(world, player);
player.sendMessage(new TextComponentTranslation("transcend.sword.ranger_kill", 50, count));
}
}
}
return super.onItemRightClick(world, player, hand);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/huige233/transcend/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public void registerItemRenderer( Item item, int meta, String id )
public void preInit( FMLPreInitializationEvent event )
{
if(Loader.isModLoaded("tconstruct")){
TiCConfig.setup();
}
TiCConfig.setup();
}
}


public void init( FMLInitializationEvent event )
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/huige233/transcend/util/SwordUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package huige233.transcend.util;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;

import java.util.List;

public class SwordUtil {
public static void killPlayer(EntityPlayer player, EntityLivingBase source){
ItemStack stack = source.getHeldItem(EnumHand.MAIN_HAND);
player.inventory.clearMatchingItems(null,-1,-1,null);
InventoryEnderChest ec = player.getInventoryEnderChest();
for(int i = 0;i < ec.getSizeInventory();i++){
ec.removeStackFromSlot(i);
}
player.inventory.dropAllItems();
DamageSource ds = source == null ? new DamageSource("infinity") :new EntityDamageSource("infinity",source);
DamageSource ds1 = source == null ? new DamageSource("transcend") :new EntityDamageSource("transcend",source);
player.getCombatTracker().trackDamage(ds,Float.MIN_VALUE,Float.MAX_VALUE);
player.getCombatTracker().trackDamage(ds1,Float.MIN_VALUE,Float.MAX_VALUE);
player.setHealth(0.0f);
player.onDeath(ds);
player.isDead=true;
}
public static void killEntityLiving(EntityLivingBase entity,EntityLivingBase source){
if(!(entity.world.isRemote || entity.isDead || entity.getHealth()==0.0f)){
entity.setEntityInvulnerable(false);
DamageSource ds = source == null ? new DamageSource("infinity") :new EntityDamageSource("infinity",source);
DamageSource ds1 = source == null ? new DamageSource("transcend") :new EntityDamageSource("transcend",source);
entity.getCombatTracker().trackDamage(ds,Float.MAX_VALUE,Float.MAX_VALUE);
entity.getCombatTracker().trackDamage(ds1,Float.MIN_VALUE,Float.MAX_VALUE);
entity.setHealth(0.0f);
entity.isDead=true;
}
}
public static void killEntity(Entity entity){
entity.setDead();
}
public static int killRangeEntity(World world,EntityLivingBase entity){
int range = 50;
List<Entity> list = world.getEntitiesWithinAABB(EntityLivingBase.class,new AxisAlignedBB(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range));
list.removeIf(en -> en instanceof EntityPlayer || en instanceof EntityArmorStand || en instanceof EntityAmbientCreature || (en instanceof EntityCreature && !(en instanceof EntityMob)));
list.remove(entity);
for(Entity en : list) {
if(en instanceof EntityPlayer){
killPlayer((EntityPlayer) en,entity);
}else if(en instanceof EntityLivingBase){
killEntityLiving((EntityLivingBase) en,entity);
} else {
killEntity((Entity) en);
}
}
return list.size();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/transcend/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tooltip.warp_sword1.desc=Should need Thaumcraft can use it
tooltip.warp_sword2.desc=Warp Power has been unsealed
tooltip.invulnerable=This tool can modify entity invincible attribute, hit entity will be invincible/uninvincible
tooltip.TimeStop=This tool can Stop the entity time,hit entity will be stop/unstop it time

transcend.sword.ranger_kill=Dealt a critical blow to %2$d creatures in %1$d blocks
message.bedrock_ore_failed= "You failed to break the bedrock"

death.attack.transcend=%s A power beyond all things will wipe you out
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/transcend/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tooltip.warp_sword2.desc=扭曲的力量已经解封
tooltip.invulnerable=本工具可以修改实体的无敌属性,被击中的实体将会无敌/取消无敌
tooltip.TimeStop=This tool can Stop the entity time,hit entity will be stop/unstop it time
message.bedrock_ore_failed="挖掘基岩矿石失败"

transcend.sword.ranger_kill=对%1$d方块内的%2$d个生物造成了致命打击
death.attack.transcend=%s被超越万物的力量粉碎
tip.transcend=Infinity
container.cast_machine=基岩冶炼厂
Expand Down

0 comments on commit b699454

Please sign in to comment.