Skip to content

Commit

Permalink
slimeBoots and slimeSling (#93)
Browse files Browse the repository at this point in the history
* slimeBoots and slimeSling

* changed items directories and some code
* slime sling now with durability (100)
* boots now reduce bounce instead of increasing it
* added vanilla recipes

* fix slimeSling and Slime Boots
* removed debug logs
* Reduced bounce distance to 20 blocks (up or away)
* small fixes
* structural recovery as was
* add 100 durability to slime sling and slime boots
* bs
  • Loading branch information
Quetz4l authored Sep 9, 2023
1 parent 9120091 commit f7c6a9e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 114 deletions.
14 changes: 7 additions & 7 deletions src/main/java/tconstruct/TConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
Expand Down Expand Up @@ -160,9 +166,6 @@ public void preInit(FMLPreInitializationEvent event) {
pulsar.registerPulse(new TinkerUBC());
pulsar.registerPulse(new TinkerGears());
pulsar.registerPulse(new TinkerRfTools());
/*
* pulsar.registerPulse(new TinkerPrayers()); pulsar.registerPulse(new TinkerCropify());
*/

TConstructRegistry.materialTab = new TConstructCreativeTab("TConstructMaterials");
TConstructRegistry.toolTab = new TConstructCreativeTab("TConstructTools");
Expand All @@ -176,10 +179,7 @@ public void preInit(FMLPreInitializationEvent event) {
basinCasting = new LiquidCasting();
chiselDetailing = new Detailing();

// GameRegistry.registerFuelHandler(content);

playerTracker = new TPlayerHandler();
// GameRegistry.registerPlayerTracker(playerTracker);
FMLCommonHandler.instance().bus().register(playerTracker);
MinecraftForge.EVENT_BUS.register(playerTracker);
NetworkRegistry.INSTANCE.registerGuiHandler(TConstruct.instance, proxy);
Expand Down
65 changes: 32 additions & 33 deletions src/main/java/tconstruct/armor/TinkerArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,51 @@
import java.util.EnumSet;

import net.minecraft.block.Block;
import net.minecraft.init.*;
import net.minecraft.item.*;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.ShapedOreRecipe;

import cpw.mods.fml.common.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
import mantle.pulsar.pulse.*;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import tconstruct.TConstruct;
import tconstruct.armor.blocks.DryingRack;
import tconstruct.armor.items.*;
import tconstruct.armor.items.ArmorBasic;
import tconstruct.armor.items.DiamondApple;
import tconstruct.armor.items.HeartCanister;
import tconstruct.armor.items.Jerky;
import tconstruct.armor.items.Knapsack;
import tconstruct.armor.items.TravelBelt;
import tconstruct.armor.items.TravelGear;
import tconstruct.armor.items.TravelGlove;
import tconstruct.armor.items.TravelWings;
import tconstruct.blocks.logic.DryingRackLogic;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.accessory.AccessoryCore;
import tconstruct.library.armor.ArmorPart;
import tconstruct.library.crafting.*;
import tconstruct.library.crafting.DryingRackRecipes;
import tconstruct.library.crafting.LiquidCasting;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.modifiers.accessory.GloveSpeed;
import tconstruct.modifiers.armor.*;
import tconstruct.modifiers.armor.AModBoolean;
import tconstruct.modifiers.armor.AModInteger;
import tconstruct.modifiers.armor.AModLeadBoots;
import tconstruct.modifiers.armor.ActiveTinkerArmor;
import tconstruct.modifiers.armor.TravelModDoubleJump;
import tconstruct.modifiers.armor.TravelModRepair;
import tconstruct.modifiers.tools.ModAttack;
import tconstruct.tools.TinkerTools;
import tconstruct.world.TinkerWorld;
Expand All @@ -39,8 +61,6 @@ public class TinkerArmor {

public static Item diamondApple;
public static Item jerky;
// public static Item stonePattern;
// public static Item netherPattern;
public static Block dryingRack;
// Wearables
/*
Expand Down Expand Up @@ -84,18 +104,9 @@ public void preInit(FMLPreInitializationEvent event) {
GameRegistry.registerItem(TinkerArmor.jerky, "jerky");

// Wearables
// heavyHelmet = new TArmorBase(PHConstruct.heavyHelmet,
// 0).setUnlocalizedName("tconstruct.HeavyHelmet");
TinkerArmor.heartCanister = new HeartCanister().setUnlocalizedName("tconstruct.canister");
// heavyBoots = new TArmorBase(PHConstruct.heavyBoots,
// 3).setUnlocalizedName("tconstruct.HeavyBoots");
// glove = new
// Glove(PHConstruct.glove).setUnlocalizedName("tconstruct.Glove");
TinkerArmor.knapsack = new Knapsack().setUnlocalizedName("tconstruct.storage");
// GameRegistry.registerItem(TRepo.heavyHelmet, "heavyHelmet");
GameRegistry.registerItem(TinkerArmor.heartCanister, "heartCanister");
// GameRegistry.registerItem(TRepo.heavyBoots, "heavyBoots");
// GameRegistry.registerItem(TRepo.glove, "glove");
GameRegistry.registerItem(TinkerArmor.knapsack, "knapsack");

LiquidCasting basinCasting = TConstruct.getBasinCasting();
Expand Down Expand Up @@ -124,6 +135,7 @@ public void preInit(FMLPreInitializationEvent event) {
travelBoots = (TravelGear) new TravelGear(ArmorPart.Feet).setUnlocalizedName("tconstruct.travelboots");
travelGlove = (AccessoryCore) new TravelGlove().setUnlocalizedName("tconstruct.travelgloves");
travelBelt = (AccessoryCore) new TravelBelt().setUnlocalizedName("tconstruct.travelbelt");

GameRegistry.registerItem(travelGoggles, "travelGoggles");
GameRegistry.registerItem(travelVest, "travelVest");
GameRegistry.registerItem(travelWings, "travelWings");
Expand Down Expand Up @@ -163,9 +175,6 @@ private void craftingTableRecipes() {
new ShapedOreRecipe(new ItemStack(TinkerArmor.heartCanister, 1, 0), "##", "##", '#', "ingotAluminum"));
GameRegistry.addRecipe(
new ShapedOreRecipe(new ItemStack(TinkerArmor.heartCanister, 1, 0), "##", "##", '#', "ingotAluminium"));
// GameRegistry.addRecipe(new ShapedOreRecipe(new
// ItemStack(TRepo.heartCanister, 1, 0), "##", "##", '#',
// "ingotNaturalAluminum"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
new ItemStack(TinkerArmor.heartCanister, 1, 0),
Expand Down Expand Up @@ -201,8 +210,6 @@ private void craftingTableRecipes() {
new ItemStack(TinkerArmor.heartCanister, 1, 2),
new ItemStack(TinkerArmor.heartCanister, 1, 3),
new ItemStack(Items.golden_apple, 1, 1));
// GameRegistry.addShapelessRecipe(new ItemStack(heartCanister, 1, 6), new ItemStack(heartCanister, 1, 0), new
// ItemStack(heartCanister, 1, 4), new ItemStack(heartCanister, 1, 5));

GameRegistry.addRecipe(
new ShapedOreRecipe(
Expand Down Expand Up @@ -234,7 +241,6 @@ private void craftingTableRecipes() {

// Temporary recipes
ItemStack leather = new ItemStack(Items.leather);
ItemStack glass = new ItemStack(Blocks.glass);
ItemStack string = new ItemStack(Items.string);
GameRegistry.addRecipe(
new ShapedOreRecipe(
Expand Down Expand Up @@ -304,8 +310,6 @@ protected static void addRecipesForDryingRack() {
DryingRackRecipes.addDryingRecipe(Items.beef, 20 * 60 * 5, new ItemStack(TinkerArmor.jerky, 1, 0));
DryingRackRecipes.addDryingRecipe(Items.chicken, 20 * 60 * 5, new ItemStack(TinkerArmor.jerky, 1, 1));
DryingRackRecipes.addDryingRecipe(Items.porkchop, 20 * 60 * 5, new ItemStack(TinkerArmor.jerky, 1, 2));
// DryingRackRecipes.addDryingRecipe(Item.muttonRaw, 20 * 60 * 5, new
// ItemStack(TRepo.jerky, 1, 3));
DryingRackRecipes.addDryingRecipe(Items.fish, 20 * 60 * 5, new ItemStack(TinkerArmor.jerky, 1, 4));
DryingRackRecipes.addDryingRecipe(Items.rotten_flesh, 20 * 60 * 5, new ItemStack(TinkerArmor.jerky, 1, 5));
DryingRackRecipes.addDryingRecipe(
Expand All @@ -317,8 +321,6 @@ protected static void addRecipesForDryingRack() {
20 * 60 * 5,
new ItemStack(TinkerArmor.jerky, 1, 7));

// DryingRackRecipes.addDryingRecipe(new ItemStack(TRepo.jerky, 1, 5),
// 20 * 60 * 10, Item.leather);
}

private void registerModifiers() {
Expand Down Expand Up @@ -427,8 +429,6 @@ private void registerModifiers() {
// Glove
ModifyBuilder.registerModifier(
new GloveSpeed(1, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
// ModifyBuilder.registerModifier(new GloveClimb(new ItemStack[] { new ItemStack(Items.slime_ball), new
// ItemStack(Blocks.web), new ItemStack(TinkerTools.materials, 1, 25) }));
modAttackGlove = new ModAttack(
"Quartz",
2,
Expand All @@ -437,6 +437,5 @@ private void registerModifiers() {
50,
50,
"Accessory");
// ModifyBuilder.registerModifier(modAttackGlove);
}
}
45 changes: 26 additions & 19 deletions src/main/java/tconstruct/gadgets/TinkerGadgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
Expand All @@ -20,8 +21,8 @@
import tconstruct.TConstruct;
import tconstruct.gadgets.item.ItemSlimeBoots;
import tconstruct.gadgets.item.ItemSlimeSling;
import tconstruct.library.SlimeBounceHandler;
import tconstruct.library.TConstructRegistry;
import tconstruct.world.TinkerWorld;

@Pulse(id = "Tinkers' Gadgets", description = "All the fun toys.", forced = true)
public class TinkerGadgets {
Expand All @@ -35,31 +36,37 @@ public class TinkerGadgets {

@Handler
public void preInit(FMLPreInitializationEvent event) {
log.info("Pre Init");
SlimeBounceHandler.init();
slimeSling = registerItem(new ItemSlimeSling(), "slimesling");
slimeBoots = registerItem(new ItemSlimeBoots(), "slime_boots");
}

@Handler
public void init(FMLInitializationEvent event) {
log.info("Init");
String ore = "blockSlime";
if (!Loader.isModLoaded("dreamcraft")) {
ItemStack slimeBlockGreen = new ItemStack(TinkerWorld.slimeGel, 1, 1);

GameRegistry.addRecipe(
new ShapedOreRecipe(new ItemStack(slimeBoots), " ", "s s", "b b", 's', "slimeball", 'b', ore));
GameRegistry.addRecipe(
new ShapedOreRecipe(
new ItemStack(slimeSling),
"fbf",
"s s",
" s ",
'f',
Items.string,
's',
"slimeball",
'b',
ore));
GameRegistry.addShapedRecipe(
new ItemStack(slimeBoots),
" ",
"s s",
"b b",
's',
Items.slime_ball,
'b',
slimeBlockGreen);
GameRegistry.addRecipe(
new ShapedOreRecipe(
new ItemStack(slimeSling),
"fbf",
"s s",
" s ",
'f',
Items.string,
's',
Items.slime_ball,
'b',
slimeBlockGreen));
}
TConstructRegistry.gadgetsTab.init(new ItemStack(slimeBoots));
}

Expand Down
30 changes: 13 additions & 17 deletions src/main/java/tconstruct/gadgets/item/ItemSlimeBoots.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public ItemSlimeBoots() {
super(SLIME_MATERIAL, 0, 3);
this.setCreativeTab(TConstructRegistry.gadgetsTab);
this.setMaxStackSize(1);
this.setMaxDamage(100);
SLIME_MATERIAL.customCraftingMaterial = Items.slime_ball;
armorPart = ArmorPart.Feet;
textureFolder = "armor";
Expand All @@ -57,7 +56,7 @@ public boolean isValidArmor(ItemStack stack, int armorType1, Entity entity) {
return armorType1 == 3;
}

// equipping with rightclick
// equipping with right click
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
int slot = 1; // 0 = current item, 1 = feet
Expand All @@ -67,7 +66,6 @@ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPl
} else {
itemstack = itemstack.copy();
playerIn.setCurrentItemOrArmor(1, itemStackIn.copy());
// playerIn.setCurrentItemOrArmor(0, itemstack);
playerIn.entityDropItem(itemstack, 0);
}
itemStackIn.stackSize--;
Expand All @@ -79,21 +77,17 @@ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPl
// RUBBERY BOUNCY BOUNCERY WOOOOO
public void onFall(LivingFallEvent event) {
final EntityLivingBase living = event.entityLiving;
// TinkerGadgets.log.info("Fall event.");
// using fall distance as the event distance could be reduced by jump boost
if (living == null || living.fallDistance <= 2f) {
// TinkerGadgets.log.info("Invalid event.");
return;
}
// can the entity bounce?
if (!SlimeBounceHandler.hasSlimeBoots(living)) {
// TinkerGadgets.log.info("No Boots.");
return;
}

// reduced fall damage when crouching
if (living.isSneaking()) {
// TinkerGadgets.log.info("Sneaking");
event.distance = 1;
return;
}
Expand All @@ -102,38 +96,33 @@ public void onFall(LivingFallEvent event) {
event.setCanceled(true);
// skip further client processing on players
if (living.worldObj.isRemote) {
// TinkerGadgets.log.info("Client Fall Handler.");
living.playSound("mob.slime.small", 1f, 1f);
SlimeBounceHandler.addBounceHandler(living);
// TConstruct.packetPipeline.sendToServer(new BouncedPacket(living));
return;
}

// server players behave differently than non-server players, they have no
// velocity during the event, so we need to reverse engineer it
Vec3 motion = SlimeBounceHandler.getMotion(living);
if (living instanceof EntityPlayerMP) {
// velocity is lost on server players, but we dont have to defer the bounce
// velocity is lost on server players, but we don't have to defer the bounce
double gravity = 0.2353455252;
double time = Math.sqrt(living.fallDistance / gravity);
double velocity = gravity * time;
double velocity = gravity * time / 2;
living.motionX = motion.xCoord / 0.95f;
living.motionY = velocity;
living.motionZ = motion.zCoord / 0.95f;
living.velocityChanged = true;
// preserve momentum
SlimeBounceHandler.addBounceHandler(living);
// TinkerGadgets.log.info("Player");
} else {
// for non-players, need to defer the bounce
// only slow down half as much when bouncing
living.motionX = motion.xCoord / 0.95f;
living.motionY = motion.yCoord * -0.9;
living.motionZ = motion.zCoord / 0.95f;
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).yCoord);
// TinkerGadgets.log.info("Not Player");
}
// TinkerGadgets.log.info("Server Fall Handler.");
// update airborn status
living.isAirBorne = true;
living.onGround = false;
Expand All @@ -143,7 +132,7 @@ public void onFall(LivingFallEvent event) {

@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
return 2;
return 0;
}

@Override
Expand Down Expand Up @@ -183,11 +172,13 @@ public boolean hasEffect(ItemStack par1ItemStack) {
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
int slot) {
return new ArmorProperties(0, armor.getItemDamage() / 100, 100);
return new ArmorProperties(0, 0.1D, 1);
}

@Override
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {}
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
armor.damageItem(1, entity);
}

@Override
@SideOnly(Side.CLIENT)
Expand Down Expand Up @@ -232,6 +223,11 @@ public boolean hasCustomEntity(ItemStack stack) {
return true;
}

@Override
public int getMaxDamage() {
return 100;
}

@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
return new FancyEntityItem(world, location, itemstack);
Expand Down
Loading

0 comments on commit f7c6a9e

Please sign in to comment.