Skip to content

Commit

Permalink
Fix #51: MEGA Pattern Provider doesn't rotate properly on the client …
Browse files Browse the repository at this point in the history
…side
  • Loading branch information
62832 committed Apr 23, 2023
1 parent 9e29f58 commit 52ed213
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
14 changes: 5 additions & 9 deletions fabric/src/main/java/gripe/_90/megacells/MEGACellsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;

import appeng.api.IAEAddonEntrypoint;
Expand Down Expand Up @@ -70,14 +69,14 @@ private void initBlockModels() {
BlockEntityRenderers.register(MEGABlockEntities.MEGA_CRAFTING_MONITOR, CraftingMonitorRenderer::new);

ModelsReloadCallback.EVENT.register(modelRegistry -> {
var customizers = new HashMap<ResourceLocation, Function<BakedModel, BakedModel>>();
customizers.put(MEGABlocks.CRAFTING_MONITOR.id(), model -> model instanceof MonitorBakedModel
var customizers = new HashMap<String, Function<BakedModel, BakedModel>>();
customizers.put(MEGABlocks.CRAFTING_MONITOR.id().getPath(), model -> model instanceof MonitorBakedModel
? model
: new AutoRotatingBakedModel(model));

for (var block : MEGABlocks.getBlocks()) {
if (!(block.block() instanceof CraftingUnitBlock)) {
customizers.put(block.id(), AutoRotatingBakedModel::new);
customizers.put(block.id().getPath(), AutoRotatingBakedModel::new);
}
}

Expand All @@ -87,14 +86,11 @@ private void initBlockModels() {
}

var originalModel = modelRegistry.get(location);
var customizer = customizers.get(location);
var customizer = customizers.get(location.getPath());

if (customizer != null) {
var newModel = customizer.apply(originalModel);

if (newModel != originalModel) {
modelRegistry.put(location, newModel);
}
modelRegistry.put(location, newModel);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
Expand Down Expand Up @@ -81,14 +80,14 @@ private void initModels(ModelEvent.RegisterGeometryLoaders event) {

private void initModelRotation(ModelEvent.BakingCompleted event) {
var modelRegistry = event.getModels();
var customizers = new HashMap<ResourceLocation, Function<BakedModel, BakedModel>>();
customizers.put(MEGABlocks.CRAFTING_MONITOR.id(), model -> model instanceof MonitorBakedModel
var customizers = new HashMap<String, Function<BakedModel, BakedModel>>();
customizers.put(MEGABlocks.CRAFTING_MONITOR.id().getPath(), model -> model instanceof MonitorBakedModel
? model
: new AutoRotatingBakedModel(model));

for (var block : MEGABlocks.getBlocks()) {
if (!(block.block() instanceof CraftingUnitBlock)) {
customizers.put(block.id(), AutoRotatingBakedModel::new);
customizers.put(block.id().getPath(), AutoRotatingBakedModel::new);
}
}

Expand All @@ -98,14 +97,11 @@ private void initModelRotation(ModelEvent.BakingCompleted event) {
}

var originalModel = modelRegistry.get(location);
var customizer = customizers.get(location);
var customizer = customizers.get(location.getPath());

if (customizer != null) {
var newModel = customizer.apply(originalModel);

if (newModel != originalModel) {
modelRegistry.put(location, newModel);
}
modelRegistry.put(location, newModel);
}
}
}
Expand Down

0 comments on commit 52ed213

Please sign in to comment.