Jump to content

ChAoS_UnItY

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by ChAoS_UnItY

  1. I'm using `ExtendedList` as my list, but I would like to discard the dirt background which renders in default. I've tried to overrides the render part which contains `Screen#renderDirtBackground()`, but it failed with crash. Any help? Currently stable source code without overrides renderDirtBackground : https://github.com/ChAoSUnItY/EkiLib/blob/1.16.3/src/main/java/com/chaos/eki_lib/gui/screen/StationSelectionScreen.java
  2. But after I removed lots line and get final code result like this : @Override public void render(StationNameplateTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); matrixStackIn.push(); FontRenderer fontRenderer = this.renderDispatcher.getFontRenderer(); IReorderingProcessor irp = new StringTextComponent("This is a test string, if you saw me , that's gud").func_241878_f(); fontRenderer.func_238416_a_(irp, 10, -20, 16777215, false, matrixStackIn.getLast().getMatrix(), bufferIn, false, 0, combinedLightIn); matrixStackIn.pop(); } It still doesn't show up in the world... EDIT: It's just need a scale down. Case closed
  3. My goal is to create a non sign block but renders text, so that is not what I'm looking for. Maybe I need some Matrix translating help since my block model is quite different.
  4. I have taken a look at Sign's TileEntityRenderer, but I still not 100% sure how to properly render it, any help?
  5. The abstractList is always rendering a dirt backgorund, even I overrided the method, then it'll caused a no respond, is there correct way to change it? Here's my code: package com.chaos.ekiLib.screen; import com.chaos.ekiLib.api.EkiLibApi; import com.chaos.ekiLib.station.data.Station; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.list.ExtendedList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ScreenStationSelection extends ScreenBase { private ScreenStationSelection.List list; private final boolean selectMode; public ScreenStationSelection(int dimID, PlayerEntity player, boolean selectMode) { super(new TranslationTextComponent("eki.screen.station_selection"), dimID, player); this.selectMode = selectMode; } protected void init() { this.list = new ScreenStationSelection.List(this.minecraft); this.children.add(this.list); super.init(); } public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { this.list.render(matrixStack, mouseX, mouseY, partialTicks); drawCenteredString(matrixStack, this.font, this.title, this.width / 2, 16, 16777215); this.renderBackground(matrixStack); super.render(matrixStack, mouseX, mouseY, partialTicks); } @OnlyIn(Dist.CLIENT) class List extends ExtendedList<ScreenStationSelection.List.StationEntry> { public List(Minecraft mcIn) { super(mcIn, ScreenStationSelection.this.width, ScreenStationSelection.this.height, 32, ScreenStationSelection.this.height - 65 + 4, 18); for (Station station : EkiLibApi.getStationList(ScreenStationSelection.this.dimID)){ this.addEntry(new StationEntry(station)); } if (this.getSelected() != null) { this.centerScrollOn(this.getSelected()); } } protected int getScrollbarPosition() { return super.getScrollbarPosition() + 20; } public int getRowWidth() { return super.getRowWidth() + 50; } protected void renderBackground(MatrixStack matrixStack) { ScreenStationSelection.this.renderBackground(matrixStack); } protected boolean isFocused() { return ScreenStationSelection.this.getListener() == this; } @OnlyIn(Dist.CLIENT) public class StationEntry extends ExtendedList.AbstractListEntry<ScreenStationSelection.List.StationEntry> { private final Station station; public StationEntry(Station station) { this.station = station; } public void render(MatrixStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) { String s = this.station.getName() + " - " + this.station.getFormmatedPosition(); ScreenStationSelection.this.font.func_238406_a_(p_230432_1_, s, (float) (ScreenStationSelection.List.this.width / 2 - ScreenStationSelection.this.font.getStringWidth(s) / 2), (float) (p_230432_3_ + 1), 16777215, true); } public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 0) { this.select(); return true; } else { return false; } } private void select() { ScreenStationSelection.List.this.setSelected(this); } } } }
  6. um, to be clear, I want to draw it with font renderer but it only accepts String, that's the first problem, and second, after got all tooltips on the tool player is holding, they're formatted but ITextComponent, therefore, I might need that to achieve what I want in a simple way. Note: How about copy 1.15.2's method code and try to modify to be compatible to 1.16.2's?
  7. How about getFormattedText()?
  8. Since I need to style my text with default-set style, like the tools' tooltip, it has green texts on it.
  9. I'm porting my 1.15.2 mod to 1.16.1 . In 1.15.2 , ITextComponent#getFormattedText() is the way to achieve my goal, but in 1.16.1, since most of forge is still mapping, I did not find a similar method to achieve my goal. Any idea? Also, is ITextComponent#applyTextStyle() in 1.16.1 calls ITextComponent#func_240699_a_()?
  10. After a compiled run, it says no such field, how can I get the field I want? (note: the field calls "debugFPS")
  11. Ok, my exception part is fixed, but after a further discover, I don't know what the "E" in the code below should be....... @Nullable public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String fieldName) { try { return (T) findField(classToAccess, fieldName).get(instance); } catch (UnableToFindFieldException e) { LOGGER.error(REFLECTION,"Unable to locate field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e); throw e; } catch (IllegalAccessException e) { LOGGER.error(REFLECTION,"Unable to access field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e); throw new UnableToAccessFieldException(e); } } It says "The type of the classToAccess."
  12. I've tried to use Reflection to get the "debugFPS" field like below : int fps = 0; try { Field field = mc.getClass().getDeclaredField("debugFPS"); field.setAccessible(true); fps = (int) field.get(mc); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } but it only works on dev one, not working on compiled one. Anything I did not noticed?
  13. Ok , I think I have figured out the final answer, thanks for replies.
  14. My plan is to get server side's world and get tileentity data , I think two methods I mentioned earlier is the remote world so it doesn't get the real data.
  15. I'm trying to get vanilla server side's identity data from server side world.
  16. But is it possible to send a packets from client side only mod and receive from vanilla server ?
  17. I've tried Minecraft.getInstance().getConnection().getWorld() and Minecraft.getInstance().world , but they both print isRemote() as true. Any other possible way to access? (Like packets or something else)
  18. public void onRender(RenderGameOverlayEvent event) { LambdaHelper lambdaHelper = (x) -> { return 1 + x * 9; }; PlayerEntity player = mc.player; UtilMinecraftDate date = new UtilMinecraftDate(mc.world); if (event.getType() == ElementType.TEXT) { GL11.glPushMatrix(); //Some codes not relative to my topic // ============================BENEATH PART============================// int h = event.getWindow().getHeight(); lambdaHelper = (x) -> { return h - 1 - x * 9; }; World world = mc.world; RayTracingHelper.INSTANCE.fire(); //<----From HWYLA RayTraceResult mop = RayTracingHelper.INSTANCE.getTarget(); //<----From HWYLA if (mop.getType() == Type.BLOCK) { // ============================TILEENTITY INFO============================// BlockPos pos2 = new BlockPos(mop.getHitVec()); System.out.println(pos2); System.out.println(player.getForward().getX()); BlockState state = world.getBlockState(pos2); Block block = state.getBlock(); System.out.println(block); if (block.hasTileEntity(state)) { TileEntity te = world.getTileEntity(pos2); // mc.getItemRenderer().renderItemIntoGUI(stack, x, y); if (block == Blocks.BEE_NEST || block == Blocks.BEEHIVE) { simpleStringDraw("bee" + ((BeehiveTileEntity) te).getHoneyLevel(state), 2, 90, 16777215); mc.getItemRenderer().renderItemIntoGUI(Blocks.BEE_NEST.asItem().getDefaultInstance(), 1, 90); } } } GL11.glPopMatrix(); } } Main code where RayTracingResult get datas public class RayTracingHelper { public static final RayTracingHelper INSTANCE = new RayTracingHelper(); private RayTraceResult target = null; private Minecraft mc = Minecraft.getInstance(); private RayTracingHelper() { } public void fire() { if (mc.objectMouseOver != null) { this.target = mc.objectMouseOver; return; } Entity viewpoint = mc.player; if (viewpoint == null) return; this.target = this.rayTrace(viewpoint, mc.playerController.getBlockReachDistance(), 1); } public RayTraceResult getTarget() { return this.target; } public RayTraceResult rayTrace(Entity entity, double playerReach, float partialTicks) { Vec3d eyePosition = entity.getEyePosition(partialTicks); Vec3d lookVector = entity.getLook(partialTicks); Vec3d traceEnd = eyePosition.add(lookVector.x * playerReach, lookVector.y * playerReach, lookVector.z * playerReach); RayTraceContext context = new RayTraceContext(traceEnd, eyePosition, BlockMode.OUTLINE, FluidMode.NONE, entity); return mc.world.rayTraceBlocks(context); } } Codes from HWYLA (just some important methods copied) Any idea what is wrong in these codes? EDIT: Also, all blocks' west, north, and up side is not doing well with ray tracing, they all show air block.
  19. I am making a WAILA-like mod, I'm not familiar with RayTracingResult mechanics, so I decided to just copy some code from HWYLA source code. Here's the problem, it works half fine, but once my crosshair is on specific side of block , it shows that what I'm pointing is an air block that is next to the block it should be. Any idea?
  20. When I clicked my TileEntity (TicketVendor), it should open Gui, and it should be closed on pressing escape or E, but my problem is after clicking, it shows for a moment and disappear without any messages. Github : https://github.com/KyleLin921021/EkiMod/tree/master/src/main/java/chaos/mod Note : Currently the Gui stuff is in building phase, so some stuff is saved for future usage.
  21. Is getCollisionShape a good way to do that? (also , can this method return a array with more than one VoxelShape stuff?)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.