Skip to content

Commit

Permalink
Mobs can now sit on cushions
Browse files Browse the repository at this point in the history
Change sconce model
Change mug texture
Change framed glass texture
  • Loading branch information
aqariio committed Nov 2, 2023
1 parent 9035e40 commit 38de3e0
Show file tree
Hide file tree
Showing 26 changed files with 704 additions and 1,403 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx2G
org.gradle.parallel = true

# Mod Properties
version = 1.5.0-beta.3
version = 1.5.0-beta.5
maven_group = aqario.furnishings
archives_base_name = furnishings

Expand Down
34 changes: 25 additions & 9 deletions src/main/java/aqario/furnishings/common/block/CushionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
Expand Down Expand Up @@ -49,10 +51,8 @@ public CushionBlock(Settings settings) {
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
Item item = player.getStackInHand(hand).getItem();
if (item instanceof BlockItem blockItem) {
if (blockItem.getBlock() instanceof CushionBlock) {
return ActionResult.PASS;
}
if (item instanceof BlockItem blockItem && blockItem.getBlock() instanceof CushionBlock) {
return ActionResult.PASS;
}
if (!hit.getSide().equals(Direction.DOWN)) {
if (unseat(state, world, pos)) {
Expand All @@ -65,15 +65,15 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
return ActionResult.PASS;
}



public boolean unseat(BlockState state, World world, BlockPos pos) {
if (state.get(OCCUPIED)) {
List<SeatEntity> list = world.getEntitiesByClass(SeatEntity.class, new Box(pos), entity -> true);
boolean unseated = false;
for (SeatEntity entity : list) {
if (!(entity.getFirstPassenger() instanceof PlayerEntity) &&
entity.getFirstPassenger() != null) {
if (entity.getFirstPassenger() instanceof PlayerEntity) {
continue;
}
if (entity.getFirstPassenger() != null) {
entity.delete();
unseated = true;
}
Expand Down Expand Up @@ -128,9 +128,20 @@ public boolean seat(LivingEntity livingEntity, World world, BlockPos pos) {
return false;
}

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (state.get(OCCUPIED) || entity instanceof PlayerEntity || !(entity instanceof LivingEntity livingEntity)) {
return;
}
if (entity instanceof MobEntity mobEntity && mobEntity.getTarget() != null) {
return;
}
seat(livingEntity, world, pos);
}

@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
return true;
}

@Override
Expand Down Expand Up @@ -160,6 +171,11 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
return SHAPE;
}

@Override
public PistonBehavior getPistonBehavior(BlockState state) {
return PistonBehavior.DESTROY;
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(OCCUPIED, WATERLOGGED);
Expand Down
35 changes: 18 additions & 17 deletions src/main/java/aqario/furnishings/common/entity/SeatEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,39 @@ protected void writeCustomDataToNbt(NbtCompound nbt) {

@Override
protected boolean canAddPassenger(Entity passenger) {
return this.getPassengerList().isEmpty();
return this.getPassengerList().size() < this.getMaxPassengers();
}

protected int getMaxPassengers() {
return 1;
}

@Override
public void tick() {
if (this.getFirstPassenger() != null && !(this.getWorld()).isClient) {
Entity entity = this.getFirstPassenger();
if (entity instanceof MobEntity mobEntity) {
if (mobEntity.getTarget() != null) {
delete();
return;
}
}
if (entity instanceof MobEntity mobEntity && mobEntity.getTarget() != null) {
delete();
return;
}
}
BlockPos cushionPos = this.getCushionPos();
if (cushionPos != null) {
BlockState cushionState = this.getWorld().getBlockState(cushionPos);
if (!(cushionState.getBlock() instanceof CushionBlock)) {
delete();
} else if (!((Boolean)cushionState.get(Properties.OCCUPIED))) {
this.getWorld().setBlockState(cushionPos, cushionState.with(Properties.OCCUPIED, true), 2);
}
} else {
if (cushionPos == null) {
delete();
}
}
BlockState cushionState = this.getWorld().getBlockState(cushionPos);
if (!(cushionState.getBlock() instanceof CushionBlock)) {
delete();
} else if (!((Boolean)cushionState.get(Properties.OCCUPIED))) {
this.getWorld().setBlockState(cushionPos, cushionState.with(Properties.OCCUPIED, true), 2);
}
}

public void delete() {
this.discard();
if (!(this.getWorld()).isClient) {
this.removeAllPassengers();
}
this.discard();
}

@Nullable
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/furnishings/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@
"entity.furnishings.scarecrow": "Scarecrow",
"entity.furnishings.statue": "Statue",

"subtitles.furnishings.block.cushion.sit": "Cushion fluffs"
"subtitles.furnishings.block.cushion.sit": "Seat cushions"
}
Original file line number Diff line number Diff line change
@@ -1,113 +1,7 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "furnishings:block/sconce",
"particle": "furnishings:block/sconce"
},
"elements": [
{
"from": [6, 3, 15],
"to": [10, 9, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [16, 8, 23]},
"faces": {
"north": {"uv": [12, 6, 16, 12], "texture": "#0"},
"east": {"uv": [15, 6, 16, 12], "texture": "#0"},
"south": {"uv": [12, 6, 16, 12], "texture": "#0", "cullface": "south"},
"west": {"uv": [12, 6, 13, 12], "texture": "#0"},
"up": {"uv": [12, 6, 16, 7], "texture": "#0"},
"down": {"uv": [12, 11, 16, 12], "texture": "#0"}
}
},
{
"from": [6, 6, 10],
"to": [10, 8, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [17, 15, 19]},
"faces": {
"north": {"uv": [5, 14, 9, 16], "texture": "#0"},
"east": {"uv": [0, 14, 5, 16], "texture": "#0"},
"south": {"uv": [0, 0, 0, 0], "texture": "#0"},
"west": {"uv": [5, 14, 0, 16], "texture": "#0"},
"up": {"uv": [12, 0, 16, 5], "rotation": 180, "texture": "#0"},
"down": {"uv": [12, 0, 16, 5], "texture": "#0"}
}
},
{
"from": [6, 11, 10],
"to": [6, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [0, 0, 0, 0], "texture": "#0"},
"east": {"uv": [9, 0, 5, 2], "texture": "#0"},
"south": {"uv": [0, 0, 0, 0], "texture": "#0"},
"west": {"uv": [5, 0, 9, 2], "texture": "#0"},
"up": {"uv": [0, 0, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 0], "texture": "#0"}
}
},
{
"from": [10, 11, 10],
"to": [10, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [0, 0, 0, 0], "texture": "#0"},
"east": {"uv": [5, 0, 9, 2], "texture": "#0"},
"south": {"uv": [0, 0, 0, 0], "texture": "#0"},
"west": {"uv": [9, 0, 5, 2], "texture": "#0"},
"up": {"uv": [0, 0, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 0], "texture": "#0"}
}
},
{
"from": [6, 11, 14],
"to": [10, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [9, 0, 5, 2], "texture": "#0"},
"east": {"uv": [0, 0, 0, 0], "texture": "#0"},
"south": {"uv": [5, 0, 9, 2], "texture": "#0"},
"west": {"uv": [0, 0, 0, 0], "texture": "#0"},
"up": {"uv": [0, 0, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 0], "texture": "#0"}
}
},
{
"from": [6, 11, 10],
"to": [10, 13, 10],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [5, 0, 9, 2], "texture": "#0"},
"east": {"uv": [0, 0, 0, 0], "texture": "#0"},
"south": {"uv": [9, 0, 5, 2], "texture": "#0"},
"west": {"uv": [0, 0, 0, 0], "texture": "#0"},
"up": {"uv": [0, 0, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 0], "texture": "#0"}
}
},
{
"from": [7, 2, 11],
"to": [9, 10, 13],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [6, 3, 8, 11], "texture": "#0"},
"east": {"uv": [6, 3, 8, 11], "texture": "#0"},
"south": {"uv": [6, 3, 8, 11], "texture": "#0"},
"west": {"uv": [6, 3, 8, 11], "texture": "#0"},
"up": {"uv": [0, 0, 0, 0], "texture": "#0"},
"down": {"uv": [6, 9, 8, 11], "texture": "#0"}
}
},
{
"from": [6, 10, 10],
"to": [10, 11, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [5, 2, 9, 3], "texture": "#0"},
"east": {"uv": [5, 2, 9, 3], "texture": "#0"},
"south": {"uv": [5, 2, 9, 3], "texture": "#0"},
"west": {"uv": [5, 2, 9, 3], "texture": "#0"},
"up": {"uv": [0, 4, 4, 8], "texture": "#0"},
"down": {"uv": [0, 4, 4, 8], "texture": "#0"}
}
}
]
}
"credit": "Made with Blockbench",
"parent": "furnishings:block/template_lever_sconce_off_wall",
"textures": {
"base": "furnishings:block/sconce"
}
}
Original file line number Diff line number Diff line change
@@ -1,116 +1,8 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "furnishings:block/sconce",
"1": "furnishings:block/sconce_fire",
"particle": "furnishings:block/sconce"
},
"elements": [
{
"from": [6, 3, 15],
"to": [10, 9, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [16, 8, 23]},
"faces": {
"north": {"uv": [12, 6, 16, 12], "texture": "#0"},
"east": {"uv": [15, 6, 16, 12], "texture": "#0"},
"south": {"uv": [12, 6, 16, 12], "texture": "#0", "cullface": "south"},
"west": {"uv": [12, 6, 13, 12], "texture": "#0"},
"up": {"uv": [12, 6, 16, 7], "texture": "#0"},
"down": {"uv": [12, 11, 16, 12], "texture": "#0"}
}
},
{
"from": [6, 6, 10],
"to": [10, 8, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [17, 15, 19]},
"faces": {
"north": {"uv": [5, 14, 9, 16], "texture": "#0"},
"east": {"uv": [0, 14, 5, 16], "texture": "#0"},
"west": {"uv": [5, 14, 0, 16], "texture": "#0"},
"up": {"uv": [12, 0, 16, 5], "rotation": 180, "texture": "#0"},
"down": {"uv": [12, 0, 16, 5], "texture": "#0"}
}
},
{
"from": [8, 10, 8],
"to": [8, 14, 12],
"shade": false,
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6, 10]},
"faces": {
"east": {"uv": [6, 12, 10, 16], "texture": "#1"},
"west": {"uv": [6, 12, 10, 16], "texture": "#1"}
}
},
{
"from": [6, 10, 10],
"to": [10, 14, 10],
"shade": false,
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6, 10]},
"faces": {
"north": {"uv": [6, 12, 10, 16], "texture": "#1"},
"south": {"uv": [6, 12, 10, 16], "texture": "#1"}
}
},
{
"from": [6, 11, 10],
"to": [6, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"east": {"uv": [9, 0, 5, 2], "texture": "#0"},
"west": {"uv": [5, 0, 9, 2], "texture": "#0"}
}
},
{
"from": [10, 11, 10],
"to": [10, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"east": {"uv": [5, 0, 9, 2], "texture": "#0"},
"west": {"uv": [9, 0, 5, 2], "texture": "#0"}
}
},
{
"from": [6, 11, 14],
"to": [10, 13, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [9, 0, 5, 2], "texture": "#0"},
"south": {"uv": [5, 0, 9, 2], "texture": "#0"}
}
},
{
"from": [6, 11, 10],
"to": [10, 13, 10],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [5, 0, 9, 2], "texture": "#0"},
"south": {"uv": [9, 0, 5, 2], "texture": "#0"}
}
},
{
"from": [7, 2, 11],
"to": [9, 10, 13],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [6, 3, 8, 11], "texture": "#0"},
"east": {"uv": [6, 3, 8, 11], "texture": "#0"},
"south": {"uv": [6, 3, 8, 11], "texture": "#0"},
"west": {"uv": [6, 3, 8, 11], "texture": "#0"},
"down": {"uv": [6, 9, 8, 11], "texture": "#0"}
}
},
{
"from": [6, 10, 10],
"to": [10, 11, 14],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 7, 12]},
"faces": {
"north": {"uv": [5, 2, 9, 3], "texture": "#0"},
"east": {"uv": [5, 2, 9, 3], "texture": "#0"},
"south": {"uv": [5, 2, 9, 3], "texture": "#0"},
"west": {"uv": [5, 2, 9, 3], "texture": "#0"},
"up": {"uv": [0, 0, 4, 4], "texture": "#0"},
"down": {"uv": [0, 4, 4, 8], "texture": "#0"}
}
}
]
}
"credit": "Made with Blockbench",
"parent": "furnishings:block/template_lever_sconce_wall",
"textures": {
"base": "furnishings:block/sconce",
"fire": "furnishings:block/sconce_fire"
}
}
Loading

0 comments on commit 38de3e0

Please sign in to comment.