This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the world attempts to spawn monsters every tick | |
the world attempts to spawn animals every 400 ticks | |
entities classified as MISC are not spawned in world-chunk ticks | |
int mobCap = nominal cap * tracked chunks / 289D // 289 == 17^2 | |
nominal cap is 70 for monsters, 10 for animals | |
tracked chunks is the number of chunks tracked by any player (the range appears to be 8) | |
I'm not sure if this is a square or a circle, but if it's a square, then we have 289 chunks tracked per player (minus overlaps) | |
if (total Explicitly Persistant Loaded Mobs < mobCap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mod(YourMod.MODID) // tells forge to construct this during modloading | |
public class YourMod | |
{ | |
public static final String MODID = "yourmod"; // use this same string everywhere you need a modid | |
// Deferred Registers are forge's latest abstraction layer over the registries | |
// you give them suppliers and they create and register your things when the registry event happens | |
// don't forget to subscribe them to the mod bus in your mod constructor! this is important for making them work | |
// in 1.14 or old forge builds of 1.15 use `new DeferredRegister` instead of .create | |
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, YourMod.MODID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FluidTest | |
{ | |
public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(ForgeRegistries.FLUIDS, "modid"); | |
public static final Pair<RegistryObject<ForgeFlowingFluid.Source>, RegistryObject<ForgeFlowingFluid.Flowing>> TEST_FLUIDS = | |
registerFluid("test_fluid", "flowing_test_fluid", | |
ForgeFlowingFluid.Source::new, | |
ForgeFlowingFluid.Flowing::new, | |
FluidAttributes.builder(new ResourceLocation("modid:block/test_fluid_still"), new ResourceLocation("modid:block/test_fluid_flowing"))); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// thanks to gigaherz for pointing me in the right directions on the buildscript | |
// The shadow gradle plugin assists with repackaging a 3rd-party library jar within your own jar | |
// In addition to ensuring that your end-users have the library available when they use your own thing, | |
// it also helps avoid collisions with other things that are also using the same library. | |
// As always, make sure the license of the library allows redistribution and is compatible with | |
// your own thing's license before redistributing it in this manner | |
buildscript { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The MIT License (MIT) | |
Copyright (c) 2020 Joseph Bettendorff a.k.a. "Commoble" | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
idletime has these interactions: | |
is reset to 0 when: | |
when attacked | |
in the despawn check, when: | |
when the despawn fails due to persistance flag set or preventDespawn returning true | |
when the forge event is denied | |
when the nearest player is closer than the random despawn distance | |
when piglin or raider uses a ranged attack | |
when raider starts targeting a home |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
water slowdown mechanics | |
assume an entity is in water | |
let moveSpeed = movement speed attribute | |
defaults to 0.7 for players? | |
let swimSpeed = swim speed modifier attribute | |
defaults to 1.0 | |
let depthStriderEnchantment be 0F, 1F, 2F, or 3F (depends on enchantment tier, hard capped at 3) if on ground, or half that if treading water | |
let depthStriderFactor = depthStriderEnchantment / 3F (results in a number in the range [0,1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RIGHT CLICK BLOCK LOGIC FLOW -- SERVER THREAD (after interaction packet is received by server) | |
fire RightClickBlock event | |
if event is canceled, return the cancellation's action result type | |
if gametype is SPECTATOR, attempt to open the ContainerBlock container of the clicked block | |
return SUCCESS if block had a container, PASS otherwise | |
if event.getUseItem() is NOT DENIED, call ItemStack::onItemUseFirst (which usually delegates to Item::onItemUseFirst) | |
if the result of this is not PASS, return that result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package commoble.hyperbox; | |
import java.lang.reflect.Field; | |
import java.util.Map; | |
import java.util.concurrent.Executor; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
import com.google.common.collect.ImmutableList; | |
import com.mojang.serialization.Lifecycle; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package commoble.gists; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockState; | |
import net.minecraft.entity.LivingEntity; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.Direction; | |
import net.minecraft.util.math.BlockPos; | |
import net.minecraft.world.IWorld; | |
import net.minecraft.world.IWorldReader; |