Added wrench for rotating blocks around
This commit is contained in:
parent
b8aedebf14
commit
617148fddb
10 changed files with 120 additions and 0 deletions
86
src/main/java/cr0s/warpdrive/item/ItemWrench.java
Normal file
86
src/main/java/cr0s/warpdrive/item/ItemWrench.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package cr0s.warpdrive.item;
|
||||
|
||||
import cr0s.warpdrive.api.IWarpTool;
|
||||
import cr0s.warpdrive.data.EnumTier;
|
||||
import cr0s.warpdrive.data.Vector3;
|
||||
import cr0s.warpdrive.network.PacketHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemWrench extends ItemAbstractBase implements IWarpTool {
|
||||
|
||||
public ItemWrench(final String registryName, final EnumTier enumTier) {
|
||||
super(registryName, enumTier);
|
||||
|
||||
setMaxDamage(0);
|
||||
setMaxStackSize(1);
|
||||
setTranslationKey("warpdrive.tool.wrench");
|
||||
setFull3D();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(final EntityPlayer entityPlayer,
|
||||
final World world, final BlockPos blockPos, final EnumHand hand,
|
||||
final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
// get context
|
||||
final ItemStack itemStackHeld = entityPlayer.getHeldItem(hand);
|
||||
final IBlockState blockState = world.getBlockState(blockPos);
|
||||
if (blockState.getBlock().isAir(blockState, world, blockPos)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
// note: we allow sneaking usage so we can rotate blocks with GUIs
|
||||
|
||||
// compute effect position
|
||||
final Vector3 vFace = new Vector3(blockPos).translate(0.5D);
|
||||
|
||||
// @TODO: confirm if both are really needed
|
||||
if ( !entityPlayer.canPlayerEdit(blockPos, facing, itemStackHeld)
|
||||
|| !world.isBlockModifiable(entityPlayer, blockPos) ) {
|
||||
PacketHandler.sendSpawnParticlePacket(world, "jammed", (byte) 5, vFace,
|
||||
new Vector3(0.0D, 0.0D, 0.0D),
|
||||
1.0F, 1.0F, 1.0F,
|
||||
1.0F, 1.0F, 1.0F,
|
||||
6);
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!blockState.getBlock().rotateBlock(world, blockPos, facing)) {
|
||||
PacketHandler.sendSpawnParticlePacket(world, "jammed", (byte) 5, vFace,
|
||||
new Vector3(0.0D, 0.0D, 0.0D),
|
||||
1.0F, 1.0F, 1.0F,
|
||||
1.0F, 1.0F, 1.0F,
|
||||
6);
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
// no chat message
|
||||
|
||||
// standard place sound effect
|
||||
final SoundType soundType = blockState.getBlock().getSoundType(blockState, world, blockPos, null);
|
||||
world.playSound(null, blockPos, soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
||||
(soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
|
||||
|
||||
world.notifyNeighborsOfStateChange(blockPos, blockState.getBlock(), false);
|
||||
|
||||
entityPlayer.swingArm(hand);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
|
@ -197,6 +197,10 @@ item.warpdrive.tool.tuning_fork.black.name=Schwarze Stimmgabel
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§bRecktsklicke einen Block§7 um seine Kristalle einzustellen\n§bSchleiche§7 um alternative Kristalle einzustellen
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Bedrock Glass !!!
|
||||
tile.warpdrive.decoration.decorative.energized.name=Energiegeladener Block
|
||||
tile.warpdrive.decoration.decorative.network.name=Netzwerk Block
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=Black Tuning Fork
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§bRight click a block§7 to tune its crystals\n§bSneak§7 to tune alternate crystals
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Bedrock Glass
|
||||
tile.warpdrive.decoration.decorative.energized.name=Energized Block
|
||||
tile.warpdrive.decoration.decorative.network.name=Network Block
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=Diapason noir
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§bCliques droit sur un block§r pour ajuster ses cristaux\n§bAccroupi§r pour ajuster les cristaux alternatifs
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Clé tournante
|
||||
item.warpdrive.tool.wrench.tooltip=§bCliques droit sur un block§7 pour le tourner
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Vitre de bedrock
|
||||
tile.warpdrive.decoration.decorative.energized.name=Block energisé
|
||||
tile.warpdrive.decoration.decorative.network.name=Bloc de réseau
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=Zwarte Afstemmingsvork
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§bRechts-klik op een blok§7 om zijn kristal af te stemmen\n§bbuk§7 om zijn andere kristallen af te stemmen
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Bedrock Glass
|
||||
tile.warpdrive.decoration.decorative.energized.name=Geactiveerd Blok
|
||||
tile.warpdrive.decoration.decorative.network.name=Netwerk Blok
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=Черный камертон
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§bИспользуйте на блоке§7, чтобы настроить его кристаллы\n§bПрисядьте§7, чтобы настроить вторичные кристаллы
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Bedrock Glass
|
||||
tile.warpdrive.decoration.decorative.energized.name=Энергизированный блок
|
||||
tile.warpdrive.decoration.decorative.network.name=Сетевой блок
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=黑色音叉
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§b右击方块§7调节水晶频率\n§b潜行右击§7轮替水晶
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=基岩玻璃
|
||||
tile.warpdrive.decoration.decorative.energized.name=能量方块
|
||||
tile.warpdrive.decoration.decorative.network.name=网络方块
|
||||
|
|
|
@ -194,6 +194,10 @@ item.warpdrive.tool.tuning_fork.black.name=黑色調音叉
|
|||
item.warpdrive.tool.tuning_fork.tooltip.usage=§b右鍵單擊一個方塊§7 以調整其水晶\n§b潛行§7 以調節交替水晶
|
||||
|
||||
|
||||
item.warpdrive.tool.wrench.name=Wrench
|
||||
item.warpdrive.tool.wrench.tooltip=§bRight click a block§7 to rotate it
|
||||
|
||||
|
||||
tile.warpdrive.decoration.bedrock_glass.name=Bedrock Glass
|
||||
tile.warpdrive.decoration.decorative.energized.name=通電方塊
|
||||
tile.warpdrive.decoration.decorative.network.name=網絡方塊
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/handheld",
|
||||
"textures": {
|
||||
"layer0": "warpdrive:items/tool/wrench"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Loading…
Reference in a new issue