Skip to content

Instantly share code, notes, and snippets.

@Draco18s
Draco18s / IEventType.cs
Created May 30, 2020 02:20
A delegate based C# event messaging system.
namespace draco18s.EventSystem {
/// <summary>
/// Base interface for all event types
/// </summary>
public interface IEventType {
/// <summary>
/// TODO - This method signature will change depending on implementation details
/// </summary>
/// <returns></returns>
object Serialize(); //whatever this means for your project
///Spend fuel and accelerate in direction
private void Thrust(Vector3 dir, float draw, float seconds) {
o.Normalize();
float change = GetVelocityFromBurn(this, draw * seconds);
DrawFuelFromTanks();
velocity += change*dir;
}
///Determine the number of seconds in order to reach velocity (assuming no friction)
public static float CalculateBurnTimeToReachVelocity(Spaceship ship, float vel, float draw) {
//Copy and paste bot functions here:
function justFarm(me, others){
return farm();
}
function undyableBot(me, others, storage){
if(me.hp < 100 - (me.levels.heal + 5)*2){
return heal()
@Draco18s
Draco18s / GuiMultiLineTextField
Last active February 5, 2023 20:43
A multiline text entry box for Minecraft's GUI system
package com.draco18s.runic.client.gui;
import java.util.ArrayList;
import org.lwjgl.input.Mouse;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraft.client.Minecraft;
Shader "Unlit/UI_ShaderFixes" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color("Color Multiplier", Color) = (1, 1, 1, 1) // color
_Cutoff ("Cutoff", Range(0,1)) = 0.5
[HideInInspector]_StencilComp("Stencil Comparison", Float) = 8
[HideInInspector]_Stencil("Stencil ID", Float) = 1
[HideInInspector]_StencilOp("Stencil Operation", Float) = 0
[HideInInspector]_StencilWriteMask("Stencil Write Mask", Float) = 255
@Draco18s
Draco18s / mc log
Created June 11, 2018 00:44
some crash log
2018-06-10 14:10:06,452 main WARN Disabling terminal, you're running in an unsupported environment.
[14:10:06] [main/INFO] [GradleStart]: Extra: []
[14:10:06] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/Gamer/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[14:10:06] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[14:10:06] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[14:10:06] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[14:10:06] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[14:10:06] [main/INFO] [FML]: Forge Mod Loader version 14.23.4.2705 for Min
public static void setupDir(Configuration config) {
RECIPE_DIR = null;
if (RECIPE_DIR == null) {
RECIPE_DIR = config.getConfigFile().toPath().resolve("../recipes/").toFile();
ADVANCE_DIR = config.getConfigFile().toPath().resolve("../advancements/").toFile();
String dir = config.getConfigFile().toPath().resolve("../recipes/").toString();
String pattern = "config\\\\(.*)\\.cfg\\\\\\.\\.\\\\recipes";
Pattern p = Pattern.compile(pattern);
Matcher matcher = p.matcher(dir);
public static class GameObjectExtensions {
public static bool IsVisibleFrom(this GameObject obj, Camera camera) {
Bounds b = obj.GetComponent<Collider>().bounds;
b.Expand(0.5f);
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
return GeometryUtility.TestPlanesAABB(planes, b);
}
public static bool IsVisibleFrom(this GameObject obj, Plane[] planes) {
Bounds b = obj.GetComponent<Collider>().bounds;
@Draco18s
Draco18s / BlockUnstableStone
Created December 17, 2014 18:28
Gravity effected and distance-support Stone Replacement
package com.draco18s.hazards.block;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.draco18s.hardlib.HashUtils;
import com.draco18s.hazards.StoneRegistry;
import com.draco18s.hazards.block.helper.UnstableStoneHelper;
<!--************************ CustomOreGen Minecraft Ores Module ****************
:set ai et ts=4 sw=4
*
* This file contains Presets, Options, and Distributions for the 7
* vanilla minecraft ores:
* Coal, Iron, Gold, Redstone, Diamond, Lapis Lazuli, and Emerald.
*
******************************************************************************-->
<ConfigSection>