Skip to content

Commit acbf0f5

Browse files
fixing catalyst carrier rendering
1 parent a710e38 commit acbf0f5

21 files changed

Lines changed: 165 additions & 118 deletions

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'idea'
33
id 'java-library'
44
id 'maven-publish'
5-
id 'net.neoforged.moddev' version '2.0.78'
5+
id 'net.neoforged.moddev' version '2.0.107'
66
}
77

88
tasks.named('wrapper', Wrapper).configure {

‎gradle.properties‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ neo_version=21.1.200
2222
# The Neo version range can use any version of Neo as bounds
2323
neo_version_range=[21.1.0,)
2424
# The loader version range can only use the major version of FML as bounds
25-
loader_version_range=[1,)
25+
loader_version_range=[4,)
2626

2727
## Mod Properties
2828

@@ -37,9 +37,9 @@ mod_license=MIT
3737
mod_version=1.7.10
3838

3939

40-
create_version = 6.0.6-98
41-
flywheel_version = 1.0.4
42-
ponder_version = 1.0.59
40+
create_version = 6.0.8-169
41+
flywheel_version = 1.0.6
42+
ponder_version = 1.0.66
4343

4444
registrate_version = MC1.21-1.3.0+62
4545
jei_version= 19.21.0.247

‎src/main/java/com/rae/creatingspace/content/datagen/recipe/CSStandardRecipeGen.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.rae.creatingspace.content.datagen.CSRecipeProvider;
88
import com.rae.creatingspace.init.ingameobject.ItemInit;
99
import com.simibubi.create.AllTags;
10-
import com.simibubi.create.foundation.data.recipe.CompatMetals;
10+
import com.simibubi.create.foundation.data.recipe.CommonMetal;
1111
import com.simibubi.create.foundation.data.recipe.Mods;
1212
import com.simibubi.create.foundation.mixin.accessor.MappedRegistryAccessor;
1313
import com.tterrag.registrate.util.entry.BlockEntry;
@@ -52,6 +52,7 @@
5252

5353
import static com.rae.creatingspace.CreatingSpace.resource;
5454

55+
5556
public class CSStandardRecipeGen extends CSRecipeProvider {
5657

5758
private Marker MISC = enterFolder("misc");
@@ -127,8 +128,8 @@ GeneratedRecipe blastCrushedMetal(Supplier<? extends ItemLike> result, Supplier<
127128
.inBlastFurnace();
128129
}
129130

130-
GeneratedRecipe blastModdedCrushedMetal(ItemEntry<? extends Item> ingredient, CompatMetals metal) {
131-
for (Mods mod : metal.getMods()) {
131+
GeneratedRecipe blastModdedCrushedMetal(ItemEntry<? extends Item> ingredient, CommonMetal metal) {
132+
for (Mods mod : metal.mods) {
132133
String metalName = metal.getName(mod);
133134
ResourceLocation ingot = mod.ingotOf(metalName);
134135
String modId = mod.getId();
@@ -396,7 +397,7 @@ private <T extends AbstractCookingRecipe> GeneratedRecipe create(RecipeSerialize
396397
}
397398
}
398399

399-
public String getthisName() {
400+
public String getThisName() {
400401
return "CreatingSpace Standard Recipes";
401402
}
402403

‎src/main/java/com/rae/creatingspace/content/recipes/chemical_synthesis/CatalystCarrierBlock.java‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.minecraft.world.level.BlockGetter;
1919
import net.minecraft.world.level.Level;
2020
import net.minecraft.world.level.LevelReader;
21+
import net.minecraft.world.level.block.entity.BlockEntity;
2122
import net.minecraft.world.level.block.entity.BlockEntityType;
2223
import net.minecraft.world.level.block.state.BlockState;
2324
import net.minecraft.world.level.pathfinder.PathComputationType;
@@ -86,24 +87,34 @@ protected boolean isPathfindable(BlockState state, PathComputationType pathCompu
8687
}
8788

8889
@Override
89-
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
90-
if (!level.isClientSide) {
91-
if (stack.getItem() instanceof CatalystItem) {
92-
withBlockEntityDo(level, pos, be -> be.setCatalyst(stack));
93-
return ItemInteractionResult.CONSUME;
94-
95-
}
96-
}
97-
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
90+
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos,
91+
Player player, InteractionHand hand, BlockHitResult hitResult) {
92+
ItemStack heldByPlayer = stack.copy();
93+
94+
// Let non-catalyst items pass through (blocks, tools, etc.)
95+
if (!heldByPlayer.isEmpty() && !(heldByPlayer.getItem() instanceof CatalystItem))
96+
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
97+
98+
if (level.isClientSide)
99+
return ItemInteractionResult.SUCCESS;
100+
101+
withBlockEntityDo(level, pos, be -> {
102+
ItemStack currentCatalyst = be.getCatalyst().copy();
103+
104+
// Both empty → nothing to do
105+
if (currentCatalyst.isEmpty() && heldByPlayer.isEmpty())
106+
return;
107+
108+
player.setItemInHand(hand, currentCatalyst);
109+
be.setCatalyst(heldByPlayer);
110+
be.sendData();
111+
});
112+
113+
return ItemInteractionResult.SUCCESS;
98114
}
99115

100116
@Override
101117
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
102-
103-
if (!level.isClientSide) {
104-
withBlockEntityDo(level, pos, be -> be.setCatalyst(ItemStack.EMPTY));
105-
return InteractionResult.SUCCESS;
106-
}
107118
return super.useWithoutItem(state, level, pos, player, hitResult);
108119
}
109120

‎src/main/java/com/rae/creatingspace/content/recipes/chemical_synthesis/CatalystCarrierBlockEntity.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import net.minecraft.sounds.SoundEvents;
2020
import net.minecraft.sounds.SoundSource;
2121
import net.minecraft.util.Mth;
22-
import net.minecraft.world.Container;
22+
import net.minecraft.world.entity.player.Player;
2323
import net.minecraft.world.item.ItemStack;
2424
import net.minecraft.world.item.crafting.Recipe;
2525
import net.minecraft.world.item.crafting.RecipeHolder;
@@ -30,20 +30,20 @@
3030
import net.minecraft.world.phys.Vec3;
3131
import net.neoforged.api.distmarker.Dist;
3232
import net.neoforged.api.distmarker.OnlyIn;
33+
import org.jetbrains.annotations.NotNull;
3334
import org.jetbrains.annotations.Nullable;
3435

3536
import java.util.List;
3637
import java.util.Optional;
37-
import java.util.stream.Collectors;
3838

3939
public class CatalystCarrierBlockEntity extends BasinOperatingBlockEntity {
4040

41-
private static final Object shapelessOrMixingRecipesKey = new Object();
41+
private static final Object chemistryRecipesKey = new Object();
4242

4343
public int runningTicks;
4444
public int processingTicks;
45-
public boolean running;
46-
private ItemStack catalyst = ItemStack.EMPTY;//todo replace null values by air item
45+
public boolean running;
46+
private @NotNull ItemStack catalyst = ItemStack.EMPTY;
4747

4848
public CatalystCarrierBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
4949
super(type, pos, state);
@@ -89,7 +89,7 @@ protected void read(CompoundTag compound, HolderLookup.Provider registries,bool
8989

9090
CompoundTag catalyst = (CompoundTag) compound.get("catalyst");
9191
if (catalyst != null) {
92-
if (catalyst.isEmpty()) {
92+
if (catalyst.isEmpty()) {//redundant
9393
this.catalyst = ItemStack.EMPTY;
9494
} else {
9595
this.catalyst = ItemStack.parseOptional(registries,catalyst);
@@ -227,7 +227,7 @@ protected void onBasinRemoved() {
227227

228228
@Override
229229
protected Object getRecipeCacheKey() {
230-
return shapelessOrMixingRecipesKey;
230+
return chemistryRecipesKey;
231231
}
232232

233233
@Override
@@ -254,13 +254,13 @@ public void tickAudio() {
254254
*/
255255
}
256256

257-
public ItemStack getCatalyst() {
257+
public @NotNull ItemStack getCatalyst() {
258258
return catalyst;
259259
}
260260

261261
public void setCatalyst(@Nullable ItemStack held) {
262262
if (held == null) {
263-
catalyst = null;
263+
catalyst = ItemStack.EMPTY;
264264
notifyUpdate();
265265
return;
266266
}

‎src/main/java/com/rae/creatingspace/content/recipes/chemical_synthesis/CatalystCarrierRenderer.java‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.rae.creatingspace.content.recipes.chemical_synthesis;
22

33
import com.mojang.blaze3d.vertex.PoseStack;
4-
import com.rae.creatingspace.CreatingSpace;
54
import com.rae.creatingspace.init.graphics.PartialModelInit;
65
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
76

8-
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
9-
import dev.engine_room.flywheel.lib.model.Models;
7+
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
108
import net.createmod.catnip.render.CachedBuffers;
119
import net.createmod.catnip.render.SuperByteBuffer;
1210
import net.minecraft.client.model.geom.ModelPart;
@@ -20,9 +18,11 @@
2018
import net.minecraft.client.renderer.RenderType;
2119
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
2220
import net.minecraft.client.renderer.texture.OverlayTexture;
21+
import net.minecraft.core.Direction;
2322
import net.minecraft.resources.ResourceLocation;
2423
import net.minecraft.world.item.ItemStack;
2524
import net.minecraft.world.level.block.state.BlockState;
25+
import org.jetbrains.annotations.NotNull;
2626

2727
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
2828

@@ -33,47 +33,44 @@ public CatalystCarrierRenderer(BlockEntityRendererProvider.Context context) {
3333
}
3434

3535
@Override
36-
public boolean shouldRenderOffScreen(CatalystCarrierBlockEntity be) {
36+
public boolean shouldRenderOffScreen(@NotNull CatalystCarrierBlockEntity be) {
3737
return true;
3838
}
3939

4040
@Override
41-
protected void renderSafe(CatalystCarrierBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
41+
protected void renderSafe(CatalystCarrierBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource bufferSource,
4242
int light, int overlay) {
43-
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
44-
if (VisualizationManager.supportsVisualization(be.getLevel())) return;
43+
super.renderSafe(be, partialTicks, ms, bufferSource, light, overlay);
44+
//if (VisualizationManager.supportsVisualization(be.getLevel())) return;
4545

4646
float renderedHeadOffset =
4747
be.getRenderedHeadOffset(partialTicks);
48-
ItemStack catalyst = be.getCatalyst();
49-
BlockState blockState = be.getBlockState();
50-
51-
if (catalyst != null) {
52-
if (!catalyst.isEmpty()) {
53-
SuperByteBuffer catalystModel = CachedBuffers.partial(PartialModelInit.NICKEL_SULFATE_CATALYST, blockState);
54-
55-
catalystModel.translate(0, -renderedHeadOffset, 0)
56-
.rotateXDegrees(180)
57-
.light(light)
58-
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
59-
/*
60-
ms.pushPose();
61-
ms.translate(0, -renderedHeadOffset, 0);
62-
renderCatalystFromTexture(ms,
63-
CreatingSpace.resource("textures/block/catalyst_carrier/catalyst/" +
64-
catalyst.getItemHolder().unwrapKey().orElseThrow().location().getPath() + ".png"), buffer);
65-
ms.popPose();*/
66-
}
48+
@NotNull ItemStack catalyst = be.getCatalyst();
49+
BlockState blockState = be.getBlockState();
50+
51+
if (!catalyst.isEmpty()) {
52+
PartialModel model = ((CatalystItem)catalyst.getItem()).getModel();
53+
SuperByteBuffer catalystModel = CachedBuffers.partial(PartialModelInit.NICKEL_SULFATE_CATALYST, blockState);
54+
55+
catalystModel.translate(0, -renderedHeadOffset-1, 0)
56+
.rotateCenteredDegrees(180, Direction.Axis.X)
57+
.light(light)
58+
.renderInto(ms, bufferSource.getBuffer(RenderType.cutout()));
59+
/*
60+
ms.pushPose();
61+
ms.translate(0, -renderedHeadOffset, 0);
62+
renderCatalystFromTexture(ms,
63+
CreatingSpace.resource("textures/block/catalyst_carrier/catalyst/" +
64+
catalyst.getItemHolder().unwrapKey().orElseThrow().location().getPath() + ".png"), bufferSource);
65+
ms.popPose();*/
6766
}
6867

6968

70-
71-
7269
SuperByteBuffer headRender = CachedBuffers.partialFacing(PartialModelInit.CATALYST_CARRIER_HEAD, blockState,
7370
blockState.getValue(HORIZONTAL_FACING));
7471
headRender.translate(0, -renderedHeadOffset, 0)
7572
.light(light)
76-
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
73+
.renderInto(ms, bufferSource.getBuffer(RenderType.solid()));
7774
}
7875

7976
@Override
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
package com.rae.creatingspace.content.recipes.chemical_synthesis;
22

3+
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
34
import net.minecraft.world.item.Item;
45
import net.minecraft.world.item.ItemStack;
6+
import org.jetbrains.annotations.NotNull;
57

68
public class CatalystItem extends Item {
7-
public CatalystItem(Properties properties) {
9+
final PartialModel model;
10+
11+
//PartialModel exist in DedicatedServer but should be used...
12+
public CatalystItem(Properties properties, PartialModel model) {
813
super(properties);
14+
this.model = model;
915
}
1016

1117
@Override
12-
public boolean isDamageable(ItemStack stack) {
18+
public boolean isDamageable(@NotNull ItemStack stack) {
1319
return true;
1420
}
21+
22+
public @NotNull PartialModel getModel(){
23+
return model;
24+
};
1525
}

src/main/java/com/rae/creatingspace/content/recipes/electrolysis/MechanicalElectrolyserBlockRenderer.java renamed to src/main/java/com/rae/creatingspace/content/recipes/electrolysis/MechanicalElectrolyzerBlockRenderer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.rae.creatingspace.init.graphics.PartialModelInit;
55
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
66

7-
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
87
import net.createmod.catnip.render.CachedBuffers;
98
import net.createmod.catnip.render.SuperByteBuffer;
109
import net.minecraft.client.renderer.MultiBufferSource;
@@ -14,9 +13,9 @@
1413

1514
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
1615

17-
public class MechanicalElectrolyserBlockRenderer extends KineticBlockEntityRenderer<MechanicalElectrolyzerBlockEntity> {
16+
public class MechanicalElectrolyzerBlockRenderer extends KineticBlockEntityRenderer<MechanicalElectrolyzerBlockEntity> {
1817

19-
public MechanicalElectrolyserBlockRenderer(BlockEntityRendererProvider.Context context) {
18+
public MechanicalElectrolyzerBlockRenderer(BlockEntityRendererProvider.Context context) {
2019
super(context);
2120
}
2221

@@ -32,7 +31,7 @@ protected void renderSafe(MechanicalElectrolyzerBlockEntity be, float partialTic
3231
float renderedHeadOffset =
3332
be.getRenderedHeadOffset(partialTicks);
3433

35-
if (VisualizationManager.supportsVisualization(be.getLevel())) return;
34+
//if (VisualizationManager.supportsVisualization(be.getLevel())) return;
3635

3736
BlockState blockState = be.getBlockState();
3837
SuperByteBuffer headRender = CachedBuffers.partialFacing(PartialModelInit.ELECTROLYZER_HEAD, blockState,

‎src/main/java/com/rae/creatingspace/init/CreativeModeTabsInit.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ private static Predicate<Item> makeExclusionPredicate() {
121121
BlockInit.ENGINE_STRUCTURAL,
122122
BlockInit.BIG_ENGINE_STRUCTURAL,
123123
BlockInit.SMALL_ENGINE_STRUCTURAL,
124-
ItemInit.STARTER_CHARGE,
125124
ItemInit.REINFORCED_INJECTOR,
126125
ItemInit.REINFORCED_INJECTOR_GRID,
127126
ItemInit.INJECTOR,

‎src/main/java/com/rae/creatingspace/init/TagsInit.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class TagsInit extends AllTags {
3232
public enum CustomNameSpace {
3333

3434
MOD(CreatingSpace.MODID, false, true),
35-
FORGE("forge"),
35+
COMMON("c"),
3636
TIC("tconstruct"),
3737
QUARK("quark");
3838

@@ -51,7 +51,8 @@ public enum CustomNameSpace {
5151
}
5252
}
5353
public enum CustomBlockTags {
54-
MOON_CARVER_REPLACEABLES(),MOON_STONE_ORE_REPLACEABLES();
54+
MOON_CARVER_REPLACEABLES(),
55+
MOON_STONE_ORE_REPLACEABLES();
5556

5657
public final TagKey<Block> tag;
5758
public final boolean alwaysDatagen;

0 commit comments

Comments
 (0)