Skip to content

Commit 31b7881

Browse files
committed
Updated shouldereffect to work and mirror new cobblemon (i think), fix a few json errors, removed items preventing one of the pokeball loot tables to work and ported LootBlocks to main.
1 parent 868366e commit 31b7881

File tree

19 files changed

+289
-41
lines changed

19 files changed

+289
-41
lines changed

common/src/main/java/generations/gg/generations/core/generationscore/client/GenerationsCoreClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public static void registerBlockEntityRenderers(BiConsumer<BlockEntityType<? ext
135135
consumer.accept(GenerationsBlockEntities.GENERIC_MODEL_PROVIDING.get(), GeneralUseBlockEntityRenderer::new);
136136
consumer.accept(GenerationsBlockEntities.VENDING_MACHINE.get(), GeneralUseBlockEntityRenderer::new);
137137
consumer.accept(GenerationsBlockEntities.BALL_DISPLAY.get(), GeneralUseBlockEntityRenderer::new);
138+
consumer.accept(GenerationsBlockEntities.POKE_LOOT.get(), PokeLootRendrer::new);
138139
}
139140

140141
public static void registerLayerDefinitions(BiConsumer<ModelLayerLocation, Supplier<LayerDefinition>> consumer) {

common/src/main/java/generations/gg/generations/core/generationscore/client/render/block/entity/GeneralUseBlockEntityRenderer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ protected void renderModelProvider(PoseStack stack, ModelProvidingBlockEntity bl
5353
blockEntity.objectInstance.setVariant(provider.getVariant());
5454
}
5555

56+
57+
5658
blockEntity.objectInstance.viewMatrix().set(stack.last().pose());
5759
((BlockObjectInstance) blockEntity.objectInstance).setLight(packedLight);
5860

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package generations.gg.generations.core.generationscore.client.render.block.entity;
2+
3+
import com.mojang.blaze3d.systems.RenderSystem;
4+
import com.mojang.blaze3d.vertex.PoseStack;
5+
import generations.gg.generations.core.generationscore.client.render.rarecandy.BlockObjectInstance;
6+
import generations.gg.generations.core.generationscore.client.render.rarecandy.ModelRegistry;
7+
import generations.gg.generations.core.generationscore.world.level.block.entities.PokeLootBlockEntity;
8+
import generations.gg.generations.core.generationscore.world.level.block.generic.GenericModelBlock;
9+
import net.minecraft.client.renderer.MultiBufferSource;
10+
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
11+
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
12+
import org.joml.Matrix4f;
13+
14+
public class PokeLootRendrer implements BlockEntityRenderer<PokeLootBlockEntity> {
15+
16+
public PokeLootRendrer(BlockEntityRendererProvider.Context ctx) {}
17+
18+
@Override
19+
public void render(PokeLootBlockEntity blockEntity, float partialTick, PoseStack stack, MultiBufferSource buffer, int packedLight, int packedOverlay) {
20+
if (!(blockEntity.getBlockState().getBlock() instanceof GenericModelBlock<?> block && block.canRender(blockEntity.getLevel(), blockEntity.getBlockPos(), blockEntity.getBlockState()))) return;
21+
stack.pushPose();
22+
if (blockEntity.objectInstance == null) {
23+
blockEntity.objectInstance = new BlockObjectInstance(new Matrix4f(), new Matrix4f(), "");
24+
}
25+
26+
var primeInstance = blockEntity.objectInstance;
27+
28+
if (!primeInstance.materialId().equals(blockEntity.getVariant())) {
29+
primeInstance.setVariant(blockEntity.getVariant());
30+
}
31+
32+
33+
34+
((BlockObjectInstance) primeInstance).setLight(packedLight);
35+
36+
37+
ModelRegistry.prepForBER(stack, blockEntity);
38+
stack.translate(0, 0.25f, 0);
39+
40+
var model = ModelRegistry.get(blockEntity, "block");
41+
var scale = model.renderObject.scale * 0.5f;
42+
stack.scale(scale, scale, scale);
43+
primeInstance.viewMatrix().set(stack.last().pose());
44+
45+
model.render(primeInstance, RenderSystem.getProjectionMatrix());
46+
stack.popPose();
47+
}
48+
}

common/src/main/java/generations/gg/generations/core/generationscore/world/level/block/GenerationsUtilityBlocks.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,44 @@ public class GenerationsUtilityBlocks {
9393

9494
public static final RegistrySupplier<Block> TRASH_CAN = registerBlockItem("trash_can", () -> new TrashCanBlock(BlockBehaviour.Properties.of().destroyTime(1.0f).sound(SoundType.METAL)));
9595

96+
public static RegistrySupplier<PokeLootBlock> BEAST_LOOT = registerLoot("beast");
97+
public static RegistrySupplier<PokeLootBlock> CHERISH_LOOT = registerLoot("cherish");
98+
public static RegistrySupplier<PokeLootBlock> DIVE_LOOT = registerLoot("dive");
99+
public static RegistrySupplier<PokeLootBlock> DREAM_LOOT = registerLoot("dream");
100+
public static RegistrySupplier<PokeLootBlock> DUSK_LOOT = registerLoot("dusk");
101+
public static RegistrySupplier<PokeLootBlock> FAST_LOOT = registerLoot("fast");
102+
public static RegistrySupplier<PokeLootBlock> FRIEND_LOOT = registerLoot("friend");
103+
public static RegistrySupplier<PokeLootBlock> GIGATON_LOOT = registerLoot("gigaton");
104+
public static RegistrySupplier<PokeLootBlock> GREAT_LOOT = registerLoot("great");
105+
public static RegistrySupplier<PokeLootBlock> HEAL_LOOT = registerLoot("heal");
106+
public static RegistrySupplier<PokeLootBlock> HEAVY_LOOT = registerLoot("heavy");
107+
public static RegistrySupplier<PokeLootBlock> JET_LOOT = registerLoot("jet");
108+
public static RegistrySupplier<PokeLootBlock> LEADEN_LOOT = registerLoot("leaden");
109+
public static RegistrySupplier<PokeLootBlock> LEVEL_LOOT = registerLoot("level");
110+
public static RegistrySupplier<PokeLootBlock> LOVE_LOOT = registerLoot("love");
111+
public static RegistrySupplier<PokeLootBlock> LURE_LOOT = registerLoot("lure");
112+
public static RegistrySupplier<PokeLootBlock> LUXURY_LOOT = registerLoot("luxury");
113+
public static RegistrySupplier<PokeLootBlock> MASTER_LOOT = registerLoot("master");
114+
public static RegistrySupplier<PokeLootBlock> MOON_LOOT = registerLoot("moon");
115+
public static RegistrySupplier<PokeLootBlock> NEST_LOOT = registerLoot("nest");
116+
public static RegistrySupplier<PokeLootBlock> NET_LOOT = registerLoot("net");
117+
public static RegistrySupplier<PokeLootBlock> ORIGIN_LOOT = registerLoot("origin");
118+
public static RegistrySupplier<PokeLootBlock> PARK_LOOT = registerLoot("park");
119+
public static RegistrySupplier<PokeLootBlock> POKE_LOOT = registerLoot("poke");
120+
public static RegistrySupplier<PokeLootBlock> PREMIER_LOOT = registerLoot("premier");
121+
public static RegistrySupplier<PokeLootBlock> QUICK_LOOT = registerLoot("quick");
122+
public static RegistrySupplier<PokeLootBlock> REPEAT_LOOT = registerLoot("repeat");
123+
public static RegistrySupplier<PokeLootBlock> SAFARI_LOOT = registerLoot("safari");
124+
public static RegistrySupplier<PokeLootBlock> SPORT_LOOT = registerLoot("sport");
125+
public static RegistrySupplier<PokeLootBlock> STRANGE_LOOT = registerLoot("strange");
126+
public static RegistrySupplier<PokeLootBlock> TIMER_LOOT = registerLoot("timer");
127+
public static RegistrySupplier<PokeLootBlock> ULTRA_LOOT = registerLoot("ultra");
128+
public static RegistrySupplier<PokeLootBlock> WING_LOOT = registerLoot("wing");
129+
130+
private static RegistrySupplier<PokeLootBlock> registerLoot(String name) {
131+
return registerBlockItem(name + "_loot", () -> new PokeLootBlock(name, BlockBehaviour.Properties.of().noOcclusion().sound(SoundType.METAL).strength(-1.0f, 3600000.0f)));
132+
}
133+
96134
public static final RegistrySupplier<BreederBlock> BREEDER = registerBlockItem("breeder", () -> new BreederBlock(BlockBehaviour.Properties.of().destroyTime(1.0f).sound(SoundType.WOOD).ignitedByLava()));
97135
public static final RegistrySupplier<GenericFurnaceBlock> CHARGE_STONE_FURNACE = registerBlockItem("charge_stone_furnace", () -> new GenericFurnaceBlock(BlockBehaviour.Properties.copy(Blocks.FURNACE)));
98136
public static final RegistrySupplier<GenericBlastFurnaceBlock> CHARGE_STONE_BLAST_FURNACE = registerBlockItem("charge_stone_blast_furnace", () -> new GenericBlastFurnaceBlock(BlockBehaviour.Properties.copy(Blocks.BLAST_FURNACE)));
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package generations.gg.generations.core.generationscore.world.level.block;
2+
3+
import dev.architectury.utils.GameInstance;
4+
import generations.gg.generations.core.generationscore.GenerationsCore;
5+
import generations.gg.generations.core.generationscore.world.level.block.entities.GenerationsBlockEntities;
6+
import generations.gg.generations.core.generationscore.world.level.block.entities.GenerationsBlockEntityModels;
7+
import generations.gg.generations.core.generationscore.world.level.block.entities.PokeLootBlockEntity;
8+
import generations.gg.generations.core.generationscore.world.level.block.generic.GenericRotatableModelBlock;
9+
import net.minecraft.advancements.CriteriaTriggers;
10+
import net.minecraft.core.BlockPos;
11+
import net.minecraft.core.NonNullList;
12+
import net.minecraft.resources.ResourceLocation;
13+
import net.minecraft.server.level.ServerLevel;
14+
import net.minecraft.server.level.ServerPlayer;
15+
import net.minecraft.world.Containers;
16+
import net.minecraft.world.InteractionHand;
17+
import net.minecraft.world.InteractionResult;
18+
import net.minecraft.world.entity.player.Player;
19+
import net.minecraft.world.level.Level;
20+
import net.minecraft.world.level.block.state.BlockState;
21+
import net.minecraft.world.level.storage.loot.LootContext;
22+
import net.minecraft.world.level.storage.loot.LootParams;
23+
import net.minecraft.world.level.storage.loot.LootTable;
24+
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
25+
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
26+
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
27+
import net.minecraft.world.phys.BlockHitResult;
28+
import net.minecraft.world.phys.Vec3;
29+
30+
import java.util.stream.Collectors;
31+
32+
public class PokeLootBlock extends GenericRotatableModelBlock<PokeLootBlockEntity> {
33+
private final String name;
34+
private final ResourceLocation lootTable;
35+
36+
protected PokeLootBlock(String name, Properties properties) {
37+
super(properties, GenerationsBlockEntities.POKE_LOOT, GenerationsBlockEntityModels.POKEBALL);
38+
this.name = name;
39+
this.lootTable = GenerationsCore.id("chests/%s_ball".formatted(name));
40+
}
41+
42+
@Override
43+
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
44+
if(!level.isClientSide) {
45+
unpackLootTable((ServerLevel) level, pos, player);
46+
47+
return InteractionResult.CONSUME;
48+
}
49+
50+
return super.use(state, level, pos, player, hand, hit);
51+
}
52+
53+
public String getType() {
54+
return name;
55+
}
56+
57+
public ResourceLocation getLootTableId() {
58+
return lootTable;
59+
}
60+
61+
public void unpackLootTable(ServerLevel level, BlockPos pos, Player player) {
62+
var lootTableId = this.getLootTableId();
63+
LootTable lootTable = GameInstance.getServer().getLootData().getLootTable(lootTableId);
64+
65+
if (player instanceof ServerPlayer) {
66+
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, lootTableId);getLootTable();
67+
}
68+
69+
LootParams.Builder builder = (new LootParams.Builder(level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos));
70+
if (player != null) {
71+
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
72+
}
73+
74+
var list = lootTable.getRandomItems(builder.create(LootContextParamSets.CHEST)).stream().collect(Collectors.toCollection(NonNullList::create));
75+
76+
Containers.dropContents(level, pos.above(), list);
77+
}
78+
}

common/src/main/java/generations/gg/generations/core/generationscore/world/level/block/entities/GenerationsBlockEntities.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,42 @@ public class GenerationsBlockEntities {
295295
GenerationsDecorationBlocks.TIMER_BALL_DISPLAY.get()
296296
).build(null));
297297

298+
public static final RegistrySupplier<BlockEntityType<PokeLootBlockEntity>> POKE_LOOT = BLOCK_ENTITIES.register("poke_loot", () -> BlockEntityType.Builder.of(PokeLootBlockEntity::new,
299+
GenerationsUtilityBlocks.BEAST_LOOT.get(),
300+
GenerationsUtilityBlocks.CHERISH_LOOT.get(),
301+
GenerationsUtilityBlocks.DIVE_LOOT.get(),
302+
GenerationsUtilityBlocks.DREAM_LOOT.get(),
303+
GenerationsUtilityBlocks.DUSK_LOOT.get(),
304+
GenerationsUtilityBlocks.FAST_LOOT.get(),
305+
GenerationsUtilityBlocks.FRIEND_LOOT.get(),
306+
GenerationsUtilityBlocks.GIGATON_LOOT.get(),
307+
GenerationsUtilityBlocks.GREAT_LOOT.get(),
308+
GenerationsUtilityBlocks.HEAL_LOOT.get(),
309+
GenerationsUtilityBlocks.HEAVY_LOOT.get(),
310+
GenerationsUtilityBlocks.JET_LOOT.get(),
311+
GenerationsUtilityBlocks.LEADEN_LOOT.get(),
312+
GenerationsUtilityBlocks.LEVEL_LOOT.get(),
313+
GenerationsUtilityBlocks.LOVE_LOOT.get(),
314+
GenerationsUtilityBlocks.LURE_LOOT.get(),
315+
GenerationsUtilityBlocks.LUXURY_LOOT.get(),
316+
GenerationsUtilityBlocks.MASTER_LOOT.get(),
317+
GenerationsUtilityBlocks.MOON_LOOT.get(),
318+
GenerationsUtilityBlocks.NEST_LOOT.get(),
319+
GenerationsUtilityBlocks.NET_LOOT.get(),
320+
GenerationsUtilityBlocks.ORIGIN_LOOT.get(),
321+
GenerationsUtilityBlocks.PARK_LOOT.get(),
322+
GenerationsUtilityBlocks.POKE_LOOT.get(),
323+
GenerationsUtilityBlocks.PREMIER_LOOT.get(),
324+
GenerationsUtilityBlocks.QUICK_LOOT.get(),
325+
GenerationsUtilityBlocks.REPEAT_LOOT.get(),
326+
GenerationsUtilityBlocks.SAFARI_LOOT.get(),
327+
GenerationsUtilityBlocks.SPORT_LOOT.get(),
328+
GenerationsUtilityBlocks.STRANGE_LOOT.get(),
329+
GenerationsUtilityBlocks.TIMER_LOOT.get(),
330+
GenerationsUtilityBlocks.ULTRA_LOOT.get(),
331+
GenerationsUtilityBlocks.WING_LOOT.get()
332+
).build(null));
333+
298334

299335
public static void init() {
300336
GenerationsCore.LOGGER.info("Registering Generations Block Entities");

common/src/main/java/generations/gg/generations/core/generationscore/world/level/block/entities/GenerationsBlockEntityModels.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ public class GenerationsBlockEntityModels {
6767
public static final ResourceLocation WORK_DESK = GenerationsCore.id("models/block/decorations/work_desk.pk");
6868

6969
public static final ResourceLocation BALL_DISPLAY = GenerationsCore.id("models/block/decorations/ball_display.pk");
70+
public static final ResourceLocation POKEBALL = GenerationsCore.id("models/block/utility_blocks/pokeball.pk");
7071
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package generations.gg.generations.core.generationscore.world.level.block.entities;
2+
3+
import dev.architectury.utils.GameInstance;
4+
import generations.gg.generations.core.generationscore.client.model.ModelContextProviders;
5+
import generations.gg.generations.core.generationscore.world.level.block.PokeLootBlock;
6+
import net.minecraft.advancements.CriteriaTriggers;
7+
import net.minecraft.core.BlockPos;
8+
import net.minecraft.core.NonNullList;
9+
import net.minecraft.server.level.ServerLevel;
10+
import net.minecraft.server.level.ServerPlayer;
11+
import net.minecraft.world.Containers;
12+
import net.minecraft.world.entity.player.Player;
13+
import net.minecraft.world.level.block.state.BlockState;
14+
import net.minecraft.world.level.storage.loot.LootParams;
15+
import net.minecraft.world.level.storage.loot.LootTable;
16+
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
17+
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
18+
import net.minecraft.world.phys.Vec3;
19+
import org.jetbrains.annotations.Nullable;
20+
21+
import java.util.stream.Collectors;
22+
23+
public class PokeLootBlockEntity extends ModelProvidingBlockEntity implements ModelContextProviders.VariantProvider {
24+
public PokeLootBlockEntity(BlockPos pPos, BlockState pBlockState) {
25+
super(GenerationsBlockEntities.POKE_LOOT.get(), pPos, pBlockState);
26+
}
27+
28+
@Override
29+
public String getVariant() {
30+
return getBlockState().getBlock() instanceof PokeLootBlock loot ? loot.getType() : "poke";
31+
}
32+
}
Binary file not shown.

common/src/main/resources/data/cobblemon/spawn_pool_world/1004_chiyu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"context": "grounded",
1414
"bucket": "ultra-rare",
1515
"level": "70-75",
16-
"weight": 0.001
16+
"weight": 0.001,
1717
"condition": {
1818
"biomes": [
1919
"#cobblemon:is_volcanic"

0 commit comments

Comments
 (0)