Skip to content

Commit 5df2234

Browse files
committed
Sleeping bag, stumps and baskets
1 parent d24d83d commit 5df2234

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1839
-148
lines changed

changelog-next.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
- Added Long Flower Pot:
2-
- New Flower Pot type that can hold 3 plants (same as regular Flower Pot). The plants can be of different types.
3-
- It's rotated depending on player's facing direction.
4-
- Crafted with Flower Pot and 2 Bricks.
5-
- Added Wind Chime:
6-
- Decorative block, that moves in the wind.
7-
- Can be dyed with up to 5 different dyes at the same time.
8-
- Crafted with Chain, a Plank and 5 Iron Nuggets.
9-
- Canvas can now be placed on floors and ceilings.
10-
- Improved Tool Rack's hitbox, making it way smaller.
11-
- Tweaked some block particles.
12-
- Fixed Statues being visually in ground on first tick after placement.
1+
- Added Basket:
2+
- Storage block that can hold up to 5 stacks of items.
3+
- Keeps items inside when broken (like Shulker Boxes).
4+
- When placed under Rope or Chains, it will visually move up to connect to it.
5+
- Crafted with 2 Ropes, 5 Sticks and a Plank.
6+
- Added Sleeping Bags:
7+
- A 2x1 block that allows you to skip the night (like Beds).
8+
- Unlike a bed, it doesn't change player's spawn point.
9+
- Crafted with 3 wool blocks.
10+
- Has 16 colored variants.
11+
- Added Stumps:
12+
- A small log-like block you can sit on.
13+
- Crafted from 2 logs placed vertically.
14+
- Comes in regular and stripped variants.
15+
- Renamed all Shelves to Plain Shelf, to make it distinct from 1.21.9 Vanilla Shelf block.
16+
- You can now place Hanging Signs on Ropes.
17+
- Tweaked placement of Sign Posts to pain in direction depending on side of targeted face that was clicked.
18+
- Fixed some statues using wrong block in recipe.
19+
- Fixed missing texture references logs on client.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ loom_version=1.10-SNAPSHOT
1313
fabric_version=0.128.2+1.21.7
1414

1515
# Mod Properties
16-
mod_version = 0.8.2
16+
mod_version = 0.8.3
1717
maven_group = eu.pb4
1818
archives_base_name = polydecorations
1919

src/main/java/eu/pb4/polydecorations/block/DecorationsBlockEntities.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class DecorationsBlockEntities {
3232
DecorationsBlocks.WOODEN_MAILBOX.values().toArray(new Block[0]));
3333
public static final BlockEntityType<?> GLOBE = register("globe", GenericSingleItemBlockEntity::globe, DecorationsBlocks.GLOBE);
3434
public static final BlockEntityType<?> TRASHCAN = register("trashcan", TrashCanBlockEntity::new, DecorationsBlocks.TRASHCAN);
35+
public static final BlockEntityType<?> BASKET = register("basket", BasketBlockEntity::new, DecorationsBlocks.BASKET);
3536
public static final BlockEntityType<?> WIND_CHIME = register("wind_chime", WindChimeBlockEntity::new, DecorationsBlocks.WIND_CHIME);
3637

3738
public static final BlockEntityType<?> DISPLAY_CASE = register("display_case",

src/main/java/eu/pb4/polydecorations/block/DecorationsBlockTags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class DecorationsBlockTags {
1515
public static final TagKey<Block> TABLES = of("tables");
1616
public static final TagKey<Block> BRAZIERS = of("braziers");
1717
public static final TagKey<Block> SIGN_POSTS = of("sign_posts");
18+
public static final TagKey<Block> STUMPS = of("stumps");
19+
public static final TagKey<Block> SLEEPING_BAGS = of("stumps");
1820
public static final TagKey<Block> ALLOWED_INTERACTIONS_BLOCKS = TagKey.of(RegistryKeys.BLOCK, Identifier.of("goml", "allowed_interactions"));
1921

2022
private static TagKey<Block> of(String path) {

src/main/java/eu/pb4/polydecorations/block/DecorationsBlocks.java

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
import eu.pb4.polydecorations.block.extension.WallAttachedLanternBlock;
88
import eu.pb4.polydecorations.block.other.GhostLightBlock;
99
import eu.pb4.polydecorations.block.other.RopeBlock;
10+
import eu.pb4.polydecorations.util.DecorationsUtil;
1011
import eu.pb4.polydecorations.util.WoodUtil;
1112
import eu.pb4.polymer.core.api.block.PolymerBlock;
1213
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
1314
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
15+
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
1416
import net.minecraft.block.*;
1517
import net.minecraft.block.enums.NoteBlockInstrument;
18+
import net.minecraft.block.piston.PistonBehavior;
1619
import net.minecraft.loot.LootTable;
1720
import net.minecraft.particle.ParticleTypes;
1821
import net.minecraft.registry.Registries;
@@ -55,6 +58,12 @@ public class DecorationsBlocks {
5558
public static final WindChimeBlock WIND_CHIME = register("wind_chime", AbstractBlock.Settings.copy(Blocks.GLASS).nonOpaque(), WindChimeBlock::new);
5659
public static final TrashCanBlock TRASHCAN = register("trashcan", settings -> new TrashCanBlock(settings
5760
.mapColor(MapColor.IRON_GRAY).strength(3.5F).sounds(BlockSoundGroup.LANTERN).nonOpaque()));
61+
62+
public static final BasketBlock BASKET = register("basket", settings -> new BasketBlock(settings
63+
.mapColor(MapColor.OAK_TAN).strength(0.5F)
64+
.burnable()
65+
.sounds(BlockSoundGroup.SCAFFOLDING).nonOpaque()));
66+
5867
public static final LargeFlowerPotBlock LARGE_FLOWER_POT = register("large_flower_pot", settings -> new LargeFlowerPotBlock(settings
5968
.mapColor(MapColor.ORANGE).instrument(NoteBlockInstrument.BASEDRUM).strength(1.25F).nonOpaque()));
6069

@@ -117,6 +126,40 @@ public class DecorationsBlocks {
117126
return null;
118127
});
119128

129+
public static final Map<WoodType, StumpBlock> STUMP = registerWood("stump", (x, id, settings) -> {
130+
var log = Identifier.of(WoodUtil.getLogName(x));
131+
132+
if (Registries.BLOCK.containsId(log)) {
133+
var logBlock = Registries.BLOCK.get(log);
134+
135+
return new StumpBlock(
136+
AbstractBlock.Settings.copy(logBlock).mapColor(logBlock.getDefaultMapColor()).registryKey(RegistryKey.of(RegistryKeys.BLOCK, id)).nonOpaque()
137+
.solidBlock(Blocks::never),
138+
logBlock
139+
);
140+
}
141+
142+
return null;
143+
});
144+
145+
public static final Map<WoodType, StumpBlock> STRIPPED_STUMP = registerWood("stripped_", "stump", (x, id, settings) -> {
146+
var log = Identifier.of("stripped_" + WoodUtil.getLogName(x));
147+
148+
if (Registries.BLOCK.containsId(log)) {
149+
var logBlock = Registries.BLOCK.get(log);
150+
151+
var b = new StumpBlock(
152+
AbstractBlock.Settings.copy(logBlock).mapColor(logBlock.getDefaultMapColor()).registryKey(RegistryKey.of(RegistryKeys.BLOCK, id)).nonOpaque()
153+
.solidBlock(Blocks::never),
154+
logBlock
155+
);
156+
//StrippableBlockRegistry.register(STUMP.get(x), b);
157+
return b;
158+
}
159+
160+
return null;
161+
});
162+
120163
public static final Map<WoodType, AttachedSignPostBlock> WOOD_SIGN_POST = registerWood("sign_post", (x, id, settings) -> {
121164
var planks = Identifier.of(x.name() + "_fence");
122165
var block = Registries.BLOCK.get(planks);
@@ -127,6 +170,16 @@ public class DecorationsBlocks {
127170
return null;
128171
});
129172

173+
public static final Map<DyeColor, SleepingBagBlock> SLEEPING_BAG = registerDye("sleeping_bag", (x, id, settings) -> {
174+
var bed = Identifier.of(x.asString() + "_bed");
175+
var block = Registries.BLOCK.get(bed);
176+
if (block instanceof BedBlock) {
177+
return new SleepingBagBlock(x, AbstractBlock.Settings.copy(block).pistonBehavior(PistonBehavior.BLOCK).registryKey(RegistryKey.of(RegistryKeys.BLOCK, id)));
178+
}
179+
180+
return null;
181+
});
182+
130183
public static final Map<Block, AttachedSignPostBlock> WALL_SIGN_POST = Util.make(() -> {
131184
var map = new HashMap<Block, AttachedSignPostBlock>();
132185
var l = new ArrayList<Block>();
@@ -156,10 +209,13 @@ public class DecorationsBlocks {
156209
});
157210

158211
private static <T extends Block & PolymerBlock> Map<WoodType, T> registerWood(String id, TriFunction<WoodType, Identifier, AbstractBlock.Settings, T> object) {
212+
return registerWood("", id, object);
213+
}
214+
private static <T extends Block & PolymerBlock> Map<WoodType, T> registerWood(String prefix, String id, TriFunction<WoodType, Identifier, AbstractBlock.Settings, T> object) {
159215
var map = new HashMap<WoodType, T>();
160216

161217
WoodUtil.VANILLA.forEach(x -> {
162-
var y = register(x.name() + "_" + id, (s) -> object.apply(x, id(x.name() + "_" + id), s));
218+
var y = register(prefix + x.name() + "_" + id, (s) -> object.apply(x, id(prefix + x.name() + "_" + id), s));
163219
if (y != null) {
164220
map.put(x, y);
165221
}
@@ -168,13 +224,13 @@ private static <T extends Block & PolymerBlock> Map<WoodType, T> registerWood(St
168224
return map;
169225
}
170226

171-
private static <T extends Block & PolymerBlock> Map<DyeColor, T> registerDye(String id, Function<DyeColor, T> object) {
227+
private static <T extends Block & PolymerBlock> Map<DyeColor, T> registerDye(String id, TriFunction<DyeColor, Identifier, AbstractBlock.Settings, T> object) {
172228
var map = new HashMap<DyeColor, T>();
173229

174230
for (var x : DyeColor.values()) {
175-
var y = object.apply(x);
231+
var y = register( x.asString() + "_" + id, (s) -> object.apply(x, id(x.asString() + "_" + id), s));
176232
if (y != null) {
177-
map.put(x, register(x.name().toLowerCase(Locale.ROOT) + "_" + id, (s) -> y));
233+
map.put(x, y);
178234
}
179235
}
180236

src/main/java/eu/pb4/polydecorations/block/extension/SignPostBlockEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ public static Sign of() {
214214
return new Sign(new SignText(), Items.AIR, 0, false, false);
215215
}
216216

217-
public static Sign of(Item item, float yaw) {
218-
return new Sign(new SignText(), item, yaw, false, false);
217+
public static Sign of(Item item, float yaw, boolean flip) {
218+
return new Sign(new SignText(), item, yaw, false, flip);
219219
}
220220

221221
public Sign withText(SignText text) {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package eu.pb4.polydecorations.block.furniture;
2+
3+
import eu.pb4.factorytools.api.block.FactoryBlock;
4+
import eu.pb4.factorytools.api.virtualentity.BlockModel;
5+
import eu.pb4.factorytools.api.virtualentity.ItemDisplayElementUtil;
6+
import eu.pb4.polydecorations.mixin.LivingEntityAccessor;
7+
import eu.pb4.polydecorations.util.DecorationsUtil;
8+
import eu.pb4.polymer.blocks.api.PolymerTexturedBlock;
9+
import eu.pb4.polymer.core.api.utils.PolymerUtils;
10+
import eu.pb4.polymer.virtualentity.api.ElementHolder;
11+
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
12+
import net.minecraft.block.BedBlock;
13+
import net.minecraft.block.BlockState;
14+
import net.minecraft.block.entity.BlockEntity;
15+
import net.minecraft.block.enums.BedPart;
16+
import net.minecraft.entity.LivingEntity;
17+
import net.minecraft.entity.data.DataTracker;
18+
import net.minecraft.item.ItemDisplayContext;
19+
import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket;
20+
import net.minecraft.server.world.ServerWorld;
21+
import net.minecraft.util.DyeColor;
22+
import net.minecraft.util.TypeFilter;
23+
import net.minecraft.util.math.BlockPos;
24+
import net.minecraft.util.math.Direction;
25+
import org.jetbrains.annotations.Nullable;
26+
import org.joml.Vector3f;
27+
import xyz.nucleoid.packettweaker.PacketContext;
28+
29+
import java.util.List;
30+
import java.util.Optional;
31+
32+
public class SleepingBagBlock extends BedBlock implements FactoryBlock, PolymerTexturedBlock {
33+
public SleepingBagBlock(DyeColor color, Settings settings) {
34+
super(color, settings);
35+
}
36+
37+
@Override
38+
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
39+
return null;
40+
}
41+
42+
@Override
43+
public BlockState getPolymerBlockState(BlockState blockState, PacketContext packetContext) {
44+
return DecorationsUtil.TRAPDOOR_STATES_REGULAR.get(Direction.UP);
45+
}
46+
47+
@Override
48+
public @Nullable ElementHolder createElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
49+
return initialBlockState.get(PART) == BedPart.FOOT ? new Model(initialBlockState, pos) : null;
50+
}
51+
52+
public static final class Model extends BlockModel {
53+
private final ItemDisplayElement main;
54+
55+
public Model(BlockState state, BlockPos pos) {
56+
this.main = ItemDisplayElementUtil.createSimple(state.getBlock().asItem());
57+
this.main.setDisplaySize(2, 2);
58+
this.main.setItemDisplayContext(ItemDisplayContext.NONE);
59+
//this.main.setTranslation(new Vector3f(0, 0, 0.5f));
60+
this.main.setYaw(state.get(FACING).getPositiveHorizontalDegrees());
61+
this.addElement(this.main);
62+
}
63+
}
64+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package eu.pb4.polydecorations.block.furniture;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import eu.pb4.factorytools.api.block.BarrierBasedWaterloggable;
5+
import eu.pb4.factorytools.api.block.FactoryBlock;
6+
import eu.pb4.factorytools.api.virtualentity.BlockModel;
7+
import eu.pb4.factorytools.api.virtualentity.ItemDisplayElementUtil;
8+
import eu.pb4.polydecorations.entity.SeatEntity;
9+
import eu.pb4.polymer.virtualentity.api.ElementHolder;
10+
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
11+
import net.minecraft.block.Block;
12+
import net.minecraft.block.BlockState;
13+
import net.minecraft.block.BlockWithEntity;
14+
import net.minecraft.entity.player.PlayerEntity;
15+
import net.minecraft.fluid.FluidState;
16+
import net.minecraft.fluid.Fluids;
17+
import net.minecraft.item.ItemPlacementContext;
18+
import net.minecraft.server.world.ServerWorld;
19+
import net.minecraft.state.StateManager;
20+
import net.minecraft.util.ActionResult;
21+
import net.minecraft.util.hit.BlockHitResult;
22+
import net.minecraft.util.math.BlockPos;
23+
import net.minecraft.util.math.Direction;
24+
import net.minecraft.util.math.random.Random;
25+
import net.minecraft.world.World;
26+
import net.minecraft.world.WorldView;
27+
import net.minecraft.world.tick.ScheduledTickView;
28+
import org.jetbrains.annotations.Nullable;
29+
import org.joml.Vector3f;
30+
import xyz.nucleoid.packettweaker.PacketContext;
31+
32+
public class StumpBlock extends Block implements FactoryBlock, BarrierBasedWaterloggable {
33+
private final Block base;
34+
35+
public StumpBlock(Settings settings, Block log) {
36+
super(settings);
37+
this.setDefaultState(this.getDefaultState().with(WATERLOGGED, false));
38+
this.base = log;
39+
}
40+
41+
@Override
42+
public BlockState getPolymerBreakEventBlockState(BlockState state, PacketContext player) {
43+
return this.base.getDefaultState();
44+
}
45+
46+
@Override
47+
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
48+
builder.add(WATERLOGGED);
49+
}
50+
51+
public FluidState getFluidState(BlockState state) {
52+
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
53+
}
54+
55+
@Nullable
56+
@Override
57+
public BlockState getPlacementState(ItemPlacementContext ctx) {
58+
return waterLog(ctx, this.getDefaultState());
59+
}
60+
61+
@Override
62+
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
63+
if (!player.isSneaking() && SeatEntity.create(world, pos, 3 / 16f, null, player)) {
64+
return ActionResult.SUCCESS_SERVER;
65+
}
66+
67+
return super.onUse(state, world, pos, player, hit);
68+
}
69+
70+
71+
@Override
72+
protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) {
73+
tickWater(state, world, tickView, pos);
74+
return state;
75+
}
76+
77+
@Override
78+
protected MapCodec<? extends BlockWithEntity> getCodec() {
79+
return null;
80+
}
81+
82+
@Override
83+
public @Nullable ElementHolder createElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
84+
return new Model(initialBlockState, pos);
85+
}
86+
87+
public static final class Model extends BlockModel {
88+
private final ItemDisplayElement main;
89+
90+
public Model(BlockState state, BlockPos pos) {
91+
this.main = ItemDisplayElementUtil.createSimple(state.getBlock().asItem());
92+
this.main.setDisplaySize(1, 1);
93+
this.main.setScale(new Vector3f(2));
94+
this.main.setYaw(Random.create(pos.hashCode()).nextInt(4) * 90);
95+
this.addElement(this.main);
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)