-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa2b1d3
commit de4e1e7
Showing
5 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/turniplabs/halplibe/mixin/mixins/models/BlockModelDispatcherMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package turniplabs.halplibe.mixin.mixins.models; | ||
|
||
import net.minecraft.client.render.block.model.BlockModel; | ||
import net.minecraft.client.render.block.model.BlockModelDispatcher; | ||
import net.minecraft.core.block.Block; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import turniplabs.halplibe.helper.BlockBuilder; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
|
||
@Mixin(value = BlockModelDispatcher.class, remap = false) | ||
public abstract class BlockModelDispatcherMixin { | ||
@Shadow public abstract void addDispatch(BlockModel dispatchable); | ||
|
||
@Inject(method = "<init>()V", at = @At("TAIL")) | ||
private void addQueuedModels(CallbackInfo ci){ | ||
try { | ||
Set<Map.Entry<Block, Function<Block, BlockModel<?>>>>entries = ((Map<Block, Function<Block, BlockModel<?>>>) BlockBuilder.class.getField("queuedBlockModels").get(null)).entrySet(); | ||
for (Map.Entry<Block, Function<Block, BlockModel<?>>> entry : entries){ | ||
addDispatch(entry.getValue().apply(entry.getKey())); | ||
} | ||
BlockBuilder.class.getField("blockDispatcherInitialized").set(null, true); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/turniplabs/halplibe/mixin/mixins/models/ItemModelDispatcherMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package turniplabs.halplibe.mixin.mixins.models; | ||
|
||
import net.minecraft.client.render.item.model.ItemModel; | ||
import net.minecraft.client.render.item.model.ItemModelDispatcher; | ||
import net.minecraft.core.item.Item; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import turniplabs.halplibe.helper.ItemHelper; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
@Mixin(value = ItemModelDispatcher.class, remap = false) | ||
public abstract class ItemModelDispatcherMixin { | ||
@Shadow public abstract void addDispatch(ItemModel dispatchable); | ||
|
||
@Inject(method = "<init>()V", at = @At("TAIL")) | ||
private void addQueuedModels(CallbackInfo ci){ | ||
try { | ||
Set<Map.Entry<Item, Function<Item, ItemModel>>> entries = ((Map<Item, Function<Item, ItemModel>>) ItemHelper.class.getField("queuedItemModels").get(null)).entrySet(); | ||
for (Map.Entry<Item, Function<Item, ItemModel>> entry : entries){ | ||
addDispatch(entry.getValue().apply(entry.getKey())); | ||
} | ||
ItemHelper.class.getField("itemDispatcherInitialized").set(null, true); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters