mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Make that the multiblocks error renderers are only work with naturalist eyes
This commit is contained in:
1 parent
b297bbb2c4
commit
87ce642235
3 files changed
+64
-50
No files matched your search
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.arboriculture.ArboricultureCapabilities;
|
||||
@@ -17,7 +19,9 @@ import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.CreativeTabForestry;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.ItemTooltipUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
@@ -52,6 +56,11 @@ public class ItemArmorNaturalist extends ItemArmor implements IItemModelRegister
|
||||
public boolean hasColor(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
ItemTooltipUtil.addInformation(stack, playerIn, tooltip, advanced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Set;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -29,65 +30,69 @@ public class MultiblockEventHandlerClient {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGameOverlay(RenderGameOverlayEvent.Post event){
|
||||
if(event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null){
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
RayTraceResult posHit = minecraft.objectMouseOver;
|
||||
FontRenderer font = minecraft.fontRendererObj;
|
||||
ScaledResolution resolution = event.getResolution();
|
||||
|
||||
if(posHit != null && posHit.getBlockPos() != null){
|
||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
IMultiblockController controller = component.getMultiblockLogic().getController();
|
||||
String lastValidationError = controller.getLastValidationError();
|
||||
if(lastValidationError != null){
|
||||
lastValidationError = TextFormatting.DARK_RED.toString() + TextFormatting.ITALIC.toString() + lastValidationError;
|
||||
minecraft.fontRendererObj.drawSplitString(lastValidationError, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, 128, 16777215);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(GeneticsUtil.hasNaturalistEye(Minecraft.getMinecraft().player)){
|
||||
if(event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null){
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
RayTraceResult posHit = minecraft.objectMouseOver;
|
||||
FontRenderer font = minecraft.fontRendererObj;
|
||||
ScaledResolution resolution = event.getResolution();
|
||||
|
||||
if(posHit != null && posHit.getBlockPos() != null){
|
||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
IMultiblockController controller = component.getMultiblockLogic().getController();
|
||||
String lastValidationError = controller.getLastValidationError();
|
||||
if(lastValidationError != null){
|
||||
lastValidationError = TextFormatting.DARK_RED.toString() + TextFormatting.ITALIC.toString() + lastValidationError;
|
||||
minecraft.fontRendererObj.drawSplitString(lastValidationError, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, 128, 16777215);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRenderLast(RenderWorldLastEvent event){
|
||||
try{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
Set<IMultiblockControllerInternal> controllers = MultiblockRegistry.getControllersFromWorld(world);
|
||||
if(!controllers.isEmpty()){
|
||||
float partialTicks = event.getPartialTicks();
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.depthMask(false);
|
||||
for(IMultiblockController controller : controllers){
|
||||
if(controller != null){
|
||||
BlockPos lastErrorPosition = controller.getLastValidationErrorPosition();
|
||||
if(lastErrorPosition != null){
|
||||
if(world.isBlockLoaded(lastErrorPosition) && player.getDistanceSq(lastErrorPosition) < 64F){
|
||||
AxisAlignedBB box = Block.FULL_BLOCK_AABB.offset(lastErrorPosition.getX() - playerX, lastErrorPosition.getY() - playerY, lastErrorPosition.getZ() - playerZ);
|
||||
RenderGlobal.drawSelectionBoundingBox(box, 1.0F, 0.0F, 0.0F, 0.25F);
|
||||
RenderGlobal.renderFilledBox(box, 1.0F, 0.0F, 0.0F, 0.125F);
|
||||
if(GeneticsUtil.hasNaturalistEye(Minecraft.getMinecraft().player)){
|
||||
try{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
Set<IMultiblockControllerInternal> controllers = MultiblockRegistry.getControllersFromWorld(world);
|
||||
if(!controllers.isEmpty()){
|
||||
float partialTicks = event.getPartialTicks();
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.depthMask(false);
|
||||
for(IMultiblockController controller : controllers){
|
||||
if(controller != null){
|
||||
BlockPos lastErrorPosition = controller.getLastValidationErrorPosition();
|
||||
if(lastErrorPosition != null){
|
||||
if(world.isBlockLoaded(lastErrorPosition) && player.getDistanceSq(lastErrorPosition) < 64F){
|
||||
AxisAlignedBB box = Block.FULL_BLOCK_AABB.offset(lastErrorPosition.getX() - playerX, lastErrorPosition.getY() - playerY, lastErrorPosition.getZ() - playerZ);
|
||||
RenderGlobal.drawSelectionBoundingBox(box, 1.0F, 0.0F, 0.0F, 0.25F);
|
||||
RenderGlobal.renderFilledBox(box, 1.0F, 0.0F, 0.0F, 0.125F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}catch(Exception e){
|
||||
Log.error("Failed to render the position of a multiblock exeption.", e);
|
||||
}
|
||||
}catch(Exception e){
|
||||
Log.error("Failed to render the position of a multiblock exeption.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user