public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) {
if (args.length == 0) {
sender.addChatMessage((ITextComponent)new TextComponentString("Usage: /motionblur <0 - 10>."));
}
else {
final int amount = NumberUtils.toInt(args[0], -1);
if (amount >= 0 && amount <= 10) {
if (MotionBlurMod.isFastRenderEnabled()) {
sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur does not work if Fast Render is enabled, please disable it in Options > Video Settings > Performance."));
}
else {
if (this.mc.entityRenderer.getShaderGroup() != null) {
this.mc.entityRenderer.getShaderGroup().deleteShaderGroup();
}
if (amount != 0) {
MotionBlurMod.isEnabled = true;
MotionBlurMod.blurAmount = amount;
try {
final Method method = ReflectionHelper.findMethod((Class)EntityRenderer.class, (Object)this.mc.entityRenderer, new String[] { "loadShader", "loadShader" }, new Class[] { ResourceLocation.class });
method.invoke(this.mc.entityRenderer, new ResourceLocation("motionblur", "motionblur"));
this.mc.entityRenderer.getShaderGroup().createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur enabled."));
}
catch (Throwable ex) {
sender.addChatMessage((ITextComponent)new TextComponentString("Failed to enable Motion blur."));
ex.printStackTrace();
}
}
else {
MotionBlurMod.isEnabled = false;
sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur disabled."));
}
}
}
else {
sender.addChatMessage((ITextComponent)new TextComponentString("Invalid amount."));
}
}
}
Here is MotionBlurCommand class
@Mod(name = "MotionBlurMod", modid = "motionblurmod", version = "1.0", acceptedMinecraftVersions = "*")
public class MotionBlurMod
{
private Minecraft mc;
private Map domainResourceManagers;
public static double blurAmount;
public static boolean isEnabled;
public MotionBlurMod() {
this.mc = Minecraft.getMinecraft();
}
@Mod.EventHandler
public void init(final FMLInitializationEvent event) {
ClientCommandHandler.instance.registerCommand((ICommand)new MotionBlurCommand());
MinecraftForge.EVENT_BUS.register((Object)this);
}
@SubscribeEvent
public void onClientTick(final TickEvent.ClientTickEvent event) {
if (this.domainResourceManagers == null) {
try {
for (final Field field : SimpleReloadableResourceManager.class.getDeclaredFields()) {
if (field.getType() == Map.class) {
field.setAccessible(true);
this.domainResourceManagers = (Map)field.get(Minecraft.getMinecraft().getResourceManager());
break;
}
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
if (!this.domainResourceManagers.containsKey("motionblur")) {
this.domainResourceManagers.put("motionblur", new MotionBlurResourceManager());
}
}
@SubscribeEvent
public void onKey(final InputEvent.KeyInputEvent event) {
if (this.mc.thePlayer != null && MotionBlurMod.isEnabled && Keyboard.isKeyDown(this.mc.gameSettings.keyBindTogglePerspective.getKeyCode())) {
try {
final Method method = ReflectionHelper.findMethod((Class)EntityRenderer.class, (Object)this.mc.entityRenderer, new String[] { "loadShader", "loadShader" }, new Class[] { ResourceLocation.class });
method.invoke(this.mc.entityRenderer, new ResourceLocation("motionblur", "motionblur"));
this.mc.entityRenderer.getShaderGroup().createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
}
catch (Exception ex) {}
}
}
public static boolean isFastRenderEnabled() {
try {
final Field fastRender = GameSettings.class.getDeclaredField("ofFastRender");
return fastRender.getBoolean(Minecraft.getMinecraft().gameSettings);
}
catch (Exception var1) {
return false;
}
}
static {
MotionBlurMod.blurAmount = 0.75;
MotionBlurMod.isEnabled = false;
}
}
Here MotionBlurMod main class
public class MotionBlurResource implements IResource
{
private static final String JSON = "{\"targets\":[\"swap\",\"previous\"],\"passes\":[{\"name\":\"phosphor\",\"intarget\":\"minecraft:main\",\"outtarget\":\"swap\",\"auxtargets\":[{\"name\":\"PrevSampler\",\"id\":\"previous\"}],\"uniforms\":[{\"name\":\"Phosphor\",\"values\":[%.2f, %.2f, %.2f]}]},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"previous\"},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"minecraft:main\"}]}";
public InputStream getInputStream() {
final double amount = 0.7 + MotionBlurMod.blurAmount / 100.0 * 3.0 - 0.01;
return IOUtils.toInputStream(String.format(Locale.ENGLISH, "{\"targets\":[\"swap\",\"previous\"],\"passes\":[{\"name\":\"phosphor\",\"intarget\":\"minecraft:main\",\"outtarget\":\"swap\",\"auxtargets\":[{\"name\":\"PrevSampler\",\"id\":\"previous\"}],\"uniforms\":[{\"name\":\"Phosphor\",\"values\":[%.2f, %.2f, %.2f]}]},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"previous\"},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"minecraft:main\"}]}", amount, amount, amount));
}
public boolean hasMetadata() {
return false;
}
public IMetadataSection getMetadata(final String metadata) {
return null;
}
public ResourceLocation getResourceLocation() {
return null;
}
public String getResourcePackName() {
return null;
}
public void close() throws IOException {
}
}
Here MotionBlurRessource class
public class MotionBlurResourceManager implements IResourceManager
{
public Set<String> getResourceDomains() {
return null;
}
public IResource getResource(final ResourceLocation location) throws IOException {
return (IResource)new MotionBlurResource();
}
public List<IResource> getAllResources(final ResourceLocation location) throws IOException {
return null;
}
}
Then MotionBlurRessourceManager class
Anyways, what does it mean "don't have a uniform with the InSize name" ?
Thank you for replying