Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Ender Invasion #30

Merged
merged 50 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f46718e
Added ender invasion state and chat message
mschae23 Aug 11, 2020
49b4f0d
Added end grass block
mschae23 Aug 11, 2020
94503e2
Added spreadable block tag
mschae23 Aug 11, 2020
607ed40
Added spread recipes
mschae23 Aug 11, 2020
4f71ac8
Added mixin for random ticks
mschae23 Aug 11, 2020
f097897
Added the possibility to change chunks that get loaded
mschae23 Aug 11, 2020
e266c90
Added chunk component
mschae23 Aug 11, 2020
7e5f2cb
Use Fabric Lifecycle Events module instead of mixin
mschae23 Aug 12, 2020
a9fd691
Add Fabric Biomes module manually, as it isn't included
mschae23 Aug 12, 2020
2f6ee85
Only convert parts of the Overworld
mschae23 Aug 13, 2020
ca04686
Added texture for the end grass block
mschae23 Aug 13, 2020
d8b3952
Added corrupted grass and dirt, end caps and withered logs
mschae23 Aug 18, 2020
bd430e8
Added blockstate and models for end caps
mschae23 Aug 18, 2020
59a7a87
End foam and end caps also generate now
mschae23 Aug 19, 2020
0309b09
Fixed end foam transparency not working
mschae23 Aug 20, 2020
9deb417
Removed end grass block (replaced with corrupted dirt)
mschae23 Aug 20, 2020
9dc3bd3
Added withered leaves
mschae23 Aug 20, 2020
bf706a5
Updated corrupted dirt texture
mschae23 Aug 20, 2020
dc80e53
Keep block state when converting logs or leaves
mschae23 Aug 22, 2020
0e7192b
Made the ender pearl inaccessible before the ender invasion starts
mschae23 Aug 30, 2020
a053b06
Use noise with the world seed
mschae23 Aug 30, 2020
54d27f7
Switched components to static registration (V3)
mschae23 Sep 2, 2020
b40d27d
Reverted switch to static registration
mschae23 Sep 4, 2020
a596288
Added endermen spawning in corrupted areas
mschae23 Sep 4, 2020
b3ffe61
Added ender invasion events + refactored code
mschae23 Sep 5, 2020
39f6977
Changed spawn conditions for endermen in the ender invasion
mschae23 Sep 5, 2020
ff16dc2
Use block break event instead of overriding afterBreak(...)
mschae23 Sep 6, 2020
1f93709
Added required Fabric API version to fabric.mod.json
mschae23 Sep 6, 2020
0ed8fb0
Added block spread for hard difficulty
mschae23 Sep 6, 2020
c01fd3d
Changed enderman spawning and experimented with particles
mschae23 Sep 7, 2020
d840cbe
Increased enderman spawn chance
mschae23 Sep 7, 2020
21b28ad
Another change to the ender invasion's mob spawning
mschae23 Sep 8, 2020
d0d758f
Renamed events and removed SimplexNoiseSampler argument
mschae23 Sep 8, 2020
64b4e03
Forgot to change the event invocation
mschae23 Sep 8, 2020
a3f8df1
Changed how the ender invasion particles spawn
mschae23 Sep 8, 2020
d051886
Refactored code
mschae23 Sep 9, 2020
bfeae06
End the ender invasion when the ender dragon has been defeated
mschae23 Sep 9, 2020
8bdf204
When the ender dragon has been defeated, the invasion slowly shrinks
mschae23 Sep 9, 2020
7931555
Ignore chunks that are unaffected by the ender invasion
mschae23 Sep 10, 2020
182504c
Renamed spreadTo to convert in EnderInvasionHelper
mschae23 Sep 10, 2020
f3beae8
Fixed corrupted blocks not converting back when near to water
mschae23 Sep 10, 2020
df3df7f
Use a config instead of constants for ender invasion values
mschae23 Sep 15, 2020
ae2852f
Removed config for now
mschae23 Sep 27, 2020
a4699ad
Don't overwrite the piglin bartering loot table directly
mschae23 Sep 27, 2020
456d43d
Merge branch 'master' into ender-invasion
mschae23 Nov 11, 2020
c7584ff
Changes based on review, particle changes
mschae23 Nov 11, 2020
3a20882
Fixed issue that could somehow make the server not work
mschae23 Nov 12, 2020
4cd87b4
Merge branch 'master' into ender-invasion
mschae23 Nov 12, 2020
4ef37f4
Resolved merge conflict
mschae23 Nov 12, 2020
a6fcbfd
Merge branch 'master' into ender-invasion
mschae23 Dec 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ bin/
# fabric

run/
logs/
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ repositories {
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
}
maven {
name = "Ladysnake Libs"
url = "https://dl.bintray.com/ladysnake/libs"
}
maven { url 'https://jitpack.io' }
jcenter()
}
Expand All @@ -26,7 +30,7 @@ dependencies {
minecraft "com.mojang:minecraft:1.16.1"
mappings "net.fabricmc:yarn:1.16.1+build.1:v2"
modImplementation "net.fabricmc:fabric-loader:0.8.8+build.202"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.13.1+build.370-1.16"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.18.0+build.387-1.16.1"

modImplementation "com.lettuce.fudge:artifice:0.8.0+1.16-rc1"
include "com.lettuce.fudge:artifice:0.8.0+1.16-rc1"
Expand All @@ -35,6 +39,13 @@ dependencies {
include "io.github.cottonmc:LibGui:2.0.1+1.16.1"

modImplementation "com.github.bernie-g:geckolib:fabric-1.16.1-geckolib-2.0.0-beta.5"

modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_components_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-level:${project.cardinal_components_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-chunk:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-level:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-chunk:${project.cardinal_components_version}"
}
processResources {
inputs.property "version", project.version
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ org.gradle.jvmargs=-Xmx1G
yarn_mappings=1.16.1+build.1
loader_version=0.8.8+build.202

#Fabric api
fabric_version=0.13.1+build.370-1.16

# Mod Properties
mod_version = 0.1.0
maven_group = motherlode.core
archives_base_name = motherlode

#Dependencies
fabric_version=0.18.0+build.387-1.16.1
cardinal_components_version=2.4.1
6 changes: 5 additions & 1 deletion src/main/java/motherlode/core/Motherlode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package motherlode.core;

import motherlode.core.enderinvasion.EnderInvasion;
import motherlode.core.registry.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
Expand All @@ -9,10 +10,12 @@
import net.minecraft.util.Identifier;

public class Motherlode implements ModInitializer {
private static final String MODID = "motherlode";
public static final String MODID = "motherlode";

@Override
public void onInitialize() {

EnderInvasion.initializeEnderInvasion();
MotherlodeEntities.init();
MotherlodeBlocks.init();
MotherlodeItems.init();
Expand All @@ -29,6 +32,7 @@ public void onInitialize() {

MotherlodeData.register();
MotherlodeFeatures.register();
MotherlodeSpreadRecipes.register();
}

public static final ItemGroup BLOCKS = FabricItemGroupBuilder.create( id("blocks"))
Expand Down
86 changes: 52 additions & 34 deletions src/main/java/motherlode/core/MotherlodeClient.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
package motherlode.core;

import motherlode.core.entities.render.MotherlodeEntityRenderers;
import motherlode.core.block.PotBlock;
import motherlode.core.block.PotColor;
import motherlode.core.gui.RedstoneTransmitterGuiDescription;
import motherlode.core.gui.RedstoneTransmitterScreen;
import motherlode.core.registry.*;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.color.world.FoliageColors;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.resource.GrassColormapResourceSupplier;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.potion.PotionUtil;
import net.minecraft.util.Identifier;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.level.ColorResolver;
import net.minecraft.client.render.RenderLayer;

import net.minecraft.util.math.BlockPos;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import motherlode.core.block.PotBlock;
import motherlode.core.enderinvasion.EnderInvasion;
import motherlode.core.entities.render.MotherlodeEntityRenderers;
import motherlode.core.gui.RedstoneTransmitterGuiDescription;
import motherlode.core.gui.RedstoneTransmitterScreen;
import motherlode.core.registry.MotherlodeAssets;
import motherlode.core.registry.MotherlodeBlocks;
import motherlode.core.registry.MotherlodeParticles;
import motherlode.core.registry.MotherlodePotions;
import motherlode.core.registry.MotherlodeScreenHandlers;
@Environment(EnvType.CLIENT)
public class MotherlodeClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
MotherlodeAssets.register();
MotherlodeEntityRenderers.init();
BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeBlocks.ROPE_BLOCK, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeBlocks.ROPE_BLOCK, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeBlocks.POT, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeBlocks.END_FOAM, RenderLayer.getTranslucent());
ColorProviderRegistry.BLOCK.register((state, _world, _pos, _tintIndex) -> state.get(PotBlock.COLOR).getColor(), MotherlodeBlocks.POT);
ScreenRegistry.register(MotherlodeScreenHandlers.REDSTONE_TRANSMITTER_TYPE, (ScreenRegistry.Factory<RedstoneTransmitterGuiDescription, RedstoneTransmitterScreen>) RedstoneTransmitterScreen::new);

Expand All @@ -58,22 +62,36 @@ public void onInitializeClient() {
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) ->
BiomeColors.getGrassColor(world, pos), MotherlodeBlocks.WATERPLANT);

FabricModelPredicateProviderRegistry.register(Items.POTION, new Identifier("potion_type"), (itemStack, _world, _entity) -> {
MotherlodePotions.PotionModelInfo potion = MotherlodePotions.potionModelInfos.get( PotionUtil.getPotion(itemStack) );
return potion == null ? 1 : potion.predicateValue;
});
FabricModelPredicateProviderRegistry.register(Items.POTION, new Identifier("potion_type"), (itemStack, _world, _entity) -> {
MotherlodePotions.PotionModelInfo potion = MotherlodePotions.potionModelInfos.get(PotionUtil.getPotion(itemStack));
return potion == null ? 1 : potion.predicateValue;
});

FabricModelPredicateProviderRegistry.register(new Identifier("stack_count"), (itemStack, _world, _entity) -> itemStack.getCount() / 100F);

FabricModelPredicateProviderRegistry.register(MotherlodeBlocks.POT_ITEM, new Identifier("pot_pattern"), (itemStack, _world, _entity) -> {
CompoundTag tag = itemStack.getTag();
if (tag == null || !tag.contains("BlockStateTag"))
return 0;
tag = tag.getCompound("BlockStateTag");
if (tag == null || !tag.contains("pattern"))
return 0;

return Integer.parseInt(tag.getString("pattern")) / 100F;
});

ClientSidePacketRegistry.INSTANCE.register(EnderInvasion.PLAY_PORTAL_PARTICLE_PACKET_ID, (packetContext, attachedData) -> {

FabricModelPredicateProviderRegistry.register(new Identifier("stack_count"), ( itemStack, _world, _entity) -> itemStack.getCount() / 100F);
BlockPos pos = attachedData.readBlockPos();
double offsetY = attachedData.readDouble();

FabricModelPredicateProviderRegistry.register(MotherlodeBlocks.POT_ITEM, new Identifier("pot_pattern"), (itemStack, _world, _entity) -> {
CompoundTag tag = itemStack.getTag();
if (tag == null || !tag.contains("BlockStateTag"))
return 0;
tag = tag.getCompound("BlockStateTag");
if (tag == null || !tag.contains("pattern"))
return 0;
double velocityX = attachedData.readDouble();
double velocityY = attachedData.readDouble();
double velocityZ = attachedData.readDouble();

return Integer.parseInt(tag.getString("pattern")) / 100F;
});
}
packetContext.getTaskQueue().execute(() ->
MinecraftClient.getInstance().particleManager.addParticle(
ParticleTypes.PORTAL, pos.getX(), pos.getY() + offsetY, pos.getZ(), velocityX, velocityY, velocityZ));
});
}
}
15 changes: 15 additions & 0 deletions src/main/java/motherlode/core/block/DefaultBlock.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
package motherlode.core.block;

import motherlode.core.api.ArtificeProperties;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.Direction;

public class DefaultBlock extends Block implements ArtificeProperties {
public final boolean hasDefaultState;
public final boolean hasDefaultModel;
public final boolean hasDefaultItemModel;
public final boolean hasDefaultLootTable;
public final boolean transparent;

public DefaultBlock(AbstractBlock.Settings settings) {
this(true, true, true, true, settings);
}

public DefaultBlock(boolean hasDefaultState, boolean hasDefaultModel, boolean hasDefaultItemModel, boolean hasDefaultLootTable, AbstractBlock.Settings settings) {
this(hasDefaultState, hasDefaultModel, hasDefaultItemModel, hasDefaultLootTable, false, settings);
}
public DefaultBlock(boolean hasDefaultState, boolean hasDefaultModel, boolean hasDefaultItemModel, boolean hasDefaultLootTable, boolean transparent, AbstractBlock.Settings settings) {
super(settings);

this.hasDefaultState = hasDefaultState;
this.hasDefaultModel = hasDefaultModel;
this.hasDefaultItemModel = hasDefaultItemModel;
this.hasDefaultLootTable = hasDefaultLootTable;
this.transparent = transparent;
}

@Override
Expand All @@ -47,4 +56,10 @@ public boolean hasDefaultLootTable() {
public Block getBlockInstance() {
return this;
}

@Override
@Environment(EnvType.CLIENT)
public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {
return stateFrom.isOf(this) ? this.transparent : super.isSideInvisible(state, stateFrom, direction);
}
}
54 changes: 54 additions & 0 deletions src/main/java/motherlode/core/block/DefaultLeavesBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package motherlode.core.block;

import motherlode.core.api.ArtificeProperties;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.util.math.Direction;

public class DefaultLeavesBlock extends LeavesBlock implements ArtificeProperties {
public final boolean hasDefaultState;
public final boolean hasDefaultModel;
public final boolean hasDefaultItemModel;
public final boolean hasDefaultLootTable;

public DefaultLeavesBlock(Settings settings) {
this(true, true, true, true, settings);
}

public DefaultLeavesBlock(boolean hasDefaultState, boolean hasDefaultModel, boolean hasDefaultItemModel, boolean hasDefaultLootTable, Settings settings) {
super(settings);

this.hasDefaultState = hasDefaultState;
this.hasDefaultModel = hasDefaultModel;
this.hasDefaultItemModel = hasDefaultItemModel;
this.hasDefaultLootTable = hasDefaultLootTable;
}

@Override
public boolean hasDefaultState() {
return hasDefaultState;
}

@Override
public boolean hasDefaultModel() {
return hasDefaultModel;
}

@Override
public boolean hasDefaultItemModel() {
return hasDefaultItemModel;
}

@Override
public boolean hasDefaultLootTable() {
return hasDefaultLootTable;
}

@Override
public Block getBlockInstance() {
return this;
}
}
3 changes: 1 addition & 2 deletions src/main/java/motherlode/core/block/DefaultOreBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import motherlode.core.api.OreProperties;

public class DefaultOreBlock extends DefaultBlock implements OreProperties{
public class DefaultOreBlock extends DefaultBlock implements OreProperties {
public final int minExperience;
public final int maxExperience;
public final int veinSize;
Expand All @@ -42,7 +42,6 @@ public DefaultOreBlock(boolean hasDefaultLootTable, int minExperience, int maxEx

}


protected int getExperienceWhenMined(Random random) {
if (maxExperience!=0) {
return MathHelper.nextInt(random, minExperience, maxExperience);
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/motherlode/core/block/DefaultPlantBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@

import motherlode.core.api.ArtificeProperties;
import motherlode.core.registry.MotherlodeBlocks;
import motherlode.core.registry.MotherlodeItems;
import net.minecraft.block.*;
import net.minecraft.item.Item;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.SwordItem;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

public class DefaultPlantBlock extends PlantBlock implements ArtificeProperties {
private final int height;

public DefaultPlantBlock(int height, boolean useDefaultState, boolean useDefaultModel, Function<Block, Supplier<String>> textureName, Settings settings) {
this(height, useDefaultState, useDefaultModel, true, textureName, settings);
}
public DefaultPlantBlock(int height, boolean useDefaultState, boolean useDefaultModel, boolean grassColored, Function<Block, Supplier<String>> textureName, Settings settings) {
super(settings);
this.height = height;
if(useDefaultState) MotherlodeBlocks.defaultStateList.add(this);
if(useDefaultModel) MotherlodeBlocks.defaultPlantModelList.add(this);
MotherlodeBlocks.cutouts.add(this);
MotherlodeBlocks.grassColored.add(this);
if(grassColored) MotherlodeBlocks.grassColored.add(this);
MotherlodeBlocks.flatItemModelList.put(this, textureName.apply(this));
}

Expand All @@ -45,6 +43,12 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
return isHoldingShovelOrSword(context) ? VoxelShapes.empty() : Block.createCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, height, 14.0D);
}

@Override
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {

return super.canPlantOnTop(floor, world, pos) || floor.isOf(MotherlodeBlocks.CORRUPTED_DIRT);
}

@Override
public OffsetType getOffsetType() {
return OffsetType.XYZ;
Expand Down
Loading