Jump to content

Improvements and suggestions for a Block Detector mod


ShaRose

Recommended Posts

So, after starting to play I very quickly got distracted with wanting some way to find any nearby ore: And then proceeded to spent far longer than I've spent playing the game making it.

I've got it mostly working, but there are a few things I want to test and want someone to try and look over since I'm sure there are lots of things I'm doing that are backwards and just making things harder on myself.

The initial idea was just for detecting ores, but since we have the Variant system I thought why not expand that so anyone can add a variant type: And then doing the same for different ranges.

I quickly realized that it can only have one 'variant' at a time, so I had to make my own edits to the variant system to support it, but the end result is nice for expanding things: Here's the entire item json.

{
	code: "detector",
	class: "detector",
	texture: { base: "item/detector" },
	variantgroups: [
		{ code: "range", states: ["short", "standard", "long"] },
		{ code: "type", states: ["ore", "treasure", "flowers", "food"] },
	],
	creativeinventory: { "general": ["*"], "items": ["*"] },
	attributes: {
		short: {
			range: 6,
			angle: 100,
			sensitivity: 1,
			tickrate: 0.4
		},
		standard: {
			range: 12,
			angle: 70,
			sensitivity: 1,
			tickrate: 1
		},
		long: {
			range: 30,
			angle: 45,
			sensitivity: 1,
			tickrate: 1.5
		},
		ore: {
			trueattrs: [],
			codelist: [ "ore-*", "looseores-*" ]
		},
		treasure: {
			trueattrs: [],
			codelist: [ "loosegears-*", "metal-scraps", "metal-scraps", "metalpartpile-*", "platepile-*", "ingotpile-*", "statictranslocator-*" ]
		},
		flowers: {
			trueattrs: ["beeFeed", "butterflyFeed"],
			codelist: [ "flower-*" ]
		},
		food: {
			trueattrs: [],
			codelist: [ "smallberrybush-*", "bigberrybush-*", "fruittree-*", "mushroom-*", "barrelcactus-*", "crop-*" ]
		},
		wobbleamp: 40,
		wobblerate: 3
	},
	fpHandTransform: {
		translation: { x: -0.6, y: -0.8, z: 0 },
		rotation: { x: 143, y: 197.6992, z: -44 },
		origin: { x: 0.2, y: 1, z: 0.5 }
	}
}

To add, say, a flint detector, all you would need to do is add a flint attribute, add it as a variant, and add a language entry so it searches for "looseflints-*" for the codelist. Very easy, very quick.

The actual code isn't quite so nice, and while I'm pretty SURE it should work online, I haven't tested.

I've also got a LOT of work on making it display things properly: Right now, it pretty much has a (non resizing) box in the top left that includes the milliseconds spent processing as a debug and the list of blocks. Example for the 'long range' scanner hitting a nice big Quartz deposit, along with some silver and gold:

unknown.png

Never mind the fact there is no way to craft any of these, and that the animation is literally just the very basic pixelart waving back and forth based on how fast the detector 'ticks' (With no change to the sprite based on what it detects / what the range type is).

Or that I still include debug code, or that I know (for a fact) I can optimize the initial 'get list of blocks to check' code heavily, but haven't.

The problem is at this point this is 'good enough' for my usage, and I'm kind of getting sick of poking at it, so I'm looking for people to just tell me what I need to do / change / add, and preferably how to do it roughly: It took me a few days to realize that byEntity.ServerPos.GetViewVector() exists for example which wasted a LOT of time, so a pointer on where to look for examples would be nice.

I don't really think it's good enough to 'release' even if I removed all the debug cruft, but if anyone wants to just use it, I've got the source package attached: Look over at your own sanity, as you see me 'come up' with oddball solutions to problems I shouldn't have run in to because I didn't know you could do (something really simple and common that I somehow missed).

Tested it out on the beta as well (Was running on stable) and somehow never came across that I messed up a zip file. So reuploaded.

 

vsdetector 0.9 repack.zip

Edited by ShaRose
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.