ActionResultType in onActivated

This commit is contained in:
Sebastian Hartte
2020-06-02 19:15:23 +02:00
parent 3e78c713d1
commit cf9ab8a13b
42 changed files with 135 additions and 181 deletions
@@ -146,7 +146,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
{
final TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isShiftKeyDown() && tg.isFormed() && tg.isActive() )
if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() )
{
if( Platform.isClient() )
{
@@ -100,7 +100,7 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
public boolean onBlockActivated( final World w, final BlockPos pos, final BlockState state, final PlayerEntity p, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ )
{
final TileMolecularAssembler tg = this.getTileEntity( w, pos );
if( tg != null && !p.isShiftKeyDown() )
if( tg != null && !p.isCrouching() )
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true;
@@ -47,16 +47,11 @@ import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank;
public class BlockCrank extends AEBaseTileBlock
public class BlockCrank extends AEBaseTileBlock<TileCrank>
{
public BlockCrank()
{
super( Material.WOOD );
this.setLightOpacity( 0 );
this.setHarvestLevel( "axe", 0 );
this.setFullSize( this.setOpaque( false ) );
public BlockCrank(Properties props) {
super(props);
}
@Override
@@ -65,7 +60,7 @@ public class BlockCrank extends AEBaseTileBlock
if( player instanceof FakePlayer || player == null )
{
this.dropCrank( w, pos );
return true;
return ActionResultType.SUCCESS;
}
final AEBaseTile tile = this.getTileEntity( w, pos );
@@ -77,7 +72,7 @@ public class BlockCrank extends AEBaseTileBlock
}
}
return true;
return ActionResultType.SUCCESS;
}
private void dropCrank( final World world, final BlockPos pos )
@@ -19,9 +19,8 @@
package appeng.block.grindstone;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
import appeng.tile.grindstone.TileGrinder;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
@@ -30,32 +29,25 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
import javax.annotation.Nullable;
public class BlockGrinder extends AEBaseTileBlock
public class BlockGrinder extends AEBaseTileBlock<TileGrinder>
{
public BlockGrinder()
{
super( Material.ROCK );
this.setHardness( 3.2F );
public BlockGrinder(Properties props) {
super(props);
}
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
final TileGrinder tg = this.getTileEntity( w, pos );
if( tg != null && !p.isShiftKeyDown() )
if( tg != null && !p.isCrouching() )
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_GRINDER );
return true;
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit.getFace()), GuiBridge.GUI_GRINDER );
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -1,40 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block.grindstone;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.client.render.tesr.CrankTESR;
public class CrankRendering extends BlockRenderingCustomizer
{
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.tileEntityRenderer( new CrankTESR() );
}
}
@@ -48,9 +48,9 @@ public class BlockCellWorkbench extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileCellWorkbench tg = this.getTileEntity( w, pos );
@@ -60,8 +60,8 @@ public class BlockCellWorkbench extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_CELL_WORKBENCH );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -75,9 +75,9 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( player.isShiftKeyDown() )
if( player.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
if( Platform.isServer() )
@@ -89,7 +89,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
}
}
return true;
return ActionResultType.SUCCESS;
}
@Override
@@ -48,21 +48,21 @@ public class BlockCondenser extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( player.isShiftKeyDown() )
if( player.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
if( Platform.isServer() )
{
final TileCondenser tc = this.getTileEntity( w, pos );
if( tc != null && !player.isShiftKeyDown() )
if( tc != null && !player.isCrouching() )
{
Platform.openGUI( player, tc, AEPartLocation.fromFacing(hit), GuiBridge.GUI_CONDENSER );
return true;
return ActionResultType.SUCCESS;
}
}
return true;
return ActionResultType.SUCCESS;
}
}
@@ -53,9 +53,9 @@ public class BlockInscriber extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileInscriber tg = this.getTileEntity( w, pos );
@@ -65,9 +65,9 @@ public class BlockInscriber extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_INSCRIBER );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
@Override
@@ -77,9 +77,9 @@ public class BlockInterface extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileInterface tg = this.getTileEntity( w, pos );
@@ -89,9 +89,9 @@ public class BlockInterface extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_INTERFACE );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
@Override
@@ -83,9 +83,9 @@ public class BlockSecurityStation extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileSecurityStation tg = this.getTileEntity( w, pos );
@@ -93,12 +93,12 @@ public class BlockSecurityStation extends AEBaseTileBlock
{
if( Platform.isClient() )
{
return true;
return ActionResultType.SUCCESS;
}
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_SECURITY );
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -81,7 +81,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
this.startFuse( w, pos, player );
w.removeBlock(pos, false);
heldItem.damageItem( 1, player );
return true;
return ActionResultType.SUCCESS;
}
else
{
@@ -79,7 +79,7 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( player.isShiftKeyDown() )
if( player.isCrouching() )
{
return false;
}
@@ -87,14 +87,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
if( Platform.isServer() )
{
final TileVibrationChamber tc = this.getTileEntity( w, pos );
if( tc != null && !player.isShiftKeyDown() )
if( tc != null && !player.isCrouching() )
{
Platform.openGUI( player, tc, AEPartLocation.fromFacing(hit), GuiBridge.GUI_VIBRATION_CHAMBER );
return true;
return ActionResultType.SUCCESS;
}
}
return true;
return ActionResultType.SUCCESS;
}
@Override
@@ -111,7 +111,7 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
{
final TileWireless tg = this.getTileEntity( w, pos );
if( tg != null && !player.isShiftKeyDown() )
if( tg != null && !player.isCrouching() )
{
if( Platform.isServer() )
{
@@ -72,9 +72,9 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileQuantumBridge tg = this.getTileEntity( w, pos );
@@ -84,9 +84,9 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_QNB );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
@Override
@@ -60,9 +60,9 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileSpatialIOPort tg = this.getTileEntity( w, pos );
@@ -72,8 +72,8 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_SPATIAL_IO_PORT );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -94,11 +94,11 @@ public class BlockChest extends AEBaseTileBlock
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
final TileChest tg = this.getTileEntity( w, pos );
if( tg != null && !p.isShiftKeyDown() )
if( tg != null && !p.isCrouching() )
{
if( Platform.isClient() )
{
return true;
return ActionResultType.SUCCESS;
}
if( hit != tg.getUp() )
@@ -113,9 +113,9 @@ public class BlockChest extends AEBaseTileBlock
}
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -82,9 +82,9 @@ public class BlockDrive extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileDrive tg = this.getTileEntity( w, pos );
@@ -94,8 +94,8 @@ public class BlockDrive extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_DRIVE );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}
@@ -60,9 +60,9 @@ public class BlockIOPort extends AEBaseTileBlock
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
if( p.isShiftKeyDown() )
if( p.isCrouching() )
{
return false;
return ActionResultType.PASS;
}
final TileIOPort tg = this.getTileEntity( w, pos );
@@ -72,8 +72,8 @@ public class BlockIOPort extends AEBaseTileBlock
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_IOPORT );
}
return true;
return ActionResultType.SUCCESS;
}
return false;
return ActionResultType.PASS;
}
}