Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add folding functionality to dollies #26

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Add your dependencies here

dependencies {
compile('com.github.GTNewHorizons:waila:1.5.20:dev')
compile('com.github.GTNewHorizons:waila:1.6.0:dev')

compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.6:dev')
compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
compileOnly('curse.maven:minefactory-reloaded-66672:2366150')
api('com.github.GTNewHorizons:BuildCraft:7.1.36:dev')
}
4 changes: 4 additions & 0 deletions src/main/java/mcp/mobius/betterbarrels/BetterBarrels.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import mcp.mobius.betterbarrels.common.items.ItemTuningFork;
import mcp.mobius.betterbarrels.common.items.dolly.ItemBarrelMover;
import mcp.mobius.betterbarrels.common.items.dolly.ItemDiamondMover;
import mcp.mobius.betterbarrels.common.items.dolly.ItemFoldedBarrelMover;
import mcp.mobius.betterbarrels.common.items.upgrades.ItemUpgradeCore;
import mcp.mobius.betterbarrels.common.items.upgrades.ItemUpgradeSide;
import mcp.mobius.betterbarrels.common.items.upgrades.ItemUpgradeStructural;
Expand Down Expand Up @@ -86,6 +87,7 @@ public static void debug(String msg) {
public static Item itemLockingPlanks = null;
public static Item itemHammer = null;

public static Item itemFoldedMover = null;
public static long limiterDelay = 500;

public static int blockBarrelRendererID = -1;
Expand Down Expand Up @@ -257,6 +259,7 @@ public void preInit(FMLPreInitializationEvent event) {
itemMoverDiamond = new ItemDiamondMover();
itemHammer = new ItemBarrelHammer();
itemTuningFork = new ItemTuningFork();
itemFoldedMover = new ItemFoldedBarrelMover();

GameRegistry.registerBlock(blockBarrel, "barrel");
// GameRegistry.registerBlock(blockMiniBarrel);
Expand All @@ -268,6 +271,7 @@ public void preInit(FMLPreInitializationEvent event) {
GameRegistry.registerItem(itemUpgradeCore, "upgradeCore");
GameRegistry.registerItem(itemUpgradeSide, "upgradeSide");
GameRegistry.registerItem(itemMover, "mover");
GameRegistry.registerItem(itemFoldedMover, "moverFolded");
GameRegistry.registerItem(itemMoverDiamond, "moverDiamond");
GameRegistry.registerItem(itemHammer, "hammer");
GameRegistry.registerItem(itemTuningFork, "tuningFork");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import mcp.mobius.betterbarrels.BetterBarrels;
import mcp.mobius.betterbarrels.Utils;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
Expand All @@ -27,6 +29,7 @@
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
Expand All @@ -42,6 +45,7 @@ public class ItemBarrelMover extends Item {
protected IIcon text_empty = null;
protected IIcon text_filled = null;
protected DollyType type = DollyType.NORMAL;
protected boolean preventFold = false;
OneEyeMaker marked this conversation as resolved.
Show resolved Hide resolved

protected static ArrayList<Class> classExtensions = new ArrayList<Class>();
protected static ArrayList<String> classExtensionsNames = new ArrayList<String>();
Expand Down Expand Up @@ -177,12 +181,43 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world,
}

if (stack.hasTagCompound() && stack.getTagCompound().hasKey("Container")) {
preventFold = true;
OneEyeMaker marked this conversation as resolved.
Show resolved Hide resolved
return this.placeContainer(stack, player, world, x, y, z, side);
}

return false;
}

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}

// This prevents the dolly from folding after sneak right-clicking to place an item.
if (preventFold) {
preventFold = false;
return itemStack;
}
OneEyeMaker marked this conversation as resolved.
Show resolved Hide resolved

if (player.isSneaking() && type == DollyType.NORMAL
&& (!itemStack.hasTagCompound() || !itemStack.getTagCompound().hasKey("Container"))) {
// Diamond dollies can't be folded because they can be damaged.
final EntityItem newItem = new EntityItem(
world,
player.posX,
player.posY,
player.posZ,
new ItemStack(BetterBarrels.itemFoldedMover, 1));
newItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(newItem);

itemStack.stackSize -= 1;
}

return itemStack;
}

protected boolean placeContainer(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) {
NBTTagCompound nbtStack = stack.getTagCompound();
NBTTagCompound nbtContainerStack = nbtStack.getCompoundTag("Container");
Expand Down Expand Up @@ -644,6 +679,18 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int par4, bool
}
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean p_77624_4_) {
super.addInformation(itemStack, player, tooltip, p_77624_4_);

if (type == DollyType.NORMAL
&& (!itemStack.hasTagCompound() || !itemStack.getTagCompound().hasKey("Container"))) {
tooltip.add(StatCollector.translateToLocal("item.dolly.folding_hint.1"));
tooltip.add(StatCollector.translateToLocal("item.dolly.folding_hint.2"));
}
}

private ForgeDirection getBarrelOrientationOnPlacement(EntityPlayer player) {
return this.getBarrelOrientationOnPlacement(player, 0, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package mcp.mobius.betterbarrels.common.items.dolly;

import java.util.List;

import mcp.mobius.betterbarrels.BetterBarrels;
import mcp.mobius.betterbarrels.common.JabbaCreativeTab;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

public class ItemFoldedBarrelMover extends Item {

public ItemFoldedBarrelMover() {
super();
this.setCreativeTab(JabbaCreativeTab.tab);
this.setNoRepair();
}

@Override
public void registerIcons(IIconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon(BetterBarrels.modid + ":dolly_normal_folded");
}

@Override
public String getUnlocalizedName() {
return getUnlocalizedName(null);
}

@Override
public String getUnlocalizedName(ItemStack stack) {
return "item.dolly.normal.folded";
}

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote && itemStack.stackSize > 0) {
final EntityItem newItem = new EntityItem(
world,
player.posX,
player.posY,
player.posZ,
new ItemStack(BetterBarrels.itemMover, 1));
newItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(newItem);

itemStack.stackSize -= 1;
}
return itemStack;
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean p_77624_4_) {
super.addInformation(itemStack, player, tooltip, p_77624_4_);
tooltip.add(StatCollector.translateToLocal("item.dolly.folded_hint"));
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/jabba/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ item.hammer.void.name=Barrel Hammer(Leere)

item.dolly.normal.empty.name=Transportwagen
item.dolly.normal.full.name=Transportwagen (Voll)
item.dolly.normal.folded.name=Transportwagen (Gefaltet)
item.dolly.diamond.empty.name=Diamant-Transportwagen
item.dolly.diamond.full.name=Diamant-Transportwagen (Voll)
item.dolly.folding_hint.1=Schleichend rechtsklicken zum Zusammenklappen
item.dolly.folding_hint.2=Zusammengeklappte Transportwagen können in Truhen und Rucksäcken verstaut werden
item.dolly.folded_hint=Ausklappen mit Rechtsklick
item.fork.name=B-Space-Stimmgabel

tile.blockbarrel.name=Besseres Fass
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/assets/jabba/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ item.hammer.creative.name=Barrel Hammer(Creative)

item.dolly.normal.empty.name=Dolly
item.dolly.normal.full.name=Dolly (Full)
item.dolly.diamond.empty.name=Diamond dolly
item.dolly.diamond.full.name=Diamond dolly (Full)
item.dolly.normal.folded.name=Dolly (Folded)
item.dolly.diamond.empty.name=Diamond Dolly
item.dolly.diamond.full.name=Diamond Dolly (Full)
item.dolly.folding_hint.1=Sneak right click to fold
item.dolly.folding_hint.2=Folded dollies can be stored in chests and backpacks
item.dolly.folded_hint=Right click to unfold
item.fork.name=B-Space tuning fork

tile.blockbarrel.name=Better Barrel
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/jabba/lang/ru_RU.lang
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ item.hammer.creative.name=Бочкообразный молот (Творчес

item.dolly.normal.empty.name=Тележка
item.dolly.normal.full.name=Тележка (Полная)
item.dolly.normal.folded.name=Тележка (Сложенная)
item.dolly.diamond.empty.name=Алмазная тележка
item.dolly.diamond.full.name=Алмазная тележка (Полная)
item.dolly.folding_hint.1=Присесть и правая кнопка мыши чтобы сложить
item.dolly.folding_hint.2=Сложенные тележки можно хранить в сундуках и рюкзаках
item.dolly.folded_hint=Присесть и правая кнопка мыши чтобы разложить
item.fork.name=Пространственный камертон

tile.blockbarrel.name=Better Barrel
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/jabba/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ item.hammer.creative.name=桶锤(创造)

item.dolly.normal.empty.name=手推车
item.dolly.normal.full.name=手推车(满)
item.dolly.normal.folded.name=手推车(折叠式)
item.dolly.diamond.empty.name=钻石手推车
item.dolly.diamond.full.name=钻石手推车(满)
item.dolly.folding_hint.1=偷偷点击右键折叠
item.dolly.folding_hint.2=折叠式手推车可存放在箱子和背包中
item.dolly.folded_hint=右击展开
item.fork.name=B空间音叉

tile.blockbarrel.name=更好的桶
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.