Skip to content

Commit

Permalink
:D
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Apr 10, 2019
1 parent f4b9805 commit f2b747c
Show file tree
Hide file tree
Showing 17 changed files with 414 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -23,6 +25,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkCanBlockRenderInLayerEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -22,6 +24,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkCanBlockRenderTypeBeRenderedEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -23,6 +25,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkCanFluidRenderInLayerEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -15,6 +17,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkCheckWorldEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.renderer.chunk.RenderChunk;
import net.minecraft.util.BlockRenderLayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;

import javax.annotation.Nonnull;
Expand All @@ -14,6 +15,7 @@
* Called when a {@link RenderChunk#rebuildChunk} is called.
* This event is fired on the {@link MinecraftForge#EVENT_BUS}
*/
@Cancelable
public class RebuildChunkEvent extends Event {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -22,6 +23,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkIsFluidEmptyEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import net.minecraft.client.renderer.chunk.ChunkRenderTask;
import net.minecraft.client.renderer.chunk.RenderChunk;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;

/**
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkPreEvent extends RebuildChunkEvent {

public RebuildChunkPreEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -19,6 +21,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkPreIterationEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -18,6 +20,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkPreRenderEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -24,6 +26,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkRenderBlockEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;

import javax.annotation.Nonnull;
import java.util.HashSet;
Expand All @@ -24,6 +26,7 @@
* @author Cadiboo
*/
@Cancelable
@HasResult
public class RebuildChunkRenderFluidEvent extends RebuildChunkEvent {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static io.github.cadiboo.renderchunkrebuildchunkhooks.hooks.HookConfig.postRebuildChunkPreRenderEvent;
import static io.github.cadiboo.renderchunkrebuildchunkhooks.hooks.HookConfig.postRebuildChunkRenderBlockEvent;
import static io.github.cadiboo.renderchunkrebuildchunkhooks.hooks.HookConfig.postRebuildChunkRenderFluidEvent;
import static net.minecraftforge.eventbus.api.Event.Result.DENY;

/**
* @author Cadiboo
Expand All @@ -64,7 +65,7 @@ public static boolean pre(final RenderChunk renderChunk, final float x, final fl
if (postRebuildChunkPreEvent) {
final RebuildChunkPreEvent event = new RebuildChunkPreEvent(renderChunk, x, y, z, generator);
MinecraftForge.EVENT_BUS.post(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand All @@ -75,7 +76,7 @@ public static boolean checkWorld(final RenderChunk renderChunk, final float x, f
if (postRebuildChunkCheckWorldEvent) {
final RebuildChunkCheckWorldEvent event = new RebuildChunkCheckWorldEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, worldRef);
MinecraftForge.EVENT_BUS.post(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand All @@ -86,7 +87,7 @@ public static boolean preRender(final RenderChunk renderChunk, final float x, fi
if (postRebuildChunkPreRenderEvent) {
final RebuildChunkPreRenderEvent event = new RebuildChunkPreRenderEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_);
MinecraftForge.EVENT_BUS.post(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand All @@ -97,7 +98,7 @@ public static boolean preIteration(final RenderChunk renderChunk, final float x,
if (postRebuildChunkPreIterationEvent) {
final RebuildChunkPreIterationEvent event = new RebuildChunkPreIterationEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher);
MinecraftForge.EVENT_BUS.post(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand All @@ -113,19 +114,19 @@ public static boolean canFluidRender(final RenderChunk renderChunk, final float
final RebuildChunkCanFluidRenderInLayerEvent canFluidRenderInLayerEvent = PooledHandler.setupRebuildChunkCanFluidRenderInLayerEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1);
MinecraftForge.EVENT_BUS.post(canFluidRenderInLayerEvent);
PooledHandler.tearDown(canFluidRenderInLayerEvent);
return !isFluidEmptyEvent.isCanceled() && !canFluidRenderInLayerEvent.isCanceled();
return isFluidEmptyEvent.getResult() != DENY && canFluidRenderInLayerEvent.getResult() != DENY;
} else {
final RebuildChunkIsFluidEmptyEvent isFluidEmptyEvent = PooledHandler.setupRebuildChunkIsFluidEmptyEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate);
MinecraftForge.EVENT_BUS.post(isFluidEmptyEvent);
PooledHandler.tearDown(isFluidEmptyEvent);
return !isFluidEmptyEvent.isCanceled() && ifluidstate.canRenderInLayer(blockrenderlayer1);
return isFluidEmptyEvent.getResult() != DENY && ifluidstate.canRenderInLayer(blockrenderlayer1);
}
} else {
if (postRebuildChunkCanFluidRenderInLayerEvent) {
final RebuildChunkCanFluidRenderInLayerEvent canFluidRenderInLayerEvent = PooledHandler.setupRebuildChunkCanFluidRenderInLayerEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1);
MinecraftForge.EVENT_BUS.post(canFluidRenderInLayerEvent);
PooledHandler.tearDown(canFluidRenderInLayerEvent);
return !ifluidstate.isEmpty() && !canFluidRenderInLayerEvent.isCanceled();
return !ifluidstate.isEmpty() && canFluidRenderInLayerEvent.getResult() != DENY;
} else {
return !ifluidstate.isEmpty() && ifluidstate.canRenderInLayer(blockrenderlayer1);
}
Expand All @@ -138,7 +139,7 @@ public static boolean preRenderFluid(final RenderChunk renderChunk, final float
final RebuildChunkRenderFluidEvent event = PooledHandler.setupRebuildChunkRenderFluidEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1, j, bufferbuilder);
MinecraftForge.EVENT_BUS.post(event);
PooledHandler.tearDown(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand All @@ -154,19 +155,19 @@ public static boolean canBlockRender(final RenderChunk renderChunk, final float
final RebuildChunkCanBlockRenderInLayerEvent canBlockRenderInLayerEvent = PooledHandler.setupRebuildChunkCanBlockRenderInLayerEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1);
MinecraftForge.EVENT_BUS.post(canBlockRenderInLayerEvent);
PooledHandler.tearDown(canBlockRenderInLayerEvent);
return !canBlockRenderTypeBeRenderedEvent.isCanceled() && !canBlockRenderInLayerEvent.isCanceled();
return canBlockRenderTypeBeRenderedEvent.getResult() != DENY && canBlockRenderInLayerEvent.getResult() != DENY;
} else {
final RebuildChunkCanBlockRenderTypeBeRenderedEvent canBlockRenderTypeBeRenderedEvent = PooledHandler.setupRebuildChunkCanBlockRenderTypeBeRenderedEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate);
MinecraftForge.EVENT_BUS.post(canBlockRenderTypeBeRenderedEvent);
PooledHandler.tearDown(canBlockRenderTypeBeRenderedEvent);
return !canBlockRenderTypeBeRenderedEvent.isCanceled() && iblockstate.canRenderInLayer(blockrenderlayer1);
return canBlockRenderTypeBeRenderedEvent.getResult() != DENY && iblockstate.canRenderInLayer(blockrenderlayer1);
}
} else {
if (postRebuildChunkCanBlockRenderInLayerEvent) {
final RebuildChunkCanBlockRenderInLayerEvent canBlockRenderInLayerEvent = PooledHandler.setupRebuildChunkCanBlockRenderInLayerEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1);
MinecraftForge.EVENT_BUS.post(canBlockRenderInLayerEvent);
PooledHandler.tearDown(canBlockRenderInLayerEvent);
return iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE && !canBlockRenderInLayerEvent.isCanceled();
return iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE && canBlockRenderInLayerEvent.getResult() != DENY;
} else {
return iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE && iblockstate.canRenderInLayer(blockrenderlayer1);
}
Expand All @@ -179,7 +180,7 @@ public static boolean preRenderBlock(final RenderChunk renderChunk, final float
final RebuildChunkRenderBlockEvent event = PooledHandler.setupRebuildChunkRenderBlockEvent(renderChunk, x, y, z, generator, compiledchunk, blockpos, blockpos1, world, lvt_10_1_, lvt_11_1_, lvt_12_1_, aboolean, random, blockrendererdispatcher, iblockstate, block, ifluidstate, blockrenderlayer1, k, bufferbuilder1);
MinecraftForge.EVENT_BUS.post(event);
PooledHandler.tearDown(event);
return event.isCanceled();
return event.getResult() != DENY;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.cadiboo.renderchunkrebuildchunkhooks;

import io.github.cadiboo.renderchunkrebuildchunkhooks.event.RebuildChunkCanBlockRenderInLayerEvent;
import io.github.cadiboo.renderchunkrebuildchunkhooks.hooks.HookConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockRenderLayer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

import static io.github.cadiboo.renderchunkrebuildchunkhooks.util.Refs.MOD_ID;
import static net.minecraft.util.BlockRenderLayer.CUTOUT;
import static net.minecraft.util.BlockRenderLayer.CUTOUT_MIPPED;
import static net.minecraftforge.eventbus.api.Event.Result.ALLOW;

@EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT)
public final class CorrectBlockRenderLayerTester {

private static boolean enabled = true;
static {
if (enabled) {
HookConfig.enableRebuildChunkCanBlockRenderInLayerEvent();
}
}

@SubscribeEvent
public static void onRebuildChunkCanBlockRenderInLayerEvent(final RebuildChunkCanBlockRenderInLayerEvent event) {
if (!enabled) {
return;
}

if (event.getBlockRenderLayer() == getTargetLayer()) {
event.setResult(ALLOW);
}
}

private static BlockRenderLayer getTargetLayer() {
return Minecraft.getInstance().gameSettings.mipmapLevels > 0 ? CUTOUT : CUTOUT_MIPPED;
}

}
Loading

0 comments on commit f2b747c

Please sign in to comment.