mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -1,12 +1,10 @@
|
||||
package tconstruct.gadgets.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector3d;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector3d;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -32,208 +30,208 @@ import tconstruct.tools.entity.FancyEntityItem;
|
||||
|
||||
public class ItemSlimeBoots extends ItemArmor implements ISpecialArmor {
|
||||
|
||||
public static ArmorMaterial SLIME_MATERIAL = EnumHelper.addArmorMaterial("SLIME", 100, new int[] { 0, 0, 0, 0 }, 0);
|
||||
public static ArmorMaterial SLIME_MATERIAL = EnumHelper.addArmorMaterial("SLIME", 100, new int[] {0, 0, 0, 0}, 0);
|
||||
|
||||
public final ArmorPart armorPart;
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
public final ArmorPart armorPart;
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
|
||||
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";
|
||||
textureName = "slime";
|
||||
SlimeBounceHandler.registerEvent(this);
|
||||
}
|
||||
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";
|
||||
textureName = "slime";
|
||||
SlimeBounceHandler.registerEvent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType1, Entity entity) {
|
||||
// can be worn as boots
|
||||
return armorType1 == 3;
|
||||
}
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType1, Entity entity) {
|
||||
// can be worn as boots
|
||||
return armorType1 == 3;
|
||||
}
|
||||
|
||||
// equipping with rightclick
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
int slot = 1; // 0 = current item, 1 = feet
|
||||
ItemStack itemstack = playerIn.getEquipmentInSlot(slot);
|
||||
if (itemstack == null) {
|
||||
playerIn.setCurrentItemOrArmor(slot, itemStackIn.copy());
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
else {
|
||||
itemstack = itemstack.copy();
|
||||
playerIn.setCurrentItemOrArmor(1, itemStackIn.copy());
|
||||
//playerIn.setCurrentItemOrArmor(0, itemstack);
|
||||
playerIn.entityDropItem(itemstack, 0);
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
/** Called when an entity lands to handle the event */
|
||||
@SubscribeEvent
|
||||
// RUBBERY BOUNCY BOUNCERY WOOOOO
|
||||
public void onFall(LivingFallEvent event) {
|
||||
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;
|
||||
}
|
||||
// equipping with rightclick
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
int slot = 1; // 0 = current item, 1 = feet
|
||||
ItemStack itemstack = playerIn.getEquipmentInSlot(slot);
|
||||
if (itemstack == null) {
|
||||
playerIn.setCurrentItemOrArmor(slot, itemStackIn.copy());
|
||||
itemStackIn.stackSize--;
|
||||
} else {
|
||||
itemstack = itemstack.copy();
|
||||
playerIn.setCurrentItemOrArmor(1, itemStackIn.copy());
|
||||
// playerIn.setCurrentItemOrArmor(0, itemstack);
|
||||
playerIn.entityDropItem(itemstack, 0);
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
// reduced fall damage when crouching
|
||||
if (living.isSneaking()) {
|
||||
//TinkerGadgets.log.info("Sneaking");
|
||||
event.distance = 1;
|
||||
return;
|
||||
}
|
||||
/** Called when an entity lands to handle the event */
|
||||
@SubscribeEvent
|
||||
// RUBBERY BOUNCY BOUNCERY WOOOOO
|
||||
public void onFall(LivingFallEvent event) {
|
||||
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;
|
||||
}
|
||||
|
||||
// thing is wearing slime boots. let's get bouncyyyyy
|
||||
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;
|
||||
}
|
||||
// reduced fall damage when crouching
|
||||
if (living.isSneaking()) {
|
||||
// TinkerGadgets.log.info("Sneaking");
|
||||
event.distance = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// server players behave differently than non-server players, they have no
|
||||
// velocity during the event, so we need to reverse engineer it
|
||||
Vector3d motion = SlimeBounceHandler.getMotion(living);
|
||||
if (living instanceof EntityPlayerMP) {
|
||||
// velocity is lost on server players, but we dont have to defer the bounce
|
||||
double gravity = 0.2353455252;
|
||||
double time = Math.sqrt(living.fallDistance / gravity);
|
||||
double velocity = gravity * time;
|
||||
living.setVelocity(motion.x / 0.95f, velocity, motion.z / 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.setVelocity(motion.x / 0.95f, motion.y * -0.9, motion.z / 0.95f);
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).y);
|
||||
//TinkerGadgets.log.info("Not Player");
|
||||
}
|
||||
//TinkerGadgets.log.info("Server Fall Handler.");
|
||||
// update airborn status
|
||||
living.isAirBorne = true;
|
||||
living.onGround = false;
|
||||
event.distance = 0f;
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
}
|
||||
// thing is wearing slime boots. let's get bouncyyyyy
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
return 2;
|
||||
}
|
||||
// server players behave differently than non-server players, they have no
|
||||
// velocity during the event, so we need to reverse engineer it
|
||||
Vector3d motion = SlimeBounceHandler.getMotion(living);
|
||||
if (living instanceof EntityPlayerMP) {
|
||||
// velocity is lost on server players, but we dont have to defer the bounce
|
||||
double gravity = 0.2353455252;
|
||||
double time = Math.sqrt(living.fallDistance / gravity);
|
||||
double velocity = gravity * time;
|
||||
living.setVelocity(motion.x / 0.95f, velocity, motion.z / 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.setVelocity(motion.x / 0.95f, motion.y * -0.9, motion.z / 0.95f);
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).y);
|
||||
// TinkerGadgets.log.info("Not Player");
|
||||
}
|
||||
// TinkerGadgets.log.info("Server Fall Handler.");
|
||||
// update airborn status
|
||||
living.isAirBorne = true;
|
||||
living.onGround = false;
|
||||
event.distance = 0f;
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] modifiers;
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + "_boots");
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] modifiers;
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + "_boots");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
return itemIcon;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
return itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
|
||||
int slot) {
|
||||
return new ArmorProperties(0, armor.getItemDamage() / 100, 100);
|
||||
}
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties(
|
||||
EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
return new ArmorProperties(0, armor.getItemDamage() / 100, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (source == DamageSource.fall) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (source == DamageSource.fall) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1));
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1));
|
||||
}
|
||||
|
||||
// Vanilla overrides
|
||||
@Override
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
// Vanilla overrides
|
||||
@Override
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Boooounce!");
|
||||
list.add("Hold "+(I18n.format(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyDescription(), new Object[0]))+" to stop bouncing.");
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Boooounce!");
|
||||
list.add("Hold "
|
||||
+ (I18n.format(
|
||||
Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyDescription(), new Object[0]))
|
||||
+ " to stop bouncing.");
|
||||
}
|
||||
|
||||
/* Prevent armor from dying */
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
/* Prevent armor from dying */
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user