Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Jul 10, 2024
1 parent 6aa5bdc commit 0240cbc
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/id/paradiselost/api/BlockLikeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public boolean handleFallDamage(float distance, float multiplier, DamageSource d
}

boolean flag = this.blockState.isIn(BlockTags.ANVIL);
DamageSource damageSource2 = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
DamageSource damageSource2 = flag ? this.world.getDamageSources().fallingAnvil(this) : this.world.getDamageSources().fallingBlock(this);
float f = Math.min(MathHelper.floor((float)i * this.fallHurtAmount), this.fallHurtMax);

this.world.getOtherEntities(this, getBoundingBox().union(getBoundingBox().offset(0, 1 + -2 * this.getVelocity().getY(), 0))).forEach(entity -> entity.damage(damageSource2, f));
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/net/id/paradiselost/blocks/BlockRegistration.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.sapling.SaplingGenerator;
import net.minecraft.item.ItemConvertible;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Iterator;
import java.util.function.Consumer;

import static net.id.paradiselost.ParadiseLost.MOD_ID;
import static net.id.paradiselost.ParadiseLost.locate;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.cutoutMippedRenderLayer;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.cutoutRenderLayer;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.flammableLeaves;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.flammableLog;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.flammablePlanks;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.stripsTo;
import static net.id.paradiselost.blocks.ParadiseLostBlockActions.*;

public class BlockRegistration {

@SafeVarargs
public static <V extends Block> V add(String id, V block, RegistryQueue.Action<? super V>... additionalActions) {
return ParadiseLostRegistryQueues.BLOCK.add(locate(id), block, additionalActions);
public static <V extends Block> V add(String id, V block, Consumer<Block>... additionalActions) {
return Registry.register(Registries.BLOCK, locate(id), block);
}

static class ParadiseLostFarmlandBlock extends FarmlandBlock {
Expand Down Expand Up @@ -214,7 +213,7 @@ sapling, add(flowerPotId, new FlowerPotBlock(sapling, flowerPotSettings)),
planks, add(plankStairsId, new ParadiseLostStairsBlock(planks.getDefaultState(), plankSettings), flammablePlanks), add(plankSlabId, new SlabBlock(plankSettings), flammablePlanks),
add(fenceId, new FenceBlock(plankSettings), flammablePlanks), add(fenceGateId, new FenceGateBlock(plankSettings), flammablePlanks),
add(doorId, new DoorBlock(doorSettings), cutoutMippedRenderLayer), add(trapdoorId, new TrapdoorBlock(trapdoorSettings), cutoutMippedRenderLayer),
add(buttonId, new WoodenButtonBlock(buttonSettings)), add(pressurePlateId, new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, pressurePlateSettings))
add(buttonId, new ButtonBlock(buttonSettings)), add(pressurePlateId, new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, pressurePlateSettings))
);
}

Expand All @@ -225,7 +224,7 @@ public record WoodBlockSet(
Block plank, StairsBlock plankStairs, SlabBlock plankSlab,
FenceBlock fence, FenceGateBlock fenceGate,
DoorBlock door, TrapdoorBlock trapdoor,
WoodenButtonBlock button, PressurePlateBlock pressurePlate
ButtonBlock button, PressurePlateBlock pressurePlate
) implements Iterable<Block> {
public @NotNull Iterator<Block> iterator() {
return Arrays.stream(new Block[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,38 @@
import net.minecraft.block.Block;
import net.minecraft.item.HoeItem;

import java.util.function.Consumer;

class ParadiseLostBlockActions {
protected static final AbstractBlock.ContextPredicate never = (state, view, pos) -> false;
protected static final AbstractBlock.ContextPredicate always = (state, view, pos) -> true;

protected static Action<Block> flammable(int spread, int burn) {
return (id, block) -> FlammableBlockRegistry.getDefaultInstance().add(block, spread, burn);
protected static Consumer<Block> flammable(int spread, int burn) {
return (block) -> FlammableBlockRegistry.getDefaultInstance().add(block, spread, burn);
}

protected static final Action<Block> flammableLog = flammable(5, 5);
protected static final Action<Block> flammablePlanks = flammable(20, 5);
protected static final Action<Block> flammableLeaves = flammable(60, 30);
protected static final Action<Block> flammablePlant = flammable(60, 100);
protected static final Consumer<Block> flammableLog = flammable(5, 5);
protected static final Consumer<Block> flammablePlanks = flammable(20, 5);
protected static final Consumer<Block> flammableLeaves = flammable(60, 30);
protected static final Consumer<Block> flammablePlant = flammable(60, 100);

protected static final Action<Block> translucentRenderLayer = onClient((id, block) -> RenderUtils.transparentRenderLayer(block));
protected static final Action<Block> cutoutRenderLayer = onClient((id, block) -> RenderUtils.cutoutRenderLayer(block));
protected static final Action<Block> cutoutMippedRenderLayer = onClient((id, block) -> RenderUtils.cutoutMippedRenderLayer(block));
protected static final Consumer<Block> translucentRenderLayer = (block) -> RenderUtils.transparentRenderLayer(block);
protected static final Consumer<Block> cutoutRenderLayer = (block) -> RenderUtils.cutoutRenderLayer(block);
protected static final Consumer<Block> cutoutMippedRenderLayer = (block) -> RenderUtils.cutoutMippedRenderLayer(block); //TODO

protected static Action<Block> stripsTo(Block stripped) {
return (id, original) -> StrippableBlockRegistry.register(original, stripped);
protected static Consumer<Block> stripsTo(Block stripped) {
return (original) -> StrippableBlockRegistry.register(original, stripped);
}

protected static Action<Block> tillable() {
return (id, block) -> TillableBlockRegistry.register(block, HoeItem::canTillFarmland, ParadiseLostBlocks.FARMLAND.getDefaultState());
protected static Consumer<Block> tillable() {
return (block) -> TillableBlockRegistry.register(block, HoeItem::canTillFarmland, ParadiseLostBlocks.FARMLAND.getDefaultState());
}

protected static Action<Block> coarseTillable() {
return (id, block) -> TillableBlockRegistry.register(block, HoeItem::canTillFarmland, ParadiseLostBlocks.DIRT.getDefaultState());
protected static Consumer<Block> coarseTillable() {
return (block) -> TillableBlockRegistry.register(block, HoeItem::canTillFarmland, ParadiseLostBlocks.DIRT.getDefaultState());
}

protected static Action<Block> flattenable(Block turnInto) {
return (id, block) -> FlattenableBlockRegistry.register(block, turnInto.getDefaultState());
protected static Consumer<Block> flattenable(Block turnInto) {
return (block) -> FlattenableBlockRegistry.register(block, turnInto.getDefaultState());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import java.util.List;
Expand Down Expand Up @@ -65,7 +65,6 @@ private static Settings cloud() {

public static final ParadiseLostCloudBlock COLD_CLOUD = add("cold_cloud", new ParadiseLostCloudBlock(cloud().mapColor(MapColor.WHITE)), translucentRenderLayer);
public static final BlueParadiseLostCloudBlock BLUE_CLOUD = add("blue_cloud", new BlueParadiseLostCloudBlock(cloud().mapColor(MapColor.LIGHT_BLUE)), translucentRenderLayer);
public static final PinkParadiseLostCloudBlock PINK_CLOUD = add("pink_cloud", new PinkParadiseLostCloudBlock(cloud().mapColor(MapColor.PINK)), translucentRenderLayer);
public static final GoldenParadiseLostCloudBlock GOLDEN_CLOUD = add("golden_cloud", new GoldenParadiseLostCloudBlock(cloud().mapColor(MapColor.GOLD)), translucentRenderLayer);
// Fluids
public static final FluidBlock DENSE_CLOUD = add("dense_cloud", new FluidBlock(ParadiseLostFluids.DENSE_CLOUD, of(Material.WATER).noCollision().strength(100f).dropsNothing()));
Expand Down Expand Up @@ -264,7 +263,7 @@ private static Settings flower() {
public static final Block OLVITE_BLOCK = add("olvite_block", new Block(of(Material.METAL).requiresTool().strength(3f, -1f).sounds(BlockSoundGroup.METAL)));
public static final Block REFINED_SURTRUM_BLOCK = add("refined_surtrum_block", new Block(of(Material.METAL).requiresTool().strength(4f, -1f).sounds(BlockSoundGroup.METAL)));
// Misc
public static final StoneButtonBlock FLOESTONE_BUTTON = add("floestone_button", new StoneButtonBlock(copy(Blocks.STONE_BUTTON)));
public static final ButtonBlock FLOESTONE_BUTTON = add("floestone_button", new ButtonBlock(copy(Blocks.STONE_BUTTON)));
public static final PressurePlateBlock FLOESTONE_PRESSURE_PLATE = add("floestone_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.MOBS, copy(STONE_PRESSURE_PLATE)));
public static final FloatingBlock LEVITATOR = add("levitator", new FloatingBlock(true, of(Material.WOOD).strength(3f, 3f).sounds(BlockSoundGroup.WOOD)));
public static final ChainBlock OLVITE_CHAIN = add("olvite_chain", new ChainBlock(copy(CHAIN)), cutoutMippedRenderLayer);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/net/id/paradiselost/config/ModMenuConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@

@Environment(EnvType.CLIENT)
public class ModMenuConfig implements ModMenuApi {

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(ParadiseLostConfig.class, parent).get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void doDamage() {
for (Entity e : hit) {
Vec3d diff = this.getPos().subtract(e.getPos()).negate().normalize();
e.addVelocity(diff.x, diff.y, diff.z);
e.damage(DamageSource.explosion((LivingEntity) null), 2);
e.damage(this.world.getDamageSources().explosion(null, e), 2);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/id/paradiselost/fluids/DenseCloudFluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

Expand All @@ -28,7 +29,7 @@ public Fluid getStill() {
}

@Override
protected boolean isInfinite() {
protected boolean isInfinite(World world) {
return false;
}

Expand Down Expand Up @@ -88,6 +89,6 @@ public int getLevel(FluidState state) {
}

@Override
protected void tryFlow(WorldAccess world, BlockPos fluidPos, FluidState state) {
protected void tryFlow(World world, BlockPos fluidPos, FluidState state) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void randomDisplayTick(World world, BlockPos pos, FluidState state, Rando
}

@Override
protected boolean isInfinite() {
protected boolean isInfinite(World world) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.id.paradiselost.items.utils.ParadiseLostDispenserBehaviors;
import net.id.incubus_core.util.RegistryQueue;
import net.minecraft.block.DispenserBlock;
import net.minecraft.item.ItemConvertible;

import java.util.function.Consumer;

class ParadiseLostItemActions {
protected static final RegistryQueue.Action<ItemConvertible> compostable15 = compostable(0.15f);
protected static final RegistryQueue.Action<ItemConvertible> compostable30 = compostable(0.3f);
protected static final RegistryQueue.Action<ItemConvertible> compostable50 = compostable(0.5f);
protected static final RegistryQueue.Action<ItemConvertible> compostable65 = compostable(0.65f);
protected static final RegistryQueue.Action<ItemConvertible> compostable85 = compostable(0.85f);
protected static final RegistryQueue.Action<ItemConvertible> compostable100 = compostable(1f);
protected static final Consumer<ItemConvertible> compostable15 = compostable(0.15f);
protected static final Consumer<ItemConvertible> compostable30 = compostable(0.3f);
protected static final Consumer<ItemConvertible> compostable50 = compostable(0.5f);
protected static final Consumer<ItemConvertible> compostable65 = compostable(0.65f);
protected static final Consumer<ItemConvertible> compostable85 = compostable(0.85f);
protected static final Consumer<ItemConvertible> compostable100 = compostable(1f);

protected static final RegistryQueue.Action<ItemConvertible> emptiableBucketBehavior = (id, item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.emptiableBucket);
protected static final RegistryQueue.Action<ItemConvertible> emptyBucketBehavior = (id, item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.emptyBucket);
protected static final RegistryQueue.Action<ItemConvertible> spawnEggBehavior = (id, item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.spawnEgg);
protected static final Consumer<ItemConvertible> emptiableBucketBehavior = (item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.emptiableBucket);
protected static final Consumer<ItemConvertible> emptyBucketBehavior = (item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.emptyBucket);
protected static final Consumer<ItemConvertible> spawnEggBehavior = (item) -> DispenserBlock.registerBehavior(item, ParadiseLostDispenserBehaviors.spawnEgg);

protected static RegistryQueue.Action<ItemConvertible> fuel(int ticks) {
return (id, item) -> FuelRegistry.INSTANCE.add(item, ticks);
protected static Consumer<ItemConvertible> fuel(int ticks) {
return (item) -> FuelRegistry.INSTANCE.add(item, ticks);
}
protected static RegistryQueue.Action<ItemConvertible> compostable(float chance) {
return (id, item) -> CompostingChanceRegistry.INSTANCE.add(item, chance);
protected static Consumer<ItemConvertible> compostable(float chance) {
return (item) -> CompostingChanceRegistry.INSTANCE.add(item, chance);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;

import static net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder.build;

public class ParadiseLostItemGroups {
public static final ItemGroup PARADISE_LOST_BUILDING_BLOCKS = build(
ParadiseLost.locate("building_blocks"),
Expand Down
Loading

0 comments on commit 0240cbc

Please sign in to comment.