-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FUCK, CHANGES EVERYWHERE. Oh and, added biomes in level 0 (experimental)
- Loading branch information
1 parent
72b9db2
commit a2a5644
Showing
32 changed files
with
734 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/net/limit/cubliminal/block/custom/ChairBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package net.limit.cubliminal.block.custom; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.DirectionProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.BlockMirror; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.util.shape.VoxelShapes; | ||
import net.minecraft.world.BlockView; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ChairBlock extends SeatBlock implements Waterloggable { | ||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING; | ||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; | ||
|
||
protected static final VoxelShape EAST_SHAPE = VoxelShapes.union( | ||
Block.createCuboidShape(0, 11, 0, 2, 27, 16), | ||
Block.createCuboidShape(0, 0, 14, 2, 11, 16), | ||
Block.createCuboidShape(0, 0, 0, 2, 11, 2), | ||
Block.createCuboidShape(14, 0, 0, 16, 9, 2), | ||
Block.createCuboidShape(14, 0, 14, 16, 9, 16), | ||
Block.createCuboidShape(2, 9, 0, 16, 11, 16)); | ||
protected static final VoxelShape WEST_SHAPE = VoxelShapes.union( | ||
Block.createCuboidShape(14, 11, 0, 16, 27, 16), | ||
Block.createCuboidShape(14, 0, 0, 16, 11, 2), | ||
Block.createCuboidShape(14, 0, 14, 16, 11, 16), | ||
Block.createCuboidShape(0, 0, 14, 2, 9, 16), | ||
Block.createCuboidShape(0, 0, 0, 2, 9, 2), | ||
Block.createCuboidShape(0, 9, 0, 14, 11, 16)); | ||
protected static final VoxelShape SOUTH_SHAPE = VoxelShapes.union( | ||
Block.createCuboidShape(0, 11, 0, 16, 27, 2), | ||
Block.createCuboidShape(0, 0, 0, 2, 11, 2), | ||
Block.createCuboidShape(14, 0, 0, 16, 11, 2), | ||
Block.createCuboidShape(14, 0, 14, 16, 9, 16), | ||
Block.createCuboidShape(0, 0, 14, 2, 9, 16), | ||
Block.createCuboidShape(0, 9, 2, 16, 11, 16)); | ||
protected static final VoxelShape NORTH_SHAPE = VoxelShapes.union( | ||
Block.createCuboidShape(0, 11, 14, 16, 27, 16), | ||
Block.createCuboidShape(14, 0, 14, 16, 11, 16), | ||
Block.createCuboidShape(0, 0, 14, 2, 11, 16), | ||
Block.createCuboidShape(0, 0, 0, 2, 9, 2), | ||
Block.createCuboidShape(14, 0, 0, 16, 9, 2), | ||
Block.createCuboidShape(0, 9, 0, 16, 11, 14)); | ||
|
||
public ChairBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH).with(WATERLOGGED, false)); | ||
} | ||
|
||
@Override | ||
public float setPassengerYaw(BlockState state, Entity entity) { | ||
return state.get(FACING).asRotation(); | ||
} | ||
|
||
@Override | ||
public float seatHeight(BlockState state) { | ||
return 0.7f; | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { | ||
builder.add(FACING, WATERLOGGED); | ||
} | ||
|
||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { | ||
return switch (state.get(FACING)) { | ||
case SOUTH -> SOUTH_SHAPE; | ||
case WEST -> WEST_SHAPE; | ||
case EAST -> EAST_SHAPE; | ||
default -> NORTH_SHAPE; | ||
}; | ||
} | ||
|
||
@Override | ||
public BlockState rotate(BlockState state, BlockRotation rotation) { | ||
return state.with(FACING, rotation.rotate(state.get(FACING))); | ||
} | ||
|
||
@Override | ||
public BlockState mirror(BlockState state, BlockMirror mirror) { | ||
return state.rotate(mirror.getRotation(state.get(FACING))); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
return this.getDefaultState().with(FACING, ctx.getHorizontalPlayerFacing().getOpposite()) | ||
.with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/net/limit/cubliminal/block/custom/SeatBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package net.limit.cubliminal.block.custom; | ||
|
||
import com.google.common.base.Predicates; | ||
import net.limit.cubliminal.entity.custom.SeatEntity; | ||
import net.limit.cubliminal.init.CubliminalEntities; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.SpawnReason; | ||
import net.minecraft.entity.ai.pathing.NavigationType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Box; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.List; | ||
|
||
public class SeatBlock extends Block { | ||
public SeatBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
public float setPassengerYaw(BlockState state, Entity entity) { | ||
return entity.getYaw(); | ||
} | ||
|
||
public float seatHeight(BlockState state) { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
List<SeatEntity> list = world.getEntitiesByClass(SeatEntity.class, new Box(pos), Predicates.alwaysTrue()); | ||
if (world.isClient()) { | ||
return ActionResult.CONSUME; | ||
} else if (list.isEmpty()) { | ||
SeatEntity seatEntity = CubliminalEntities.SEAT_ENTITY.spawn((ServerWorld) world, pos, SpawnReason.TRIGGERED); | ||
player.startRiding(seatEntity, true); | ||
} | ||
return ActionResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/net/limit/cubliminal/entity/client/SeatRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.limit.cubliminal.entity.client; | ||
|
||
import net.limit.cubliminal.entity.custom.SeatEntity; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class SeatRenderer extends EntityRenderer<SeatEntity> { | ||
public SeatRenderer(EntityRendererFactory.Context ctx) { | ||
super(ctx); | ||
} | ||
|
||
@Override | ||
public Identifier getTexture(SeatEntity entity) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/net/limit/cubliminal/entity/custom/SeatEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package net.limit.cubliminal.entity.custom; | ||
|
||
import com.google.common.base.Predicates; | ||
import com.google.common.collect.Lists; | ||
import net.limit.cubliminal.block.custom.SeatBlock; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.*; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Box; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.List; | ||
import java.util.function.Predicate; | ||
|
||
public class SeatEntity extends Entity { | ||
|
||
public SeatEntity(EntityType<? extends SeatEntity> type, World world) { | ||
super(type, world); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
if (this.getWorld().isClient()) return; | ||
if (!(this.getBlockStateAtPos().getBlock() instanceof SeatBlock) | ||
|| !this.getWorld().getEntitiesByClass(SeatEntity.class, new Box(this.getBlockPos()) | ||
, Predicate.not(Predicates.alwaysTrue())).isEmpty() | ||
|| this.getPassengerList().isEmpty()) this.discard(); | ||
if (this.isSubmergedInWater()) this.removeAllPassengers(); | ||
} | ||
|
||
@Override | ||
public Vec3d updatePassengerForDismount(LivingEntity passenger) { | ||
Vec3d vec3d = this.getBlockPos().toCenterPos(); | ||
double offset = 0; | ||
for (EntityPose entityPose : passenger.getPoses()) { | ||
passenger.setPose(entityPose); | ||
BlockState state = this.getBlockStateAtPos(); | ||
if (state.getBlock() instanceof SeatBlock seatBlock) offset = seatBlock.seatHeight(state); | ||
} | ||
|
||
return vec3d.add(0, offset - 0.5, 0); | ||
} | ||
|
||
@Override | ||
public Vec3d getPassengerRidingPos(Entity passenger) { | ||
BlockPos pos = this.getBlockPos(); | ||
BlockState state = this.getBlockStateAtPos(); | ||
double seatHeight = 0; | ||
if (state.getBlock() instanceof SeatBlock seatBlock) seatHeight = seatBlock.seatHeight(state); | ||
return pos.toCenterPos().add(0, seatHeight - 0.5, 0); | ||
} | ||
|
||
@Override | ||
public boolean canAddPassenger(Entity passenger) { | ||
return this.getPassengerList().isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean isInvulnerable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void addPassenger(Entity passenger) { | ||
BlockState state = this.getBlockStateAtPos(); | ||
if (state.getBlock() instanceof SeatBlock seatBlock) passenger.setYaw(seatBlock.setPassengerYaw(state, passenger)); | ||
super.addPassenger(passenger); | ||
} | ||
|
||
@Override | ||
protected boolean canStartRiding(Entity entity) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void initDataTracker() { | ||
} | ||
|
||
@Override | ||
protected void readCustomDataFromNbt(NbtCompound nbt) { | ||
} | ||
|
||
@Override | ||
protected void writeCustomDataToNbt(NbtCompound nbt) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.