No pushing

- Fixed Schematicannon asking for "Air" items
- Made several blocks immovable by piston
This commit is contained in:
simibubi 2019-11-07 12:00:27 +01:00
parent 44dc7e054b
commit 7f0ba8211d
9 changed files with 51 additions and 23 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = 'mc1.14.4_v0.1.1a' version = 'mc1.14.4_v0.1.1b'
group = 'com.simibubi.create' group = 'com.simibubi.create'
archivesBaseName = 'create' archivesBaseName = 'create'

View file

@ -28,7 +28,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.1.1a"; public static final String VERSION = "0.1.1b";
public static Logger logger = LogManager.getLogger(); public static Logger logger = LogManager.getLogger();
public static ItemGroup creativeTab = new CreateItemGroup(); public static ItemGroup creativeTab = new CreateItemGroup();

View file

@ -17,6 +17,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -148,5 +149,10 @@ public class BeltFunnelBlock extends HorizontalBlock implements IBeltAttachment,
return true; return true;
} }
@Override
public PushReaction getPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
@ -35,7 +36,7 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
SHAPE_SOUTH = makeCuboidShape(4, 2, 11, 12, 10, 17), SHAPE_WEST = makeCuboidShape(-1, 2, 4, 5, 10, 12), SHAPE_SOUTH = makeCuboidShape(4, 2, 11, 12, 10, 17), SHAPE_WEST = makeCuboidShape(-1, 2, 4, 5, 10, 12),
SHAPE_EAST = makeCuboidShape(11, 2, 4, 17, 10, 12); SHAPE_EAST = makeCuboidShape(11, 2, 4, 17, 10, 12);
private static final List<Vec3d> itemPositions = new ArrayList<>(Direction.values().length); private static final List<Vec3d> itemPositions = new ArrayList<>(Direction.values().length);
public ExtractorBlock() { public ExtractorBlock() {
super(Properties.from(Blocks.ANDESITE)); super(Properties.from(Blocks.ANDESITE));
setDefaultState(getDefaultState().with(POWERED, false)); setDefaultState(getDefaultState().with(POWERED, false));
@ -47,28 +48,28 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
builder.add(HORIZONTAL_FACING, POWERED); builder.add(HORIZONTAL_FACING, POWERED);
super.fillStateContainer(builder); super.fillStateContainer(builder);
} }
@Override @Override
public boolean showsCount() { public boolean showsCount() {
return true; return true;
} }
@Override @Override
public boolean hasTileEntity(BlockState state) { public boolean hasTileEntity(BlockState state) {
return true; return true;
} }
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new ExtractorTileEntity(); return new ExtractorTileEntity();
} }
@Override @Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) { BlockRayTraceResult hit) {
return handleActivatedFilterSlots(state, worldIn, pos, player, handIn, hit); return handleActivatedFilterSlots(state, worldIn, pos, player, handIn, hit);
} }
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
BlockState state = getDefaultState(); BlockState state = getDefaultState();
@ -86,7 +87,7 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
updateObservedInventory(state, worldIn, pos); updateObservedInventory(state, worldIn, pos);
} }
@Override @Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
if (world.isRemote()) if (world.isRemote())
@ -95,18 +96,18 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
return; return;
updateObservedInventory(state, world, pos); updateObservedInventory(state, world, pos);
} }
private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) { private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) {
IExtractor extractor = (IExtractor) world.getTileEntity(pos); IExtractor extractor = (IExtractor) world.getTileEntity(pos);
if (extractor == null) if (extractor == null)
return; return;
extractor.neighborChanged(); extractor.neighborChanged();
} }
private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) { private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) {
return observing.equals(pos.offset(state.get(HORIZONTAL_FACING))); return observing.equals(pos.offset(state.get(HORIZONTAL_FACING)));
} }
@Override @Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
@ -159,7 +160,7 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
itemPositions.add(position); itemPositions.add(position);
} }
} }
@Override @Override
public float getItemHitboxScale() { public float getItemHitboxScale() {
return 1.76f / 16f; return 1.76f / 16f;
@ -176,4 +177,9 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
return state.get(HORIZONTAL_FACING).getOpposite(); return state.get(HORIZONTAL_FACING).getOpposite();
} }
@Override
public PushReaction getPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
} }

View file

@ -35,7 +35,9 @@ public interface IInventoryManipulator {
if (!invState.hasTileEntity()) if (!invState.hasTileEntity())
return false; return false;
TileEntity invTE = world.getTileEntity(invPos); TileEntity invTE = world.getTileEntity(invPos);
if (invTE == null)
return false;
LazyOptional<IItemHandler> inventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); LazyOptional<IItemHandler> inventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
setInventory(inventory); setInventory(inventory);
if (inventory.isPresent()) { if (inventory.isPresent()) {

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
@ -238,4 +239,9 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements IBloc
return state.get(FACING); return state.get(FACING);
} }
@Override
public PushReaction getPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
} }

View file

@ -6,6 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.IntegerProperty; import net.minecraft.state.IntegerProperty;
@ -136,5 +137,10 @@ public class StockswitchBlock extends HorizontalBlock {
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new StockswitchTileEntity(); return new StockswitchTileEntity();
} }
@Override
public PushReaction getPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
} }

View file

@ -23,6 +23,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -56,7 +57,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
public static final int NEIGHBOUR_CHECKING = 100; public static final int NEIGHBOUR_CHECKING = 100;
public static final int MAX_ANCHOR_DISTANCE = 256; public static final int MAX_ANCHOR_DISTANCE = 256;
public enum State { public enum State {
STOPPED, PAUSED, RUNNING; STOPPED, PAUSED, RUNNING;
} }
@ -169,13 +170,13 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB; return INFINITE_EXTENT_AABB;
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {
return super.getMaxRenderDistanceSquared() * 16; return super.getMaxRenderDistanceSquared() * 16;
} }
public SchematicannonTileEntity(TileEntityType<?> tileEntityTypeIn) { public SchematicannonTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn); super(tileEntityTypeIn);
attachedInventories = new LinkedList<>(); attachedInventories = new LinkedList<>();
@ -454,15 +455,15 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
} }
BlockState blockState = blockReader.getBlockState(target); BlockState blockState = blockReader.getBlockState(target);
if (!shouldPlace(target, blockState)) { ItemStack requiredItem = getItemForBlock(blockState);
if (!shouldPlace(target, blockState) || requiredItem.isEmpty()) {
statusMsg = "searching"; statusMsg = "searching";
blockSkipped = true; blockSkipped = true;
return; return;
} }
// Find Item // Find item
ItemStack requiredItem = getItemForBlock(blockState);
if (blockState.has(BlockStateProperties.SLAB_TYPE) if (blockState.has(BlockStateProperties.SLAB_TYPE)
&& blockState.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) && blockState.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE)
requiredItem.setCount(2); requiredItem.setCount(2);
@ -547,7 +548,8 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
} }
protected ItemStack getItemForBlock(BlockState blockState) { protected ItemStack getItemForBlock(BlockState blockState) {
return new ItemStack(BlockItem.BLOCK_TO_ITEM.getOrDefault(blockState.getBlock(), Items.AIR)); Item item = BlockItem.BLOCK_TO_ITEM.getOrDefault(blockState.getBlock(), Items.AIR);
return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item);
} }
protected boolean findItemInAttachedInventories(ItemStack requiredItem) { protected boolean findItemInAttachedInventories(ItemStack requiredItem) {

View file

@ -4,7 +4,7 @@ loaderVersion="[28,)"
[[mods]] [[mods]]
modId="create" modId="create"
version="0.1.1a" version="0.1.1b"
displayName="Create" displayName="Create"
#updateJSONURL="" #updateJSONURL=""
authors="simibubi" authors="simibubi"