Combine all versions into a single tree

This commit is contained in:
Jonas Herzig
2018-02-10 23:35:57 +01:00
parent ec50efec10
commit 748b9da443
95 changed files with 2731 additions and 644 deletions

View File

@@ -4,13 +4,14 @@ import com.replaymod.compat.bettersprinting.DisableBetterSprinting;
import com.replaymod.compat.optifine.DisableFastRender;
import com.replaymod.compat.oranges17animations.HideInvisibleEntities;
import com.replaymod.compat.shaders.ShaderBeginRender;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import org.apache.logging.log4j.Logger;
import static com.replaymod.core.versions.MCVer.*;
@Mod(modid = ReplayModCompat.MOD_ID,
version = "@MOD_VERSION@",
acceptedMinecraftVersions = "@MC_VERSION@",
@@ -29,7 +30,7 @@ public class ReplayModCompat {
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
EventBus bus = MinecraftForge.EVENT_BUS;
EventBus bus = FML_BUS;
bus.register(new ShaderBeginRender());
bus.register(new DisableFastRender());
bus.register(new HideInvisibleEntities());

View File

@@ -2,16 +2,10 @@ package com.replaymod.compat.bettersprinting;
import com.replaymod.replay.ReplayModReplay;
import com.replaymod.replay.events.ReplayChatMessageEvent;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldEventListener;
import net.minecraft.world.World;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
@@ -22,10 +16,24 @@ import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
import net.minecraftforge.fml.common.versioning.Restriction;
import net.minecraftforge.fml.common.versioning.VersionRange;
//#if MC>=10904
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldEventListener;
import net.minecraft.world.World;
import javax.annotation.Nullable;
//#else
//$$ import net.minecraft.util.BlockPos;
//$$ import net.minecraft.world.IWorldAccess;
//#endif
import java.util.Collections;
import static com.replaymod.compat.ReplayModCompat.LOGGER;
import static com.replaymod.core.versions.MCVer.*;
/**
* Old Better Sprinting versions replace the vanilla player with their own, overridden instance (replacing the camera entity).
@@ -56,17 +64,25 @@ public class DisableBetterSprinting {
@SubscribeEvent(priority = EventPriority.HIGH)
public void beforeGuiOpenEvent(GuiOpenEvent event) {
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
if (ReplayModReplay.instance.getReplayHandler() != null && world(mc) != null) {
// During replay, get ready to revert BetterSprinting's overwritten playerController
originalController = mc.playerController;
mc.world.addEventListener(worldAccessHook);
//#if MC>=10904
world(mc).addEventListener(worldAccessHook);
//#else
//$$ world(mc).addWorldAccess(worldAccessHook);
//#endif
}
}
@SubscribeEvent(priority = EventPriority.LOW)
public void afterGuiOpenEvent(GuiOpenEvent event) {
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
mc.world.addEventListener(worldAccessHook);
if (ReplayModReplay.instance.getReplayHandler() != null && world(mc) != null) {
//#if MC>=10904
world(mc).addEventListener(worldAccessHook);
//#else
//$$ world(mc).addWorldAccess(worldAccessHook);
//#endif
}
}
@@ -82,7 +98,13 @@ public class DisableBetterSprinting {
}
}
private class BetterSprintingWorldAccess implements IWorldEventListener {
private class BetterSprintingWorldAccess
//#if MC>=10904
implements IWorldEventListener
//#else
//$$ implements IWorldAccess
//#endif
{
@Override
public void onEntityRemoved(Entity entityIn) {
if (mc.playerController != null && mc.playerController.getClass().getName().equals(CONTROLLER_OVERRIDE_CLASS_NAME)) {
@@ -93,16 +115,34 @@ public class DisableBetterSprinting {
}
}
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
@Override public void notifyLightSet(BlockPos pos) {}
@Override public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {}
@Override public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {}
@Override public void playRecord(SoundEvent soundIn, BlockPos pos) {}
@Override public void spawnParticle(int p_180442_1_, boolean p_180442_2_, double p_180442_3_, double p_180442_5_, double p_180442_7_, double p_180442_9_, double p_180442_11_, double p_180442_13_, int... p_180442_15_) {}
@Override public void spawnParticle(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
@Override public void onEntityAdded(Entity entityIn) {}
@Override public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {}
@Override public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
@Override public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
//#if MC>=10904
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
@Override public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {}
@Override public void playRecord(SoundEvent soundIn, BlockPos pos) {}
@Override public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
//#if MC>=11100
//#if MC>=11102
@Override public void spawnParticle(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
//#else
//$$ @Override public void func_190570_a(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
//#endif
//#endif
//#else
//$$ @Override public void markBlockForUpdate(BlockPos pos) {}
//$$ @Override public void playSound(String soundName, double x, double y, double z, float volume, float pitch) {}
//$$ @Override public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch) {}
//$$ @Override public void playRecord(String recordName, BlockPos blockPosIn) {}
//#if MC>=10809
//$$ @Override public void playAuxSFX(EntityPlayer p_180439_1_, int p_180439_2_, BlockPos blockPosIn, int p_180439_4_) {}
//#else
//$$ @Override public void playAusSFX(EntityPlayer p_180439_1_, int p_180439_2_, BlockPos blockPosIn, int p_180439_4_) {}
//#endif
//#endif
}
}

View File

@@ -26,7 +26,11 @@ public abstract class MixinMinecraft {
&& ReplayModReplay.instance.getReplayHandler() != null) {
for (StackTraceElement elem : Thread.currentThread().getStackTrace()) {
if ("mapwriter.util.Utils".equals(elem.getClassName()) && "getWorldName".equals(elem.getMethodName())) {
//#if MC>=10809
ci.setReturnValue(new ServerData(null, "replay", false));
//#else
//$$ ci.setReturnValue(new ServerData(null, "replay"));
//#endif
return;
}
}

View File

@@ -7,6 +7,8 @@ import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import static com.replaymod.core.versions.MCVer.*;
/**
* Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead.
* This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities.
@@ -20,7 +22,7 @@ public class HideInvisibleEntities {
@SubscribeEvent(priority = EventPriority.HIGH)
public void preRenderLiving(RenderLivingEvent.Pre event) {
if (modLoaded) {
if (mc.player instanceof CameraEntity && event.getEntity().isInvisible()) {
if (player(mc) instanceof CameraEntity && getEntity(event).isInvisible()) {
event.setCanceled(true);
}
}