mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Fix pylon and pool rendering in multiblock. Closes #25
This commit is contained in:
1 parent
61b8616008
commit
c3dce97e0d
5 files changed
+53
-5
No files matched your search
+1
-1
@@ -58,7 +58,7 @@ public class MultiblockComponent {
|
||||
}
|
||||
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos) == state; // todo 1.8?
|
||||
return world.getBlockState(pos) == state;
|
||||
}
|
||||
|
||||
public ItemStack[] getMaterials() {
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package vazkii.botania.api.lexicon.multiblock.component;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// Multiblock component that only compares blocks, not blockstates
|
||||
public class StateInsensitiveComponent extends MultiblockComponent {
|
||||
|
||||
public StateInsensitiveComponent(BlockPos relPos, Block block) {
|
||||
super(relPos, block.getDefaultState(), false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == this.getBlockState().getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockComponent copy() {
|
||||
return new StateInsensitiveComponent(getRelativePosition(), getBlockState().getBlock());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public final class HUDHandler {
|
||||
((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.getBlockPos());
|
||||
profiler.endSection();
|
||||
}
|
||||
} else if(pos != null && equippedStack.getItem() instanceof ILexicon)
|
||||
} else if(block != null && equippedStack.getItem() instanceof ILexicon)
|
||||
drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution);
|
||||
if(tile != null && tile instanceof TilePool)
|
||||
renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack);
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -36,6 +37,7 @@ import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -51,11 +53,15 @@ public final class MultiblockRenderHandler {
|
||||
public static int dimension;
|
||||
|
||||
static {
|
||||
//todo 1.8 remove when fixed by forge
|
||||
// todo 1.8.8 temporary shim, because cannot renderBlockBrightness directly, see MinecraftForge issue 2353
|
||||
IMultiblockRenderHook.renderHooks.put(ModBlocks.pylon, new IMultiblockRenderHook() {
|
||||
@Override
|
||||
public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, IBlockState state, MultiblockComponent comp, float alpha) {
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
|
||||
// Steal itemstack model since it has the proper group visibilities configured
|
||||
ItemStack stack = new ItemStack(ModBlocks.pylon, 1, state.getBlock().getMetaFromState(state));
|
||||
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
|
||||
GlStateManager.scale(0.65F, 0.65, 0.65F);
|
||||
GlStateManager.translate(0.5F, -0.75F, 0.5F);
|
||||
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(model, state, 1.0F, false);
|
||||
}
|
||||
|
||||
@@ -64,6 +70,21 @@ public final class MultiblockRenderHandler {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO also a temporary shim for same reason as above
|
||||
IMultiblockRenderHook.renderHooks.put(ModBlocks.pool, new IMultiblockRenderHook() {
|
||||
@Override
|
||||
public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, IBlockState state, MultiblockComponent comp, float alpha) {
|
||||
GlStateManager.translate(-0.5F, -0.5F, 0.5F);
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(ModBlocks.pool.getDefaultState());
|
||||
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(model, ModBlocks.pool.getDefaultState(), 1.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsTranslate(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setMultiblock(MultiblockSet set) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.StateInsensitiveComponent;
|
||||
import vazkii.botania.api.recipe.ElvenPortalUpdateEvent;
|
||||
import vazkii.botania.api.recipe.IElvenItem;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
@@ -114,7 +115,7 @@ public class TileAlfPortal extends TileMod implements ITickable {
|
||||
for(BlockPos p : PYLON_POSITIONS)
|
||||
mb.addComponent(new BlockPos(-p.getX(), p.getY() + 1, -p.getZ()), ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.NATURA));
|
||||
for(BlockPos p : POOL_POSITIONS)
|
||||
mb.addComponent(new BlockPos(-p.getX(), p.getY() + 1, -p.getZ()), ModBlocks.pool.getDefaultState());
|
||||
mb.addComponent(new StateInsensitiveComponent(new BlockPos(-p.getX(), p.getY() + 1, -p.getZ()), ModBlocks.pool));
|
||||
|
||||
mb.addComponent(new BlockPos(0, 1, 0), ModBlocks.alfPortal.getDefaultState());
|
||||
mb.setRenderOffset(new BlockPos(0, -1, 0));
|
||||
|
||||
Reference in new issue
Block a user