Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/core'
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrayfish committed Dec 5, 2017
2 parents ea10f4a + 0d11cf2 commit a817175
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 9 deletions.
50 changes: 43 additions & 7 deletions src/main/java/com/mrcrayfish/device/block/BlockLaptop.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.mrcrayfish.device.MrCrayfishDeviceMod;
import com.mrcrayfish.device.core.Laptop;
import com.mrcrayfish.device.init.DeviceItems;
import com.mrcrayfish.device.object.Bounds;
import com.mrcrayfish.device.tileentity.TileEntityLaptop;

import com.mrcrayfish.device.util.TileEntityUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -37,9 +39,13 @@
public class BlockLaptop extends BlockHorizontal implements ITileEntityProvider
{
public static final PropertyEnum TYPE = PropertyEnum.create("type", Type.class);

private static final AxisAlignedBB COLLISION_BOX = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.6, 1.0);


private static final AxisAlignedBB[] SCREEN_BOXES = new Bounds(13 * 0.0625, 0.0625, 1 * 0.0625, 1.0, 12 * 0.0625, 0.9375).getRotatedBounds();
private static final AxisAlignedBB BODY_OPEN_BOX = new AxisAlignedBB(1 * 0.0625, 0.0, 1 * 0.0625, 13 * 0.0625, 1 * 0.0625, 15 * 0.0625);
private static final AxisAlignedBB BODY_CLOSED_BOX = new AxisAlignedBB(1 * 0.0625, 0.0, 1 * 0.0625, 13 * 0.0625, 2 * 0.0625, 15 * 0.0625);
private static final AxisAlignedBB SELECTION_BOX_OPEN = new AxisAlignedBB(0, 0, 0, 1, 12 * 0.0625, 1);
private static final AxisAlignedBB SELECTION_BOX_CLOSED = new AxisAlignedBB(0, 0, 0, 1, 3 * 0.0625, 1);

public BlockLaptop()
{
super(Material.ANVIL);
Expand All @@ -64,16 +70,46 @@ public boolean isFullCube(IBlockState state)
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return COLLISION_BOX;
TileEntity tileEntity = source.getTileEntity(pos);
if(tileEntity instanceof TileEntityLaptop)
{
TileEntityLaptop laptop = (TileEntityLaptop) tileEntity;
if(laptop.open)
{
return SELECTION_BOX_OPEN;
}
else
{
return SELECTION_BOX_CLOSED;
}
}
return FULL_BLOCK_AABB;
}

@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
super.addCollisionBoxToList(pos, entityBox, collidingBoxes, COLLISION_BOX);
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_)
{
TileEntity tileEntity = worldIn.getTileEntity(pos);
if(tileEntity instanceof TileEntityLaptop)
{
TileEntityLaptop laptop = (TileEntityLaptop) tileEntity;
if(laptop.open)
{
Block.addCollisionBoxToList(pos, entityBox, collidingBoxes, BODY_OPEN_BOX);
Block.addCollisionBoxToList(pos, entityBox, collidingBoxes, SCREEN_BOXES[state.getValue(FACING).getHorizontalIndex()]);
}
else
{
Block.addCollisionBoxToList(pos, entityBox, collidingBoxes, BODY_CLOSED_BOX);
}
return;
}
Block.addCollisionBoxToList(pos, entityBox, collidingBoxes, FULL_BLOCK_AABB);
}

@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
{
IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
return state.withProperty(FACING, placer.getHorizontalFacing());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mrcrayfish/device/core/Laptop.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Laptop(TileEntityLaptop laptop)
this.currentWallpaper = 0;
}
Laptop.system = this;
pos = laptop.getPos();
Laptop.pos = laptop.getPos();
}

@Nullable
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mrcrayfish/device/core/TaskBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class TaskBar
{
public static final ResourceLocation APP_BAR_GUI = new ResourceLocation("cdm:textures/gui/application_bar.png");

private static final int APPS_DISPLAYED = MrCrayfishDeviceMod.DEVELOPER_MODE ? 18 : 10;
private static final int APPS_DISPLAYED = MrCrayfishDeviceMod.DEVELOPER_MODE ? 18 : 20;
public static final int BAR_HEIGHT = 18;

private Button btnLeft;
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/mrcrayfish/device/object/Bounds.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.mrcrayfish.device.object;

import com.mrcrayfish.device.util.CollisionHelper;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;

/**
* Author: MrCrayfish
*/
Expand All @@ -17,4 +21,23 @@ public Bounds(double x1, double y1, double z1, double x2, double y2, double z2)
this.y2 = y2;
this.z2 = z2;
}

public AxisAlignedBB toAABB()
{
return new AxisAlignedBB(x1, y1, z1, x2, y2, z2);
}

public AxisAlignedBB getRotation(EnumFacing facing)
{
return CollisionHelper.getBlockBounds(facing, this);
}

public AxisAlignedBB[] getRotatedBounds()
{
AxisAlignedBB boundsNorth = CollisionHelper.getBlockBounds(EnumFacing.NORTH, this);
AxisAlignedBB boundsEast = CollisionHelper.getBlockBounds(EnumFacing.EAST, this);
AxisAlignedBB boundsSouth = CollisionHelper.getBlockBounds(EnumFacing.SOUTH, this);
AxisAlignedBB boundsWest = CollisionHelper.getBlockBounds(EnumFacing.WEST, this);
return new AxisAlignedBB[] { boundsSouth, boundsWest, boundsNorth, boundsEast };
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": {
"particle": "blocks/anvil_base",
"0": "blocks/cauldron_side",
"1": "blocks/cauldron_inner",
"2": "blocks/wool_colored_red"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a817175

Please sign in to comment.