[1.2] Material rework (#60)

* Developement tests for nbt data in traits

* Lot of trait changes and better balancing

* Traits reworked a bit, new traits added.

* First correction of NBT Data in Trait (Soulbound). Is shown twice. Still needs corrections.

* Few fixes in traits and new trait "catcher"

* Small fix, needs workaround

* fixed some catch issues

* Fixed Catcher and Reviving Traits, new Trait: Souleater. Updated build.gradle for new TiC Version.

* Splitted SoulEater to get the bad touch to an extra trait "Cursed". Added method for using nbt more easily. Changed declaration names of fluids

* Some minor changes in Traits, Registry and Utils.

* Iron_nugget is replaced with oreDict Item when not loaded via TAIGA.

* Beginning of new material  integration. Lot of names changed, lot more work to do here. Many null pointer exceptions and no changes of values up to now.

* Some Small changes in names, registry and recipes

* Some weird stuff I don't remember :D

* fixed some things I missed while merging

* Rollback to something

* More Stuff

* fixed some merging stuff

* Fixed some misspelled names. Actually working with lots of restrictions.

* Rearranged alloys, tried to add blocks / ingots for non-tinker-materials, but they won't work.

* Again tried to fix the melting issue, but non-tinker materials still are not able to be casted as a block, ingot or nugget...

* Fixed integration of materials without tools.

* changed IMC to direct lib calls

* removed more IMC, removed redundant code

* some reformatting

* Alloy integration reworked, needs to be balanced.

* updated deps, renamed some func's, added duplicate material check

* some more renaming

* some reformatting, fixed wrong import, fixed string cmp's

* Added images for blocks, ingots, nuggets and dust. Json changes do not work yet.

* some reformatting

* Removed old json files. Placeholder needed.

* Fixed block json, items not working yet.

* Fixed my own derp (missing json files)

* Reduced materials to ensure unique traits for most of them. Still 30 though, but reduced by 20 more :'( RIP

* Changed some generator stuff, not working properly right now!

* rewrote offset generation, added some debug command, fixed some stuff

* fixed on-surface-generation, made dependencies more flexible

* reverted gen-weight back to its normal value

* Meteor generator implemented.

* fixed generating on ground

* optimized a thing

* Replaced Uru with Osram, replaced Meteorite with Uru, added Meteorite again for Hull-Material and late game alloy.

* Some changes in generation of ores, not ready yet.

* Added Cobble Meteorite. Added debug command. Implemented rest of ore generation. Some minor fixes left for generation including balancing.

* Some changes for ore generation. Added 2 separate Generic Blocks for meteorite and their cobble variant.

* some cleanup in Generator class, added meteor world save handler

* Added Textures. Added blockstates and item models. Fixed fluid rendering.

* renamed world save data file to be little more specific, removed a unused method

* some preps for the upcoming release

* First attempt of well balancing material stats. Renamed TiberiumX to Triberium.

* Final changes... ready for beta testing

* Added missing alloys.

* Corrected balancing of ore generation. Still WIP

* removed some last debug out

* one last reformat
This commit is contained in:
Giovanni Harting
2016-12-05 20:34:02 +01:00
committed by GitHub
parent 9554b56931
commit 826ab1cf3a
625 changed files with 3540 additions and 3279 deletions

View File

@@ -0,0 +1,113 @@
package com.sosnitzka.taiga.traits;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.TagUtil;
import slimeknights.tconstruct.library.utils.TinkerUtil;
import slimeknights.tconstruct.library.utils.ToolHelper;
public class TraitCatcher extends AbstractTrait {
public static int chance = 1;
public static float costMulti = 0.25f;
public TraitCatcher() {
super(TraitCatcher.class.getSimpleName().toLowerCase().substring(5), TextFormatting.RED);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public void onHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean isCritical) {
World w = player.worldObj;
if (!w.isRemote && random.nextInt((int) target.getMaxHealth()) <= chance && target instanceof EntityLiving) {
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Data data = Data.read(tag);
if (data.mobClass.isEmpty()) {
data.mobClass = target.getClass().getName();
data.mobName = target.getName();
data.write(tag);
TagUtil.setEnchantEffect(tool, true);
TagUtil.setExtraTag(tool, tag);
player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
target.setDropItemsWhenDead(false);
target.setDead();
}
}
}
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
World w = event.getWorld();
BlockPos pos = event.getEntityPlayer().getPosition();
ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Data data = Data.read(tag);
if (!data.mobClass.isEmpty()) {
Entity ent = null;
try {
ent = (Entity) Class.forName(data.mobClass).getConstructor(World.class).newInstance(w);
} catch (Exception e) {
System.out.println(e.toString());
}
if (ent != null) {
ent.setPosition(pos.getX(), pos.getY(), pos.getZ()); // TODO: set to player view target
w.spawnEntityInWorld(ent);
event.getEntityPlayer().playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
data.mobClass = "";
data.mobName = "";
data.write(tag);
TagUtil.setExtraTag(tool, tag);
TagUtil.setEnchantEffect(tool, false);
ToolHelper.damageTool(tool, random.nextInt((int) (ToolHelper.getCurrentDurability(tool) * costMulti)), event.getEntityPlayer());
}
}
}
}
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent e) {
ItemStack tool = e.getItemStack();
if (TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Data data = Data.read(tag);
if (!data.mobClass.isEmpty())
e.getToolTip().add(TextFormatting.DARK_PURPLE + "Captured: " + TextFormatting.LIGHT_PURPLE + data.mobName);
}
}
public static class Data {
String mobClass;
String mobName;
public static Data read(NBTTagCompound tag) {
Data data = new Data();
data.mobName = tag.getString("mobName");
data.mobClass = tag.getString("mobClass");
return data;
}
public void write(NBTTagCompound tag) {
tag.setString("mobClass", mobClass);
tag.setString("mobName", mobName);
}
}
}