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
+3
View File
@@ -220,6 +220,9 @@ sourceSets {
include 'appeng/container/implementations/ContainerSkyChest.java' include 'appeng/container/implementations/ContainerSkyChest.java'
include 'appeng/container/slot/SlotNormal.java' include 'appeng/container/slot/SlotNormal.java'
include 'appeng/client/gui/implementations/GuiSkyChest.java' include 'appeng/client/gui/implementations/GuiSkyChest.java'
include 'appeng/block/grindstone/**'
include 'appeng/tile/grindstone/**'
include 'appeng/container/implementations/ContainerGrinder.java'
} }
compileClasspath += sourceSets.api.output compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output runtimeClasspath += sourceSets.api.output
@@ -146,7 +146,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
{ {
final TileCraftingTile tg = this.getTileEntity( w, pos ); 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() ) 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 ) 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 ); 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 ); Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true; return true;
@@ -47,16 +47,11 @@ import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank; import appeng.tile.grindstone.TileCrank;
public class BlockCrank extends AEBaseTileBlock public class BlockCrank extends AEBaseTileBlock<TileCrank>
{ {
public BlockCrank() public BlockCrank(Properties props) {
{ super(props);
super( Material.WOOD );
this.setLightOpacity( 0 );
this.setHarvestLevel( "axe", 0 );
this.setFullSize( this.setOpaque( false ) );
} }
@Override @Override
@@ -65,7 +60,7 @@ public class BlockCrank extends AEBaseTileBlock
if( player instanceof FakePlayer || player == null ) if( player instanceof FakePlayer || player == null )
{ {
this.dropCrank( w, pos ); this.dropCrank( w, pos );
return true; return ActionResultType.SUCCESS;
} }
final AEBaseTile tile = this.getTileEntity( w, pos ); 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 ) private void dropCrank( final World world, final BlockPos pos )
@@ -19,9 +19,8 @@
package appeng.block.grindstone; package appeng.block.grindstone;
import javax.annotation.Nullable; import appeng.block.AEBaseTileBlock;
import appeng.tile.grindstone.TileGrinder;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
@@ -30,32 +29,25 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
public class BlockGrinder extends AEBaseTileBlock public class BlockGrinder extends AEBaseTileBlock<TileGrinder>
{ {
public BlockGrinder() public BlockGrinder(Properties props) {
{ super(props);
super( Material.ROCK );
this.setHardness( 3.2F );
} }
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); // FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit.getFace()), GuiBridge.GUI_GRINDER );
return true; 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 @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); 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 @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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() ) if( Platform.isServer() )
@@ -89,7 +89,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
} }
} }
return true; return ActionResultType.SUCCESS;
} }
@Override @Override
@@ -48,21 +48,21 @@ public class BlockCondenser extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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() ) if( Platform.isServer() )
{ {
final TileCondenser tc = this.getTileEntity( w, pos ); 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 ); 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 @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_INSCRIBER );
} }
return true; return ActionResultType.SUCCESS;
} }
return false; return ActionResultType.PASS;
} }
@Override @Override
@@ -77,9 +77,9 @@ public class BlockInterface extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_INTERFACE );
} }
return true; return ActionResultType.SUCCESS;
} }
return false; return ActionResultType.PASS;
} }
@Override @Override
@@ -83,9 +83,9 @@ public class BlockSecurityStation extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); final TileSecurityStation tg = this.getTileEntity( w, pos );
@@ -93,12 +93,12 @@ public class BlockSecurityStation extends AEBaseTileBlock
{ {
if( Platform.isClient() ) if( Platform.isClient() )
{ {
return true; return ActionResultType.SUCCESS;
} }
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_SECURITY ); 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 ); this.startFuse( w, pos, player );
w.removeBlock(pos, false); w.removeBlock(pos, false);
heldItem.damageItem( 1, player ); heldItem.damageItem( 1, player );
return true; return ActionResultType.SUCCESS;
} }
else else
{ {
@@ -79,7 +79,7 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 false;
} }
@@ -87,14 +87,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
if( Platform.isServer() ) if( Platform.isServer() )
{ {
final TileVibrationChamber tc = this.getTileEntity( w, pos ); 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 ); Platform.openGUI( player, tc, AEPartLocation.fromFacing(hit), GuiBridge.GUI_VIBRATION_CHAMBER );
return true; return ActionResultType.SUCCESS;
} }
} }
return true; return ActionResultType.SUCCESS;
} }
@Override @Override
@@ -111,7 +111,7 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
{ {
final TileWireless tg = this.getTileEntity( w, pos ); final TileWireless tg = this.getTileEntity( w, pos );
if( tg != null && !player.isShiftKeyDown() ) if( tg != null && !player.isCrouching() )
{ {
if( Platform.isServer() ) if( Platform.isServer() )
{ {
@@ -72,9 +72,9 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_QNB );
} }
return true; return ActionResultType.SUCCESS;
} }
return false; return ActionResultType.PASS;
} }
@Override @Override
@@ -60,9 +60,9 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); 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) 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 ); final TileChest tg = this.getTileEntity( w, pos );
if( tg != null && !p.isShiftKeyDown() ) if( tg != null && !p.isCrouching() )
{ {
if( Platform.isClient() ) if( Platform.isClient() )
{ {
return true; return ActionResultType.SUCCESS;
} }
if( hit != tg.getUp() ) 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 @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); 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 @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 ); 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 ); Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_IOPORT );
} }
return true; return ActionResultType.SUCCESS;
} }
return false; return ActionResultType.PASS;
} }
} }
@@ -138,23 +138,6 @@ class BlockDefinitionBuilder implements IBlockBuilder
return this; return this;
} }
@Override
public IBlockBuilder useCustomItemModel()
{
this.rendering( new BlockRenderingCustomizer()
{
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
ModelResourceLocation model = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, BlockDefinitionBuilder.this.registryName ), "inventory" );
itemRendering.model( model ).variants( model );
}
} );
return this;
}
@Override @Override
public IBlockBuilder item( BiFunction<Block, Item.Properties, BlockItem> factory ) public IBlockBuilder item( BiFunction<Block, Item.Properties, BlockItem> factory )
{ {
@@ -49,12 +49,6 @@ public interface IBlockBuilder
*/ */
IBlockBuilder disableItem(); IBlockBuilder disableItem();
/**
* Forces this block's item to uses a custom model, instead of using the default block state as the item model.
* The model has the same name as the registry name.
*/
IBlockBuilder useCustomItemModel();
IBlockBuilder item( BiFunction<Block, Item.Properties, BlockItem> factory ); IBlockBuilder item( BiFunction<Block, Item.Properties, BlockItem> factory );
<T extends IBlockDefinition> T build(); <T extends IBlockDefinition> T build();
@@ -19,6 +19,7 @@
package appeng.client.render.tesr; package appeng.client.render.tesr;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@@ -47,6 +48,10 @@ import appeng.tile.grindstone.TileCrank;
public class CrankTESR extends TileEntityRenderer<TileCrank> public class CrankTESR extends TileEntityRenderer<TileCrank>
{ {
public CrankTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override @Override
public void render( TileCrank te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ ) public void render( TileCrank te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ )
{ {
@@ -64,7 +64,7 @@ public class ContainerSkyChest extends AEBaseContainer
public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
BlockPos pos = buf.readBlockPos(); BlockPos pos = buf.readBlockPos();
TileEntity te = Minecraft.getInstance().player.world.getTileEntity(pos); TileEntity te = inv.player.world.getTileEntity(pos);
if (te instanceof TileSkyChest) { if (te instanceof TileSkyChest) {
return new ContainerSkyChest(windowId, inv, (TileSkyChest) te); return new ContainerSkyChest(windowId, inv, (TileSkyChest) te);
} }
@@ -22,22 +22,28 @@ package appeng.core.api.definitions;
import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks; import appeng.api.definitions.IBlocks;
import appeng.api.definitions.ITileDefinition; import appeng.api.definitions.ITileDefinition;
import appeng.block.grindstone.BlockCrank;
import appeng.block.grindstone.BlockGrinder;
import appeng.block.misc.BlockQuartzFixture; import appeng.block.misc.BlockQuartzFixture;
import appeng.block.spatial.BlockMatrixFrame; import appeng.block.spatial.BlockMatrixFrame;
import appeng.block.storage.BlockSkyChest; import appeng.block.storage.BlockSkyChest;
import appeng.bootstrap.*; import appeng.bootstrap.*;
import appeng.bootstrap.definitions.TileEntityDefinition; import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.client.render.tesr.CrankTESR;
import appeng.client.render.tesr.SkyChestTESR; import appeng.client.render.tesr.SkyChestTESR;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.decorative.AEDecorativeBlock; import appeng.decorative.AEDecorativeBlock;
import appeng.decorative.solid.*; import appeng.decorative.solid.*;
import appeng.tile.grindstone.TileCrank;
import appeng.tile.grindstone.TileGrinder;
import appeng.tile.storage.TileSkyChest; import appeng.tile.storage.TileSkyChest;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ToolType;
import static appeng.decorative.solid.BlockSkyStone.SkystoneType; import static appeng.decorative.solid.BlockSkyStone.SkystoneType;
@@ -225,16 +231,22 @@ public final class ApiBlocks implements IBlocks
// .tileEntity( new TileEntityDefinition( TileSkyCompass.class ) ) // .tileEntity( new TileEntityDefinition( TileSkyCompass.class ) )
// .rendering( new SkyCompassRendering() ) // .rendering( new SkyCompassRendering() )
// .build(); // .build();
// this.grindstone = registry.block( "grindstone", BlockGrinder::new ) this.grindstone = registry.block( "grindstone", () -> new BlockGrinder(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.2f)) )
// .features( AEFeature.GRIND_STONE ) .features( AEFeature.GRIND_STONE )
// .tileEntity( new TileEntityDefinition( TileGrinder.class ) ) .tileEntity( registry.tileEntity("grindstone", TileGrinder.class, TileGrinder::new ).build() )
// .build(); .build();
// this.crank = registry.block( "crank", BlockCrank::new ) this.crank = registry.block( "crank", () -> new BlockCrank(Block.Properties.create(Material.WOOD).harvestTool(ToolType.AXE).harvestLevel(0).notSolid()) )
// .features( AEFeature.GRIND_STONE ) .features( AEFeature.GRIND_STONE )
// .tileEntity( new TileEntityDefinition( TileCrank.class ) ) .tileEntity( registry.tileEntity("crank", TileCrank.class, TileCrank::new )
// .rendering( new CrankRendering() ) .rendering(new TileEntityRenderingCustomizer<TileCrank>() {
// .useCustomItemModel() @Override
// .build(); @OnlyIn(Dist.CLIENT)
public void customize(TileEntityRendering<TileCrank> rendering) {
rendering.tileEntityRenderer(CrankTESR::new);
}
})
.build() )
.build();
// this.inscriber = registry.block( "inscriber", BlockInscriber::new ) // this.inscriber = registry.block( "inscriber", BlockInscriber::new )
// .features( AEFeature.INSCRIBER ) // .features( AEFeature.INSCRIBER )
// .tileEntity( new TileEntityDefinition( TileInscriber.class ) ) // .tileEntity( new TileEntityDefinition( TileInscriber.class ) )
@@ -96,7 +96,7 @@ public class TileCubeGenerator extends AEBaseTile implements ITickableTileEntity
{ {
this.is = ItemStack.EMPTY; this.is = ItemStack.EMPTY;
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
this.size--; this.size--;
} }
@@ -63,7 +63,7 @@ public class ToolDebugCard extends AEBaseItem
return EnumActionResult.PASS; return EnumActionResult.PASS;
} }
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
int grids = 0; int grids = 0;
int totalNodes = 0; int totalNodes = 0;
@@ -57,7 +57,7 @@ public class ToolReplicatorCard extends AEBaseItem
int y = pos.getY(); int y = pos.getY();
int z = pos.getZ(); int z = pos.getZ();
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
if( world.getTileEntity( pos ) instanceof IGridHost ) if( world.getTileEntity( pos ) instanceof IGridHost )
{ {
@@ -48,9 +48,9 @@ public class BlockFluidInterface extends AEBaseTileBlock
@Override @Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) 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 TileEntity tg = this.getTileEntity( w, pos ); final TileEntity tg = this.getTileEntity( w, pos );
@@ -60,8 +60,8 @@ public class BlockFluidInterface extends AEBaseTileBlock
{ {
Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_FLUID_INTERFACE ); Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_FLUID_INTERFACE );
} }
return true; return ActionResultType.SUCCESS;
} }
return false; return ActionResultType.PASS;
} }
} }
@@ -225,7 +225,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
{ {
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
Hand hand = context.getHand(); Hand hand = context.getHand();
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
final TileEntity te = context.getWorld().getTileEntity( context.getPos() ); final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
IItemHandler upgrades = null; IItemHandler upgrades = null;
@@ -76,7 +76,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
private boolean clearPattern( final ItemStack stack, final PlayerEntity player ) private boolean clearPattern( final ItemStack stack, final PlayerEntity player )
{ {
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
if( Platform.isClient() ) if( Platform.isClient() )
{ {
@@ -170,7 +170,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player ) private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player )
{ {
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
if( Platform.isClient() ) if( Platform.isClient() )
{ {
@@ -57,7 +57,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand ) public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand )
{ {
if( p.isShiftKeyDown() ) if( p.isCrouching() )
{ {
this.encode( p.getHeldItem( hand ), p ); this.encode( p.getHeldItem( hand ), p );
p.swingArm( hand ); p.swingArm( hand );
@@ -70,7 +70,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public boolean itemInteractionForEntity( ItemStack is, final PlayerEntity player, final LivingEntity target, final Hand hand ) public boolean itemInteractionForEntity( ItemStack is, final PlayerEntity player, final LivingEntity target, final Hand hand )
{ {
if( target instanceof PlayerEntity && !player.isShiftKeyDown() ) if( target instanceof PlayerEntity && !player.isCrouching() )
{ {
if( player.isCreative() ) if( player.isCreative() )
{ {
@@ -198,7 +198,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@Override @Override
public ActionResultType onItemUse( ItemUseContext context ) public ActionResultType onItemUse( ItemUseContext context )
{ {
if( context.getPlayer().isShiftKeyDown() ) if( context.getPlayer().isCrouching() )
{ {
if( !context.getPlayer().world.isRemote ) if( !context.getPlayer().world.isRemote )
{ {
@@ -215,7 +215,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@Override @Override
public ActionResult<ItemStack> onItemRightClick( World w, PlayerEntity player, Hand hand ) public ActionResult<ItemStack> onItemRightClick( World w, PlayerEntity player, Hand hand )
{ {
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
if( !w.isRemote ) if( !w.isRemote )
{ {
@@ -103,7 +103,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
{ {
return ActionResultType.FAIL; return ActionResultType.FAIL;
} }
else if( context.getPlayer().isShiftKeyDown() ) else if( context.getPlayer().isCrouching() )
{ {
return ActionResultType.PASS; return ActionResultType.PASS;
} }
@@ -138,7 +138,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
} }
final Block b = w.getBlockState( pos ).getBlock(); final Block b = w.getBlockState( pos ).getBlock();
if( !p.isShiftKeyDown() ) if( !p.isCrouching() )
{ {
final TileEntity te = w.getTileEntity( pos ); final TileEntity te = w.getTileEntity( pos );
if( !( te instanceof IGridHost ) ) if( !( te instanceof IGridHost ) )
@@ -152,7 +152,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
} }
} }
if( !p.isShiftKeyDown() ) if( !p.isCrouching() )
{ {
if( p.openContainer instanceof AEBaseContainer ) if( p.openContainer instanceof AEBaseContainer )
{ {
@@ -188,7 +188,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
} }
} }
if( p.isShiftKeyDown() ) if( p.isCrouching() )
{ {
this.cycleColors( is, paintBall, 1 ); this.cycleColors( is, paintBall, 1 );
} }
@@ -256,7 +256,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
final BlockState state = w.getBlockState( pos ); final BlockState state = w.getBlockState( pos );
final Block blockID = state.getBlock(); final Block blockID = state.getBlock();
if( p.isShiftKeyDown() ) if( p.isCrouching() )
{ {
if( this.canCool( state ) ) if( this.canCool( state ) )
{ {
+1 -1
View File
@@ -444,7 +444,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
final String name = is.getTranslationKey(); final String name = is.getTranslationKey();
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
final CompoundNBT data = this.downloadSettings( SettingsFrom.MEMORY_CARD ); final CompoundNBT data = this.downloadSettings( SettingsFrom.MEMORY_CARD );
if( data != null ) if( data != null )
@@ -818,7 +818,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
// forge sends activate even when sneaking in some cases (eg emtpy hand) // forge sends activate even when sneaking in some cases (eg emtpy hand)
// if sneaking try shift activate first. // if sneaking try shift activate first.
if( player.isShiftKeyDown() && p.part.onShiftActivate( player, hand, pos ) ) if( player.isCrouching() && p.part.onShiftActivate( player, hand, pos ) )
{ {
return true; return true;
} }
@@ -833,7 +833,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
final SelectedPart p = this.selectPart( hitVec ); final SelectedPart p = this.selectPart( hitVec );
if( p != null && p.part != null ) if( p != null && p.part != null )
{ {
if( player.isShiftKeyDown() ) if( player.isCrouching() )
{ {
return p.part.onShiftClicked( player, hand, hitVec ); return p.part.onShiftClicked( player, hand, hitVec );
} }
@@ -79,7 +79,7 @@ public class PartPlacement
return ActionResultType.FAIL; return ActionResultType.FAIL;
} }
if( !held.isEmpty() && Platform.isWrench( player, held, pos ) && player.isShiftKeyDown() ) if( !held.isEmpty() && Platform.isWrench( player, held, pos ) && player.isCrouching() )
{ {
if( !Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) ) if( !Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) )
{ {
@@ -200,7 +200,7 @@ public class PartPlacement
if( held.isEmpty() ) if( held.isEmpty() )
{ {
final Block block = world.getBlockState( pos ).getBlock(); final Block block = world.getBlockState( pos ).getBlock();
if( host != null && player.isShiftKeyDown() && block != null ) if( host != null && player.isCrouching() && block != null )
{ {
final LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) ); final LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
final RayTraceResult mop = block.getRayTraceResult( world.getBlockState( pos ), world, pos, dir.getA(), dir.getB(), mop ); final RayTraceResult mop = block.getRayTraceResult( world.getBlockState( pos ), world, pos, dir.getA(), dir.getB(), mop );
@@ -325,7 +325,7 @@ public class PartPlacement
if( sp.part != null ) if( sp.part != null )
{ {
if( !player.isShiftKeyDown() && sp.part.onActivate( player, hand, mop.hitVec ) ) if( !player.isCrouching() && sp.part.onActivate( player, hand, mop.hitVec ) )
{ {
return ActionResult.resultFail( null ); return ActionResult.resultFail( null );
} }
@@ -437,7 +437,7 @@ public class PartPlacement
boolean supportedItem = items.memoryCard().isSameAs( held ); boolean supportedItem = items.memoryCard().isSameAs( held );
supportedItem |= items.colorApplicator().isSameAs( held ); supportedItem |= items.colorApplicator().isSameAs( held );
if( event.getPlayer().isShiftKeyDown() && !held.isEmpty() && supportedItem ) if( event.getPlayer().isCrouching() && !held.isEmpty() && supportedItem )
{ {
NetworkHandler.instance().sendToServer( new PacketClick( event.getPos(), event.getFace(), 0, 0, 0, event.getHand() ) ); NetworkHandler.instance().sendToServer( new PacketClick( event.getPos(), event.getFace(), 0, 0, 0, event.getHand() ) );
} }
@@ -28,6 +28,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -51,6 +52,10 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
private int hits = 0; private int hits = 0;
private int rotation = 0; private int rotation = 0;
public TileCrank(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
public void tick() public void tick()
{ {
@@ -24,6 +24,7 @@ import java.util.List;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper; import net.minecraftforge.items.wrapper.RangedWrapper;
@@ -47,6 +48,10 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new GrinderFilter() ); private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new GrinderFilter() );
private int points; private int points;
public TileGrinder(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
public void setOrientation( final Direction inForward, final Direction inUp ) public void setOrientation( final Direction inForward, final Direction inUp )
{ {