mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
Clean up more usages of ObfuscationReflectionHelper
This commit is contained in:
1 parent
b28d64050d
commit
7ab67b34bf
8 files changed
+61
-69
No files matched your search
@@ -14,7 +14,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.client.render.tile.RenderTileRedString;
|
||||
@@ -23,8 +22,7 @@ import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import vazkii.botania.mixin.MixinMinecraft;
|
||||
|
||||
public final class ClientTickHandler {
|
||||
|
||||
@@ -36,7 +34,6 @@ public final class ClientTickHandler {
|
||||
public static float partialTicks = 0;
|
||||
public static float delta = 0;
|
||||
public static float total = 0;
|
||||
private static final Field RENDER_PARTIAL_TICKS_PAUSED = ObfuscationReflectionHelper.findField(Minecraft.class, "field_193996_ah");
|
||||
|
||||
private static void calcDelta() {
|
||||
float oldTotal = total;
|
||||
@@ -51,12 +48,8 @@ public final class ClientTickHandler {
|
||||
|
||||
if (mc.isGamePaused()) {
|
||||
// If game is paused, need to use the saved value. The event is always fired with the "true" value which
|
||||
// keeps updating when paused. See RenderTickEvent fire site for details
|
||||
try {
|
||||
partialTicks = (float) RENDER_PARTIAL_TICKS_PAUSED.get(mc);
|
||||
} catch (IllegalAccessException ignored) {
|
||||
// fall back to jittery one
|
||||
}
|
||||
// keeps updating when paused. See RenderTickEvent fire site for details, remove when MinecraftForge#6991 is resolved
|
||||
partialTicks = ((MixinMinecraft) mc).getRenderPartialTicksPaused();
|
||||
}
|
||||
} else {
|
||||
calcDelta();
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.ReloadListener;
|
||||
import net.minecraft.client.util.Splashes;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SplashHandler {
|
||||
// This is probably the best spot to add a splash listener. It's an event fired after splash reload listener
|
||||
// is registered, but before resource reload happens. Doing the initial load ourselves is not effective,
|
||||
// as we would do it before the splashes are added, and the list is cleared when adding.
|
||||
public static void registerFactories(ParticleFactoryRegisterEvent event) {
|
||||
((SimpleReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(new SplashResourceListener());
|
||||
}
|
||||
|
||||
private static class SplashResourceListener extends ReloadListener<Unit> {
|
||||
@Override
|
||||
@Nonnull
|
||||
protected Unit prepare(@Nonnull IResourceManager resourceManager, @Nonnull IProfiler profiler) {
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(@Nonnull Unit unused, @Nonnull IResourceManager resourceManager, @Nonnull IProfiler profiler) {
|
||||
if (!ConfigHandler.CLIENT.splashesEnabled.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Splashes splashes = Minecraft.getInstance().getSplashes();
|
||||
List<String> splashList = ObfuscationReflectionHelper.getPrivateValue(Splashes.class, splashes, "field_215280_c"); //possibleSplashes
|
||||
splashList.add("Do not feed bread to elves!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ import vazkii.botania.common.item.relic.ItemInfiniteFruit;
|
||||
import vazkii.botania.common.item.rod.ItemTornadoRod;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.mixin.MixinBiomeGeneratorTypeScreens;
|
||||
import vazkii.botania.mixin.MixinRenderTypeBuffers;
|
||||
import vazkii.patchouli.api.IMultiblock;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
@@ -108,7 +109,6 @@ public class ClientProxy implements IProxy {
|
||||
modBus.addListener(MiscellaneousIcons.INSTANCE::onTextureStitchPost);
|
||||
modBus.addListener(MiscellaneousIcons.INSTANCE::onModelRegister);
|
||||
modBus.addListener(MiscellaneousIcons.INSTANCE::onModelBake);
|
||||
modBus.addListener(SplashHandler::registerFactories);
|
||||
modBus.addListener(ModelHandler::registerModels);
|
||||
modBus.addListener(ModParticles.FactoryHandler::registerFactories);
|
||||
|
||||
@@ -298,7 +298,7 @@ public class ClientProxy implements IProxy {
|
||||
ColorHandler.init();
|
||||
|
||||
// Needed to prevent mana pools on carts from X-raying through the cart
|
||||
SortedMap<RenderType, BufferBuilder> layers = ObfuscationReflectionHelper.getPrivateValue(RenderTypeBuffers.class, Minecraft.getInstance().getRenderTypeBuffers(), "field_228480_b_");
|
||||
SortedMap<RenderType, BufferBuilder> layers = ((MixinRenderTypeBuffers) Minecraft.getInstance().getRenderTypeBuffers()).getFixedBuffers();
|
||||
layers.put(RenderHelper.MANA_POOL_WATER, new BufferBuilder(RenderHelper.MANA_POOL_WATER.getBufferSize()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.SimpleModelTransform;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -124,8 +123,6 @@ public class GunModel implements IBakedModel {
|
||||
}
|
||||
|
||||
private static class CompositeBakedModel extends DelegatedModel {
|
||||
private static final BlockModel MODEL_GENERATED = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, null, "field_177606_o");
|
||||
|
||||
private final List<BakedQuad> genQuads = new ArrayList<>();
|
||||
private final Map<Direction, List<BakedQuad>> faceQuads = new EnumMap<>(Direction.class);
|
||||
|
||||
@@ -138,7 +135,7 @@ public class GunModel implements IBakedModel {
|
||||
ResourceLocation name = prefix("gun_with_" + lensId.toString().replace(':', '_'));
|
||||
|
||||
IBakedModel lensBaked;
|
||||
if (lensUnbaked instanceof BlockModel && ((BlockModel) lensUnbaked).getRootModel() == MODEL_GENERATED) {
|
||||
if (lensUnbaked instanceof BlockModel && ((BlockModel) lensUnbaked).getRootModel() == ModelBakery.MODEL_GENERATED) {
|
||||
BlockModel bm = (BlockModel) lensUnbaked;
|
||||
lensBaked = new ItemModelGenerator()
|
||||
.makeItemModel(ModelLoader.defaultTextureGetter(), bm)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package vazkii.botania.mixin;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public interface MixinMinecraft {
|
||||
@Accessor
|
||||
float getRenderPartialTicksPaused();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package vazkii.botania.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeBuffers;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.SortedMap;
|
||||
|
||||
@Mixin(RenderTypeBuffers.class)
|
||||
public interface MixinRenderTypeBuffers {
|
||||
@Accessor
|
||||
SortedMap<RenderType, BufferBuilder> getFixedBuffers();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package vazkii.botania.mixin;
|
||||
|
||||
import net.minecraft.client.util.Splashes;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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 vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(Splashes.class)
|
||||
public class MixinSplashes {
|
||||
@Shadow @Final private List<String> possibleSplashes;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "apply")
|
||||
public void addSplashes(List<String> splashes, IResourceManager resourceManager, IProfiler profiler, CallbackInfo ci) {
|
||||
if (ConfigHandler.CLIENT.splashesEnabled.get()) {
|
||||
possibleSplashes.add("Do not feed bread to elves!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,11 @@
|
||||
"MixinFirstPersonRenderer",
|
||||
"MixinItemOverrideList",
|
||||
"MixinModelBakery",
|
||||
"MixinMinecraft",
|
||||
"MixinRecipeBookGui",
|
||||
"MixinRecipeBookPage",
|
||||
"MixinRenderTypeBuffers",
|
||||
"MixinSplashes",
|
||||
"MixinWorldRenderer"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
Reference in new issue
Block a user