Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrthomas20121 committed Sep 9, 2020
1 parent 45b3521 commit f3bbd32
Show file tree
Hide file tree
Showing 29 changed files with 612 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mrthomas20121.tinkers_reforged.Tools;
package mrthomas20121.tinkers_reforged.tools;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mrthomas20121.tinkers_reforged.Tools;
package mrthomas20121.tinkers_reforged.tools;

import mrthomas20121.tinkers_reforged.Module.ModuleTools;
import mrthomas20121.tinkers_reforged.modules.ModuleTools;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mrthomas20121.tinkers_reforged.Tools;
package mrthomas20121.tinkers_reforged.tools;

import mrthomas20121.tinkers_reforged.Module.ModuleTools;
import mrthomas20121.tinkers_reforged.modules.ModuleTools;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mrthomas20121.tinkers_reforged.Tools;
package mrthomas20121.tinkers_reforged.tools;

import mrthomas20121.tinkers_reforged.Module.ModuleTools;
import mrthomas20121.tinkers_reforged.modules.ModuleTools;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mrthomas20121.tinkers_reforged.Tools;
package mrthomas20121.tinkers_reforged.tools;

import epicsquid.mysticallib.util.ItemUtil;
import epicsquid.roots.config.MossConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void afterBlockBreak(ItemStack tool, World world, IBlockState state, Bloc
if(this.isToolWithTrait(tool)) {
NBTTagCompound nbt = tool.getTagCompound();
int durability = nbt.getInteger("Durability");
nbt.setInteger("Durability", durability+1);
nbt.setInteger("Durability", durability+10);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import slimeknights.tconstruct.library.modifiers.ModifierAspect;
import slimeknights.tconstruct.library.traits.AbstractTrait;

public class TraitEnderfestation extends AbstractTrait {
public TraitEnderfestation() {
super("enderfestation", 0x1D3D37);
this.aspects.add(ModifierAspect.harvestOnly);
}

@Override
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/mrthomas20121/tinkers_reforged/Traits/TraitFey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package mrthomas20121.tinkers_reforged.Traits;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
import slimeknights.tconstruct.library.modifiers.ModifierAspect;
import slimeknights.tconstruct.library.traits.AbstractTraitLeveled;

public class TraitFey extends AbstractTraitLeveled {
private int boost = 2;
public TraitFey()
{
super("ref_fey", 0x67AFAF, 3, 0);
this.aspects.add(ModifierAspect.harvestOnly);
}
@Override
public void miningSpeed(ItemStack tool, PlayerEvent.BreakSpeed event) {
float originalSpeed = event.getOriginalSpeed();
event.setNewSpeed(originalSpeed+ (boost+levels) );
}
@Override
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float newDamage, boolean isCritical) {
return newDamage+ (boost+levels);
}

@Override
public int onToolHeal(ItemStack tool, int amount, int newAmount, EntityLivingBase entity) {
return newAmount+ (boost+levels);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mrthomas20121.tinkers_reforged.Traits;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import slimeknights.tconstruct.library.traits.AbstractTrait;

public class TraitLiving extends AbstractTrait {
public TraitLiving()
{
super("ref_living", 0x0);
}

@Override
public void onBlock(ItemStack tool, EntityPlayer player, LivingHurtEvent event) {
if(player.getHealth() != player.getMaxHealth()) player.heal(2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package mrthomas20121.tinkers_reforged.Traits;

import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
import vazkii.botania.api.mana.ManaItemHandler;

public class TraitManaBoost extends AbstractTrait {
public TraitManaBoost()
{
super("ref_mana_boost", 0x0);
}

@Override
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float newDamage, boolean isCritical) {

int tempDamage = 0;

if(player instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer)player;
IBaublesItemHandler baubleInv = BaublesApi.getBaublesHandler(entityPlayer);;
NonNullList<ItemStack> manaStacks = entityPlayer.inventory.mainInventory;
for(ItemStack manaStack: manaStacks)
{
if(tool.isItemDamaged())
{
if(ManaItemHandler.requestManaExact(manaStack, entityPlayer, tool.getMaxDamage(), true)) tempDamage = 15;
}
}
int size = baubleInv.getSlots();
for(int slot = 0; slot < size; slot++)
{
ItemStack stackInSlot = baubleInv.getStackInSlot(slot);
if(!stackInSlot.isEmpty())
{
if(tool.isItemDamaged() && tempDamage == 0)
{
if(ManaItemHandler.requestManaExact(stackInSlot, entityPlayer, tool.getMaxDamage(), true)) tempDamage = 15;
}
}

}
}
if(tempDamage > 0) return newDamage+tempDamage;
return newDamage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package mrthomas20121.tinkers_reforged.Traits;

import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
import vazkii.botania.api.mana.ManaItemHandler;

import java.util.List;

public class TraitManaInfusion extends AbstractTrait {
public TraitManaInfusion()
{
super("ref_mana_infusion", 0x0);
}

@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
if(isSelected)
{
if(entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)entity;
IBaublesItemHandler baubleInv = BaublesApi.getBaublesHandler(player);;
NonNullList<ItemStack> manaStacks = player.inventory.mainInventory;
for(ItemStack manaStack: manaStacks)
{
if(tool.isItemDamaged())
{
if(ManaItemHandler.requestManaExact(manaStack, player, 100, true)) ToolHelper.repairTool(tool, 10);
}
}
int size = baubleInv.getSlots();
for(int slot = 0; slot < size; slot++)
{
ItemStack stackInSlot = baubleInv.getStackInSlot(slot);
if(!stackInSlot.isEmpty())
{
if(tool.isItemDamaged())
{
if(ManaItemHandler.requestManaExact(stackInSlot, player, 100, true)) ToolHelper.repairTool(tool, 10);
}
}

}

}
}
}
}
26 changes: 4 additions & 22 deletions src/main/java/mrthomas20121/tinkers_reforged/Traits/Traits.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,8 @@ public class Traits {
public static final TraitRose rose = new TraitRose();
public static final TraitCarbon carbon = new TraitCarbon();
public static final TraitCurse curse = new TraitCurse();

public static void preInit() {
MaterialBuilder.registerTrait(ender);
MaterialBuilder.registerTrait(enderfestation);
MaterialBuilder.registerTrait(signal);
MaterialBuilder.registerTrait(light);
MaterialBuilder.registerTrait(astral);
MaterialBuilder.registerTrait(AURA_INFUSION);
MaterialBuilder.registerTrait(radioactive);
MaterialBuilder.registerTrait(nuclearwaste);
MaterialBuilder.registerTrait(life_steal);
MaterialBuilder.registerTrait(pyromancy);
MaterialBuilder.registerTrait(refined);
MaterialBuilder.registerTrait(flux);
MaterialBuilder.registerTrait(starshaped);
MaterialBuilder.registerTrait(void_trait);
MaterialBuilder.registerTrait(starry_night);
MaterialBuilder.registerTrait(villager_love);
MaterialBuilder.registerTrait(rose);
MaterialBuilder.registerTrait(carbon);
MaterialBuilder.registerTrait(curse);
}
public static final TraitFey fey = new TraitFey();
public static final TraitManaInfusion traitManaInfusion = new TraitManaInfusion();
public static final TraitManaBoost traitManaBoost = new TraitManaBoost();
public static final TraitLiving traitLiving = new TraitLiving();
}
76 changes: 63 additions & 13 deletions src/main/java/mrthomas20121/tinkers_reforged/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package mrthomas20121.tinkers_reforged.proxy;

import mrthomas20121.tinkers_reforged.Client.TinkerBookTransformer;
import mrthomas20121.tinkers_reforged.Module.Materials;
import mrthomas20121.tinkers_reforged.Module.ModuleFluids;
import mrthomas20121.tinkers_reforged.Module.ModuleItems;
import mrthomas20121.tinkers_reforged.Module.Modules;
import mrthomas20121.tinkers_reforged.client.ModifiersTransformer;
import mrthomas20121.tinkers_reforged.client.ToolsTransformer;
import mrthomas20121.tinkers_reforged.modules.*;
import mrthomas20121.tinkers_reforged.TinkersReforged;

import mrthomas20121.tinkers_reforged.resources.Resource;
import mrthomas20121.tinkers_reforged.resources.Resources;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -22,8 +23,10 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import slimeknights.tconstruct.common.ModelRegisterUtil;
import slimeknights.tconstruct.library.TinkerRegistryClient;
import slimeknights.tconstruct.library.book.TinkerBook;
import slimeknights.tconstruct.library.materials.Material;
import slimeknights.tconstruct.library.client.ToolBuildGuiInfo;
import slimeknights.tconstruct.library.modifiers.IModifier;
import slimeknights.tconstruct.library.tools.IToolPart;
import slimeknights.tconstruct.library.tools.ToolCore;

Expand All @@ -38,25 +41,72 @@ public void preInit(FMLPreInitializationEvent e) {

@Override
public void init(FMLInitializationEvent e) {
this.registerBookData();
Modules.tools.init(e);
}

@SideOnly(Side.CLIENT)
@Override
public void postInit(FMLPostInitializationEvent event) {
TinkersReforged.logger.info("Client Stuff");
for (Material mat : Materials.mats) {
mat.setRenderInfo(mat.materialTextColor);
for (Resource resource : Resources.materials) {
if(!resource.getName().equals("kovar")) resource.builder().getMat().setRenderInfo(resource.getColor());
}
}
@Override
public <T extends Item & IToolPart> void registerToolPartModel(T part) {
ModelRegisterUtil.registerPartModel(part);
}
@Override
public void registerModifierModel(IModifier mod, ResourceLocation rl) {
ModelRegisterUtil.registerModifierModel(mod, rl);
}

@Override
public void registerToolCrafting()
{
if(ModuleTools.gladius != null)
{
ToolBuildGuiInfo gladiusGui = new ToolBuildGuiInfo(ModuleTools.gladius);
gladiusGui.addSlotPosition(33 - 20 - 1, 42 + 20);
gladiusGui.addSlotPosition(33 + 20 - 5, 42 - 20 + 4);
gladiusGui.addSlotPosition(33 - 2 - 1, 42 + 2);
TinkerRegistryClient.addToolBuilding(gladiusGui);
}
if(ModuleTools.knife != null)
{
ToolBuildGuiInfo runedKnifeGui = new ToolBuildGuiInfo(ModuleTools.knife);
runedKnifeGui.addSlotPosition(33 - 20 - 1, 42 + 20);
runedKnifeGui.addSlotPosition(33 + 20 - 5, 42 - 20 + 4);
runedKnifeGui.addSlotPosition(33 - 2 - 1, 42 + 2);
TinkerRegistryClient.addToolBuilding(runedKnifeGui);
}
if(ModuleTools.club != null)
{
ToolBuildGuiInfo clubGui = new ToolBuildGuiInfo(ModuleTools.club);
clubGui.addSlotPosition(33 - 20 - 1, 42 + 20);
clubGui.addSlotPosition(33 - 2 - 1, 42 + 2);
TinkerRegistryClient.addToolBuilding(clubGui);
}
if(ModuleTools.greatsword != null)
{
ToolBuildGuiInfo greatSwordGui = new ToolBuildGuiInfo(ModuleTools.greatsword);
greatSwordGui.addSlotPosition(33 - 20 - 1, 42 + 20);
greatSwordGui.addSlotPosition(33 + 20 - 5, 42 - 20 + 4);
greatSwordGui.addSlotPosition(33 - 2 - 1, 42 + 2);
TinkerRegistryClient.addToolBuilding(greatSwordGui);
}
if(ModuleTools.khopesh != null)
{
ToolBuildGuiInfo khopeshGui = new ToolBuildGuiInfo(ModuleTools.khopesh);
khopeshGui.addSlotPosition(33 - 20 - 1, 42 + 20);
khopeshGui.addSlotPosition(33 + 20 - 5, 42 - 20 + 4);
khopeshGui.addSlotPosition(33 - 2 - 1, 42 + 2);
TinkerRegistryClient.addToolBuilding(khopeshGui);
}
}

@Override
public void registerBookData() {
TinkerBook.INSTANCE.addTransformer(new TinkerBookTransformer());
TinkerBook.INSTANCE.addTransformer(new ToolsTransformer());
TinkerBook.INSTANCE.addTransformer(new ModifiersTransformer());
}

@Override
Expand All @@ -65,7 +115,7 @@ public void registerToolModel(ToolCore tc) {
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
TinkersReforged.logger.info("Loading Model");
TinkersReforged.getLogger().info("Loading Model");
ArrayList<Item> items = ModuleItems.genArrayList();
for(Item item : items) {
ModelLoader.setCustomModelResourceLocation(item, 0 , new ModelResourceLocation(item.getRegistryName(), "inventory"));
Expand Down
Loading

0 comments on commit f3bbd32

Please sign in to comment.