-
Posts
260 -
Joined
-
Last visited
Posts posted by LogicTechCorp
-
-
18 hours ago, diesieben07 said:
You don't need to write the deserializer manually. If you match your class structure with your JSON structure, Gson can do it for you. Check out the Gson User Guide.
Are the classes set up correctly? And, how would I best go about writing the TradeOffer class?
-
12 hours ago, Draco18s said:
You shouldn't be manually parsing JSON files. You should be using a deserializer.
I think I have all of the groundwork set up. Here are the classes:
Am I doing it correctly? Also, now how do I fill out the Deserializer classes?
-
I am adding an entity with a trading ability to my mod. The trades are defined using Json and I would like some help trying to figure out how to deserialize the file. I have looked through the Minecraft source to see how they do it and have googled, but I still do not understand how to do it. All help is appreciated.
Here is an example of how the Json is structured:
{ "name": "Example Trade List", "professions": [ { "name": "blacksmith", "careers": [ { "name": "toolsmith", "offers": [ { "output": {"id": "minecraft:golden_pickaxe", "meta": 0, "count": {"min": 1, "max": 4}, "tag": { "ench": [{"id": 34, "level": 3}, {"id": 70, "level": 1}], "display": {"name": "Golden Pickaxe", "color": "FFFF55", "lore": ["A Golden Pickaxe", "Forged with magic"]} } }, "inputA": {"id": "minecraft:gold_ingot", "meta": 0, "count": {"min": 3, "max": 3}}, "inputB": {"id": "minecraft:stick", "meta": 0, "count": {"min": 2, "max": 2}}, "level": 0, "stock": {"min": 2, "max": 4} } ] } ] } ] }
-
On 2/11/2017 at 8:51 AM, Choonster said:
I don't think this is currently possible using the vanilla passive spawning system.
When WorldEntitySpawner#findChunksForSpawning tries to spawn an entity, it calls WorldServer#canCreatureTypeSpawnHere and WorldEntitySpawner#canCreatureTypeSpawnAtLocation and only proceeds if they both return true. You can use WorldEvent.PotentialSpawns to change the result of the former, but the latter is hardcoded to check for water if the entity uses EntityLiving.SpawnPlacementType.IN_WATER and call Block#canCreatureSpawn (which calls (Block#isSideSolid with EnumFacing.UP) for any other EntityLiving.SpawnPlacementType.
Lava isn't water or a solid block, so entities won't be spawned in it.
I think Forge would need to add an event in WorldEntitySpawner#canCreatureTypeSpawnAtLocation to allow the result of the method to be changed.
@Choonster Do you have any recommendations on what the event should be? I am going to try and see what I can come up with but would like to know where to start.
-
Can anyone help or point me in the right direction?
-
Hello, I have a few question about biome generation. First off can anyone help me understand how to only allow certain biomes to spawn next to each other. For example, hot by warm, warm by cool, and cool by cold. I know Vanilla does this but I do not understand it. Second, how do sub-biomes work? Thank you, all help is appreciated.
Here is my current biome gen system:
Registry
GenLayers
-
What are the uses for Block::getStateId and Block::getStateById?
-
9 hours ago, Choonster said:
You're using the blocks Field twice and casting the value of the second call to List<Template.EntityInfo> instead of using the entities Field. This will throw a ClassCastException at runtime.
It also looks like you're not actually using the size Field.
I recommend following Java naming conventions by using CONSTANT_CASE for constant fields.
Thanks, I didn't see that. Also, the size Field wasn't needed after all since the class has a getSize method.
-
It seems to be working but I just want to know if I am doing it correctly.
-
1 minute ago, Choonster said:
Use ReflectionHelper.findField or ReflectionHelper.findMethod to get a Field/Method object for the field/method and store it in a private static final field. You'll need to provide both the MCP and SRG names of the field/method.
Use Field#get or Field#set to get or set the value of a field. If it's an instance field, pass the instance as the first argument. If it's a static field, pass null as the first argument instead.
Use Method#invoke to call a method. If it's an instance method, pass the instance as the first argument. If it's a static method, pass null as the first argument instead. Pass the method's arguments as the vararg argument.
Thank you! I will work on it and come back if I have any issues.
-
I have an access transformer that I use for a few different things and I would like to replace it. A while back I had tried using reflection but it did not work correctly. Can I have some help?
Here is the AT:
Use one:
Use two:
-
2 hours ago, jeffryfisher said:
Looks correct to me. What was I supposed to notice?
The structure was saved with the air blocks around it to give it some padding. There were blocks where the structure spawned and were removed when it spawned.
-
I am trying to spawn a structure in the Nether. The structure is supposed to spawn in the air but it does not work correctly.
Here is the code I am using:
public boolean generate(World world, Random rand, BlockPos pos) { rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed()); Mirror[] mirrors = Mirror.values(); Rotation[] rotations = Rotation.values(); Mirror mirror = mirrors[rand.nextInt(mirrors.length)]; Rotation rotation = rotations[rand.nextInt(rotations.length)]; MinecraftServer server = world.getMinecraftServer(); TemplateManager manager = world.getSaveHandler().getStructureTemplateManager(); Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants)); PlacementSettings settings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setRandom(rand); BlockPos structureSize = template.transformedSize(rotation); BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX(), 96, pos.getZ() - structureSize.getZ()); BlockPos spawnPos = getSuitableAirPos(world, template.getZeroPositionWithTransform(newPos, mirror, rotation), structureSize); if(spawnPos != BlockPos.ORIGIN) { template.addBlocksToWorld(world, spawnPos, settings, 3); return true; } return false; } private static BlockPos getSuitableAirPos(World world, BlockPos pos, BlockPos structureSize) { while(pos.getY() > 32) { float sizeX = structureSize.getX(); float sizeZ = structureSize.getZ(); float sizeY = structureSize.getY(); int airBlocks = 0; for(int x = 0; x <= sizeX; x++) { for(int z = 0; z <= sizeZ; z++) { for(int y = 0; y <= sizeY; y++) { BlockPos newPos = pos.add(x, y, z); if(world.getBlockState(newPos) == Blocks.AIR.getDefaultState()) { airBlocks++; } } } } if(airBlocks == sizeX * sizeY * sizeZ) { return pos; } pos = pos.down(); } return BlockPos.ORIGIN; } }
My code is based off of the fossil generation code.
Picture of the issue:
-
I have an entity that plays a sound when it is moving. The entity has a cooldown between when it moves. If the sound plays right before it stops moving, the sound plays throughout the cooldown. I would like for this sound to stop playing when the entity stops moving. How do I do this?
-
Anyone know how to fix this? Also, how do I get them to spin?
-
I have blocks rendering now. There are a few issues: Blocks are rendered with color on them and the tops of blocks and items are transparent.
Current Code:
public class RenderSummoningAltar extends FastTESR<TileEntitySummoningAltar> { @Override public void renderTileEntityFast(TileEntitySummoningAltar altar, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer vertexRenderer) { ItemStack stack = altar.getInventory().getStackInSlot(0); if(!stack.isEmpty()) { World world = altar.getWorld(); float time = (world.getTotalWorldTime() + partialTicks) / 20; IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, null); List<BakedQuad> quads; for(EnumFacing facing : EnumFacing.values()) { quads = model.getQuads(null, facing, 0L); for(BakedQuad quad : quads) { vertexRenderer.addVertexData(quad.getVertexData()); vertexRenderer.putPosition(x, y + 1.5D, z); } } quads = model.getQuads(null, null, 0L); for(BakedQuad quad : quads) { vertexRenderer.addVertexData(quad.getVertexData()); vertexRenderer.putPosition(x, y + 1.5D, z); } } } }
-
6 hours ago, diesieben07 said:
Look at AnimationTESR.
I have made some progress. Items now render but blocks do not. How would I render blocks and scale/rotate the model?
Current code:
public class RenderSummoningAltar extends FastTESR<TileEntitySummoningAltar> { @Override public void renderTileEntityFast(TileEntitySummoningAltar altar, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer vertexRenderer) { ItemStack stack = altar.getInventory().getStackInSlot(0); if(!stack.isEmpty()) { World world = altar.getWorld(); IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, null); List<BakedQuad> quads = model.getQuads(null, null, 0L); for(BakedQuad quad : quads) { vertexRenderer.addVertexData(quad.getVertexData()); vertexRenderer.putPosition(x, y + 1, z); } } } }
-
40 minutes ago, diesieben07 said:
You never mentioned spinning. If you want it to spin, you need a TESR. I suggest you use FastTESR though. And yes, this works with any item.
Since you can't use GL calls in a FastTESR how would I go about rendering the item?
-
28 minutes ago, diesieben07 said:
I looked through the forum and cannot find a thread that discuses how to do that. Just a couple of questions: Would using what Draco suggested allow any item to work with this. Also, will the item be able to spin like a dropped item?
-
2 minutes ago, diesieben07 said:
You should not be using a TESR to do this.
What should I be using?
-
I have the Item rendering but it appears dark. What am I doing wrong?
public class RenderSummoningAltar extends TileEntitySpecialRenderer<TileEntitySummoningAltar> { @Override public void renderTileEntityAt(TileEntitySummoningAltar altar, double x, double y, double z, float partialTicks, int destroyStage) { if(altar == null) { return; } ItemStack stack = altar.getInventory().getStackInSlot(0); if(!stack.isEmpty()) { GlStateManager.pushMatrix(); GlStateManager.translate(x + 0.5F, y + 1.225F, z + 0.5F); GlStateManager.disableLighting(); GlStateManager.rotate((Minecraft.getSystemTime() / 720.0F) * (180.0F / (float)Math.PI), 0.0F, 1.0F, 0.0F); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); } } }
-
Just now, Draco18s said:
And you would be wrong. You can use an IModel implementation to get the Item's model and bake it into your block.
There's a few forum threads on this already.
The Block has a TileEntity which has an inventory and allows it to store a single item. I would like for this Item to render on top of the Block like an item renders on the ground.
-
I would like to render an Item that turns on top of my Block. I was looking around and saw that there a few different ways to achieve this. Which is the best and less resource intensive way to render the item?
-
11 minutes ago, Leomelonseeds said:
Try teleporting the player to the same position on update.
Thanks, that works. Now, how would I stop the player from using items or placing blocks?
[1.11.2] Loop through Json file
in Modder Support
Posted
I have it working now. Do you have any suggestions on how I can improve it?
https://github.com/LogicTechCorp/NetherEx/blob/715c79aec5b060b52800e8fb9f0cc6f027fcc5e4/src/main/java/nex/trade/TradeListManager.java