Skip to content

Commit

Permalink
Sugar Lump adjustments
Browse files Browse the repository at this point in the history
-Sugar Lumps now give speed and less hunger but can now be eaten faster (with a small chance to get Nausea).
-Fixed max stack size for food not being 64.
  • Loading branch information
IcarussOne committed Oct 28, 2023
1 parent 05c743b commit 05e11ef
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/main/java/drzhark/mocreatures/init/MoCItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MoCItems {
public static final MoCItem horsesaddle = new MoCItemHorseSaddle("horsesaddle");
public static final MoCItem sharkteeth = new MoCItem("sharkteeth");
public static final MoCItem haystack = new MoCItemHayStack("haystack");
public static final MoCItemSugarLump sugarlump = new MoCItemSugarLump("sugarlump");
public static final MoCItemFood sugarlump = (MoCItemFood) new MoCItemFood("sugarlump", 2, 0.1F, false, 12).setPotionEffect(new PotionEffect(MobEffects.NAUSEA, 4 * 20, 0), 0.15F);
public static final MoCItem mocegg = new MoCItemEgg("mocegg");
public static final MoCItem bigcatclaw = new MoCItem("bigcatclaw");
public static final MoCItem whip = new MoCItemWhip("whip");
Expand Down Expand Up @@ -90,6 +90,7 @@ public class MoCItems {
public static final MoCItem ancientSilverIngot = new MoCItem("ancientsilveringot");
public static final MoCItem ancientSilverNugget = new MoCItem("ancientsilvernugget");
public static final MoCItem firestoneChunk = new MoCItem("firestonechunk");
public static final MoCItemCrabClaw brackishClaw = new MoCItemCrabClaw("brackish_claw", 768, 15, 0.0F, 1, 2.0F);
// Food
public static final MoCItemFood cookedTurkey = new MoCItemFood("turkeycooked", 7, 0.8F, true);
public static final MoCItemFood crabraw = (MoCItemFood) new MoCItemFood("crabraw", 2, 0.1F, true).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30 * 20, 0), 0.8F);
Expand Down Expand Up @@ -338,7 +339,8 @@ public static void registerItems(final RegistryEvent.Register<Item> event) {
scrollOfSale,
scrollOfOwner,
crabraw,
crabcooked
crabcooked,
brackishClaw
));

final IForgeRegistry<Item> registry = event.getRegistry();
Expand Down
97 changes: 97 additions & 0 deletions src/main/java/drzhark/mocreatures/item/MoCItemCrabClaw.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* GNU GENERAL PUBLIC LICENSE Version 3
*/
package drzhark.mocreatures.item;

import net.minecraft.block.state.IBlockState;
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.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.google.common.collect.Multimap;

import drzhark.mocreatures.init.MoCItems;

import java.util.UUID;

@SuppressWarnings("deprecation")
public class MoCItemCrabClaw extends MoCItem {

protected static final UUID REACH_DISTANCE_MODIFIER = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
protected static final UUID TOUGHNESS_MODIFIER = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
public final int armor;
public final int durability;
public final int enchantability;
public final float reach;
public final float toughness;

public MoCItemCrabClaw(String name, int durability, int enchantability, float toughness, int armor, float reach) {
super(name);
this.setMaxDamage(durability);
this.maxStackSize = 1;
this.armor = armor;
this.durability = durability;
this.enchantability = enchantability;
this.reach = reach;
this.toughness = toughness;
}

// TODO: Damage claw while placing/destroying blocks or hitting mobs
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
Item itemOffhand = attacker.getHeldItemOffhand().getItem();

if (itemOffhand instanceof MoCItemCrabClaw) {
stack.damageItem(1, attacker);
}

return true;
}

@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
Item itemOffhand = entityLiving.getHeldItemOffhand().getItem();

if (!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0D && itemOffhand instanceof MoCItemCrabClaw) {
stack.damageItem(1, entityLiving);
}

return true;
}

@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}

@Override
public int getItemEnchantability() {
return enchantability;
}

@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return repair.getItem() == MoCItems.animalHide ? true : super.getIsRepairable(toRepair, repair);
}

@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);

if (equipmentSlot == EntityEquipmentSlot.OFFHAND) {
multimap.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(TOUGHNESS_MODIFIER, "Crab claw armor", armor, 0));
multimap.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(REACH_DISTANCE_MODIFIER, "Crab claw reach", reach, 0));
multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName(), new AttributeModifier(TOUGHNESS_MODIFIER, "Crab claw toughness", toughness, 0));
}

return multimap;
}
}
5 changes: 4 additions & 1 deletion src/main/java/drzhark/mocreatures/item/MoCItemFood.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public MoCItemFood(String name, int amount) {
this.setCreativeTab(MoCreatures.tabMoC);
this.setRegistryName(MoCConstants.MOD_ID, name);
this.setTranslationKey(name);
this.maxStackSize = 32;
}

public MoCItemFood(String name, int amount, float saturation, boolean isWolfFood) {
Expand Down Expand Up @@ -55,6 +54,10 @@ protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 10 * 20, 1));
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 10 * 20, 1));
}

if (this == MoCItems.sugarlump) {
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 4 * 20, 0));
}

super.onFoodEaten(stack, world, player);
}
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/drzhark/mocreatures/item/MoCItemSugarLump.java

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/assets/mocreatures/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ item.ancientsilveringot.name=Ancient Silver Ingot
item.ancientsilverscrap.name=Ancient Silver Scrap
item.bigcatclaw.name=Big Cat Claw
item.bo.name=Ninja Bo Staff
item.brackish_claw.name=Brackish Claw
item.builderhammer.name=Builder Hammer
item.chitin.name=Dirt Chitin
item.chitinblack.name=Cave Chitin
Expand Down

0 comments on commit 05e11ef

Please sign in to comment.