Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/20 in all areas

  1. The client player is always Minecraft#player. That gives you the container. Write the length of the list as an int. Then loop through the list and write each entry in turn. When reading, read the length, then use a loop to read that many entries. To write an object, write each of its fields in turn.
    1 point
  2. You can learn about custom packets in the documentation. As for your capability data: Assuming it is attached to an arbitrary entity you need to send it as follows: PlayerEvent.StartTracking tells you when a client starts "seeing" (or "knowing about") an entity: they are now in tracking range and you need to send them the entity's data. When the data changes you can use PacketDistributor.TRACKING_ENTITY to send the updated data to all players "in range". Additional considerations need to be made if your data is attached to players: In PlayerLoggedInEvent, PlayerRespawnEvent and PlayerChangedDimensionEvent send the player their own data. When the data changes use PacketDistributor.TRACKING_ENTITY_AND_SELF instead.
    1 point
  3. A github repo would be nice. Also what do you mean not working. Is it crashing? if so provide the log. Is it not generating?
    1 point
  4. oh right i was on 1.14. Only thing I can offer you right now is your method names 1st one is withConfiguration 2nd one is configure
    1 point
  5. Ah yes it is outdated, and do tell people when you are copy pasting documentation. And yes data packs allow you to completely override vanilla loot table. Here is the info on the wiki: https://minecraft.gamepedia.com/Data_pack In a dev environment you place your json in resources/data/minecraft/loot_tables
    1 point
  6. Seems outdated to me (could be wrong), try doing this: https://github.com/SilentChaos512/ScalingHealth/blob/1.14/src/main/java/net/silentchaos512/scalinghealth/world/SHWorldFeatures.java#L22 You need to use deferredWorkQueue for ore gen as in https://github.com/SilentChaos512/ScalingHealth/blob/1.14/src/main/java/net/silentchaos512/scalinghealth/SideProxy.java#L47
    1 point
  7. Hi yes a lot has changed. In particular, the code no longer uses the OpenGL transformation matrices, it keeps track of its own in a MatrixStack. So you need to supply the MatrixStack to the rendering method. Check out this link https://gist.github.com/williewillus/30d7e3f775fe93c503bddf054ef3f93e And this example code (from a Tile Entity Renderer, but you should be able to adapt it.) https://github.com/TheGreyGhost/MinecraftByExample/tree/master - see mbe21 class RenderLines or class DebugBlockVoxelShapeHighlighter package minecraftbyexample.mbe21_tileentityrenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import minecraftbyexample.usefultools.RenderTypeHelper; import net.minecraft.client.renderer.*; import net.minecraft.util.math.Vec3d; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.awt.*; /** * User: The Grey Ghost * Date: 12/01/2015 * This class shows examples of rendering using lines. * The lines have position and colour information only (RenderType.getLines()). No lightmap information, which means that * they will always be the same brightness regardless of day/night or nearby torches. */ public class RenderLines { public static void renderWireframe(TileEntityMBE21 tileEntityMBE21, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderBuffers, int combinedLight, int combinedOverlay) { // draw the artifact using lines // (Draws an inverted tetrahedron wireframe above the rendered base block (hopper block model)) // When the TER::render method is called, the origin [0,0,0] is at the current [x,y,z] of the block being rendered. // The tetrahedron-drawing method draws the tetrahedron in a cube region from [0,0,0] to [1,1,1] but we want it // to be in the block one above this, i.e. from [0,1,0] to [1,2,1], // so we need to translate up by one block, i.e. by [0,1,0] final Vec3d TRANSLATION_OFFSET = new Vec3d(0, 1, 0); matrixStack.push(); // push the current transformation matrix + normals matrix matrixStack.translate(TRANSLATION_OFFSET.x,TRANSLATION_OFFSET.y,TRANSLATION_OFFSET.z); // translate Color artifactColour = tileEntityMBE21.getArtifactColour(); drawTetrahedronWireframe(matrixStack, renderBuffers, artifactColour); matrixStack.pop(); // restore the original transformation matrix + normals matrix } /** * Draw an upside-down wireframe tetrahedron with its tip at [0.5,0,0.5] * and 1x1 square "base" at y = 1 (x= 0 to 1, z = 0 to 1) * @param matrixStack transformation matrix and normal matrix * @param renderBuffers the renderbuffers we'll be drawing to */ private static void drawTetrahedronWireframe(MatrixStack matrixStack, IRenderTypeBuffer renderBuffers, Color color) { final Vec3d [] BASE_VERTICES = { new Vec3d(0, 1, 0), new Vec3d(1, 1, 0), new Vec3d(1, 1, 1), new Vec3d(0, 1, 1), }; final Vec3d APEX_VERTEX = new Vec3d(0.5, 0, 0.5); IVertexBuilder vertexBuilderLines = renderBuffers.getBuffer(RenderTypeHelper.MBE_LINE_DEPTH_WRITING_ON); // Note that, although RenderType.getLines() might appear to be suitable, it leads to weird rendering if used in // tile entity rendering, because it doesn't write to the depth buffer. In other words, any object in the scene // which is drawn after the lines, will render over the top of the line (erase it) even if the object is behind // the lines. This means that RenderType.getLines() is only suitable for lines which are the last thing drawn in // the scene (such as DrawBlockHighlightEvent) // The solution I used here is a custom RenderType for lines which does write to the depth buffer. Matrix4f matrixPos = matrixStack.getLast().getMatrix(); //retrieves the current transformation matrix // draw the base for (int i = 1; i < BASE_VERTICES.length; ++i) { drawLine(matrixPos, vertexBuilderLines, color, BASE_VERTICES[i-1], BASE_VERTICES[i]); } drawLine(matrixPos, vertexBuilderLines, color, BASE_VERTICES[BASE_VERTICES.length - 1], BASE_VERTICES[0]); // draw the sides (from the corners of the base to the apex) for (Vec3d baseVertex : BASE_VERTICES) { drawLine(matrixPos, vertexBuilderLines, color, APEX_VERTEX, baseVertex); } } /** * Draw a coloured line from a starting vertex to an end vertex * @param matrixPos the current transformation matrix * @param renderBuffer the vertex builder used to draw the line * @param startVertex * @param endVertex */ private static void drawLine(Matrix4f matrixPos, IVertexBuilder renderBuffer, Color color, Vec3d startVertex, Vec3d endVertex) { renderBuffer.pos(matrixPos, (float) startVertex.getX(), (float) startVertex.getY(), (float) startVertex.getZ()) .color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()) // there is also a version for floats (0 -> 1) .endVertex(); renderBuffer.pos(matrixPos, (float) endVertex.getX(), (float) endVertex.getY(), (float) endVertex.getZ()) .color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()) // there is also a version for floats (0 -> 1) .endVertex(); } } or this one, from the HighlightBlock event package minecraftbyexample.usefultools.debugging; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; import minecraftbyexample.usefultools.RenderTypeMBE; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawHighlightEvent; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.awt.*; import java.lang.reflect.Field; import static minecraftbyexample.usefultools.debugging.DebugSettings.getDebugParameter; /** * Created by TGG on 27/06/2019. */ public class DebugBlockVoxelShapeHighlighter { @SubscribeEvent public static void onDrawBlockHighlightEvent(DrawHighlightEvent.HighlightBlock event) { RayTraceResult rayTraceResult = event.getTarget(); if (rayTraceResult.getType() != RayTraceResult.Type.BLOCK) return; World world; try { world = getPrivateWorldFromWorldRenderer(event.getContext()); } catch (IllegalAccessException e) { return; } BlockPos blockpos = ((BlockRayTraceResult) rayTraceResult).getPos(); BlockState blockstate = world.getBlockState(blockpos); if (blockstate.isAir(world, blockpos) || !world.getWorldBorder().contains(blockpos)) return; final Color SHAPE_COLOR = Color.RED; final Color RENDERSHAPE_COLOR = Color.BLUE; final Color COLLISIONSHAPE_COLOR = Color.GREEN; final Color RAYTRACESHAPE_COLOR = Color.MAGENTA; boolean showshape = DebugSettings.getDebugParameter("showshape").isPresent(); boolean showrendershapeshape = DebugSettings.getDebugParameter("showrendershape").isPresent(); boolean showcollisionshape = DebugSettings.getDebugParameter("showcollisionshape").isPresent(); boolean showraytraceshape = DebugSettings.getDebugParameter("showraytraceshape").isPresent(); if (!(showshape || showrendershapeshape || showcollisionshape || showraytraceshape)) return; ActiveRenderInfo activeRenderInfo = event.getInfo(); ISelectionContext iSelectionContext = ISelectionContext.forEntity(activeRenderInfo.getRenderViewEntity()); IRenderTypeBuffer renderTypeBuffers = event.getBuffers(); MatrixStack matrixStack = event.getMatrix(); if (showshape) { VoxelShape shape = blockstate.getShape(world, blockpos, iSelectionContext); drawSelectionBox(event.getContext(), renderTypeBuffers, matrixStack, blockpos, activeRenderInfo, shape, SHAPE_COLOR); } if (showrendershapeshape) { VoxelShape shape = blockstate.getRenderShape(world, blockpos); drawSelectionBox(event.getContext(), renderTypeBuffers, matrixStack, blockpos, activeRenderInfo, shape, RENDERSHAPE_COLOR); } if (showcollisionshape) { VoxelShape shape = blockstate.getCollisionShape(world, blockpos, iSelectionContext); drawSelectionBox(event.getContext(), renderTypeBuffers, matrixStack, blockpos, activeRenderInfo, shape, COLLISIONSHAPE_COLOR); } if (showraytraceshape) { VoxelShape shape = blockstate.getRaytraceShape(world, blockpos); drawSelectionBox(event.getContext(), renderTypeBuffers, matrixStack, blockpos, activeRenderInfo, shape, RAYTRACESHAPE_COLOR); } event.setCanceled(true); } private static World getPrivateWorldFromWorldRenderer(WorldRenderer worldRenderer) throws IllegalAccessException { if (worldField == null) { worldField = ObfuscationReflectionHelper.findField(WorldRenderer.class, "world"); } return (World)worldField.get(worldRenderer); } private static Field worldField; /** * copied from WorldRenderer; starting from the code marked with iprofiler.endStartSection("outline"); * * @param activeRenderInfo */ private static void drawSelectionBox(WorldRenderer worldRenderer, IRenderTypeBuffer renderTypeBuffers, MatrixStack matrixStack, BlockPos blockPos, ActiveRenderInfo activeRenderInfo, VoxelShape shape, Color color) { RenderType renderType = RenderTypeMBE.LINES(); IVertexBuilder vertexBuilder = renderTypeBuffers.getBuffer(renderType); double eyeX = activeRenderInfo.getProjectedView().getX(); double eyeY = activeRenderInfo.getProjectedView().getY(); double eyeZ = activeRenderInfo.getProjectedView().getZ(); final float ALPHA = 0.5f; drawShapeOutline(matrixStack, vertexBuilder, shape, blockPos.getX() - eyeX, blockPos.getY() - eyeY, blockPos.getZ() - eyeZ, color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, ALPHA); } private static void drawShapeOutline(MatrixStack matrixStack, IVertexBuilder vertexBuilder, VoxelShape voxelShape, double originX, double originY, double originZ, float red, float green, float blue, float alpha) { Matrix4f matrix4f = matrixStack.getLast().getMatrix(); voxelShape.forEachEdge((x0, y0, z0, x1, y1, z1) -> { vertexBuilder.pos(matrix4f, (float)(x0 + originX), (float)(y0 + originY), (float)(z0 + originZ)).color(red, green, blue, alpha).endVertex(); vertexBuilder.pos(matrix4f, (float)(x1 + originX), (float)(y1 + originY), (float)(z1 + originZ)).color(red, green, blue, alpha).endVertex(); }); } } Cheers TGG
    1 point
  8. return entity.goalSelector.getRunningGoals().anyMatch(prioritizedGoal -> prioritizedGoal.getGoal().getClass() == TargetGoal);
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.