Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 16 additions & 2 deletions src/main/java/com/mrcrayfish/device/block/BlockLaptop.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import com.mrcrayfish.device.MrCrayfishDeviceMod;
import com.mrcrayfish.device.core.Laptop;
import com.mrcrayfish.device.entity.EntitySeat;
import com.mrcrayfish.device.gui.GuiHandler;
import com.mrcrayfish.device.init.DeviceItems;
import com.mrcrayfish.device.object.Bounds;
import com.mrcrayfish.device.tileentity.TileEntityLaptop;
import com.mrcrayfish.device.tileentity.TileEntityOfficeChair;
import com.mrcrayfish.device.util.SeatUtil;
import com.mrcrayfish.device.util.TileEntityUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
Expand All @@ -25,9 +29,12 @@
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.config.GuiUtils;
import org.lwjgl.input.Keyboard;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;

public class BlockLaptop extends BlockDevice implements ITileEntityProvider
{
Expand Down Expand Up @@ -102,8 +109,15 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
{
laptop.openClose();
}
}
else
}else if(playerIn.isRiding()){
if(worldIn.isRemote) {
if (!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && laptop.isOpen()) {
playerIn.openGui(MrCrayfishDeviceMod.instance, Laptop.ID, worldIn, pos.getX(), pos.getY(), pos.getZ());
} else {
laptop.openClose();
}
}
}else
{
if(side == state.getValue(FACING).rotateYCCW())
{
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/mrcrayfish/device/util/SeatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ public class SeatUtil
{
public static void createSeatAndSit(World worldIn, BlockPos pos, EntityPlayer playerIn, double yOffset)
{
List<EntitySeat> seats = worldIn.getEntitiesWithinAABB(EntitySeat.class, new AxisAlignedBB(pos));
if(!seats.isEmpty())
{
EntitySeat seat = seats.get(0);
if(seat.getRidingEntity() == null)
{
playerIn.startRiding(seat);
}
}
else
if(getNearestSeat(worldIn, pos) == null)
{
EntitySeat seat = new EntitySeat(worldIn, pos, yOffset);
worldIn.spawnEntity(seat);
playerIn.startRiding(seat);
}
}

public static EntitySeat getNearestSeat(World world, BlockPos pos){
List<EntitySeat> seats = world.getEntitiesWithinAABB(EntitySeat.class, new AxisAlignedBB(pos));
if(!seats.isEmpty()){
return seats.get(0);
}
return null;
}
}