Skip to content

Commit

Permalink
Added capes and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaidee committed Jul 29, 2022
1 parent 2559007 commit 68faad6
Show file tree
Hide file tree
Showing 41 changed files with 330 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 GLEEP ORANGE
Copyright (c) 2022 Team Galena

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ minecraft {
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
args "-mixin.config=${mod_id}.mixins.json"
args "-mixin.config=galenacapes.forge.mixins.json"
mods {
modClientRun {
source sourceSets.main
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/galena/galenacapes/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package galena.galenacapes;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class Constants {

/*
@author: Xaidee
Remember to update this list frequently!
For the most recent version of this file please refer to https://github.com/Xaidee/Galena-Capes/blob/1.18/Common/src/main/java/galena/galenacapes/Constants.java
*/

public static final String MOD_ID = "galenacapes";
public static final String MOD_NAME = "Galena Capes";
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);

// List of usernames apart of Team Galena
public static final List<String> Dev = List.of(
"Dev"
);
/// Patreon member capes
public static final List<String> OPatreons = List.of( // Oreganized Cape
"Xaidee",
"Bi_nome",
"keviikk"
);
public static final List<String> OFPatreons = List.of( // Overweight Farming Cape

);
public static final List<String> GPatreonsBlue = List.of( // Blue Galosphere Cape

);
public static final List<String> GPatreonsYellow = List.of( // Yellow Galosphere Cape

);
public static final List<String> CPatreons = List.of( // Cooperative Cape
"Axeceros"
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package galena.galenacapes.mixin;

import galena.galenacapes.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import javax.annotation.Nullable;
import java.util.Objects;

@Mixin(AbstractClientPlayer.class)
public abstract class AbstractClientPlayerMixin {

/*
@author: Xaidee
For the most recent version of this file please refer to https://github.com/Xaidee/Galena-Capes/blob/1.18/Common/src/main/java/galena/galenacapes/mixin/AbstractClientPlayerMixin.java
*/

@Shadow @Nullable
protected abstract PlayerInfo getPlayerInfo();

@Inject(method= "getCloakTextureLocation()Lnet/minecraft/resources/ResourceLocation;", at=@At("RETURN"), cancellable = true)

public void getCloakTextureLocation(CallbackInfoReturnable<ResourceLocation> cir) {
assert Minecraft.getInstance().player != null;
if(!(Objects.requireNonNull(this.getPlayerInfo()).getProfile().getId().equals(Minecraft.getInstance().player.getUUID()))) {
cir.setReturnValue(null);
} else {
String username = this.getPlayerInfo().getProfile().getName();

for (int i = 0; Constants.Dev.size() > i; i++) {
if (Constants.Dev.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/dev.png"));
}
for (int i = 0; Constants.OPatreons.size() > i; i++) {
if (Constants.OPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/oreganized.png"));
}
for (int i = 0; Constants.OFPatreons.size() > i; i++) {
if (Constants.OFPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/overweightfarming.png"));
}
for (int i = 0; Constants.GPatreonsBlue.size() > i; i++) {
if (Constants.GPatreonsBlue.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/galosphere_blue.png"));
}
for (int i = 0; Constants.GPatreonsYellow.size() > i; i++) {
if (Constants.GPatreonsYellow.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/galosphere_yellow.png"));
}
for (int i = 0; Constants.CPatreons.size() > i; i++) {
if (Constants.CPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/coopperative.png"));
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/galena/oreganized/Oreganized.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Oreganized() {
OSoundEvents.SOUNDS,
OStructures.STRUCTURE_TYPES,
OStructures.STRUCTURES,
OBiomeModifiers.BIOME_MODIFIERS,
};

for (DeferredRegister<?> register : registers) {
Expand All @@ -68,6 +69,8 @@ public Oreganized() {

private void setup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
OConfiguredFeatures.register();
OPlacedFeatures.register();
OCauldronInteractions.register();

PotionBrewing.addMix(Potions.WATER, OItems.LEAD_INGOT.get(), OPotions.STUNNING.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
Expand All @@ -33,17 +35,18 @@
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.Optional;
import java.util.function.Supplier;

public class MoltenLeadBlock extends Block implements BucketPickup {
public class MoltenLeadBlock extends LiquidBlock {
/*
The following code is a mishmash of PowderSnowBlock with some extras taken from Fluid classes.
*/
private static final BooleanProperty MOVING = BooleanProperty.create("ismoving");

private static final VoxelShape FALLING_COLLISION_SHAPE = Shapes.box(0.0D, 0.0D, 0.0D, 1.0D, (double)0.9F, 1.0D);

public MoltenLeadBlock(BlockBehaviour.Properties properties) {
super(properties);
public MoltenLeadBlock(Supplier<? extends FlowingFluid> fluid, Properties properties) {
super(fluid, properties.noCollission().strength(-1.0F, 3600000.0F).noLootTable().lightLevel((state) -> 8));
}

protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/galena/oreganized/content/fluid/MoltenLeadFluid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package galena.oreganized.content.fluid;

import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.material.FluidState;
import net.minecraftforge.fluids.ForgeFlowingFluid;

public class MoltenLeadFluid extends ForgeFlowingFluid {

public MoltenLeadFluid(Properties properties) {
super(properties);
}

@Override
protected void animateTick(Level world, BlockPos pos, FluidState state, RandomSource rand) {
if (rand.nextInt(200) == 0) {
world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.LAVA_AMBIENT, SoundSource.BLOCKS, 1.0F, 1.0F, false);
}
}

@Override
public int getTickDelay(LevelReader world) {
return 5;
}

@Override
protected boolean isRandomlyTicking() {
return true;
}

public int getAmount(FluidState state) {
return 8;
}

public boolean isSource(FluidState state) {
return true;
}
}
18 changes: 18 additions & 0 deletions src/main/java/galena/oreganized/content/index/OBiomeModifiers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package galena.oreganized.content.index;

import com.mojang.serialization.Codec;
import galena.oreganized.Oreganized;
import galena.oreganized.world.OreganizedBiomeModifier;
import net.minecraftforge.common.world.BiomeModifier;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

@Mod.EventBusSubscriber(modid = Oreganized.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class OBiomeModifiers {

public static final DeferredRegister<Codec<? extends BiomeModifier>> BIOME_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, Oreganized.MOD_ID);

public static final RegistryObject<Codec<? extends BiomeModifier>> OREGANIZED_BIOME_MODIFIER = BIOME_MODIFIERS.register("oreganized_biome_modifier", () -> Codec.unit(OreganizedBiomeModifier::new));
}
5 changes: 2 additions & 3 deletions src/main/java/galena/oreganized/content/index/OBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ public class OBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Oreganized.MOD_ID);


public static final RegistryObject<Block> MOLTEN_LEAD = register("molten_lead_block", () ->
new MoltenLeadBlock(BlockBehaviour.Properties.of(OMaterials.MOLTEN_LEAD).strength(-1.0F, 3600000.0F)
.dynamicShape().lightLevel((light) -> 8)));
public static final RegistryObject<LiquidBlock> MOLTEN_LEAD = register("molten_lead_block", () ->
new MoltenLeadBlock(OFluids.MOLTEN_LEAD, BlockBehaviour.Properties.of(OMaterials.MOLTEN_LEAD)));
public static final RegistryObject<Block> MOLTEN_LEAD_CAULDRON = register("molten_lead_cauldron", () -> new MoltenLeadCauldronBlock(BlockBehaviour.Properties.copy(Blocks.LAVA_CAULDRON).lightLevel(moltenStageEmission())));

// Glance
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package galena.oreganized.content.index;

import galena.oreganized.Oreganized;
import net.minecraft.core.Holder;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;

import java.util.List;

public class OConfiguredFeatures {

public static void register() {

}

public static final Holder<ConfiguredFeature<OreConfiguration, ?>> SILVER_ORE_LOW = registerConfiguredFeature("silver_ore", Feature.ORE, new OreConfiguration(List.of(OreConfiguration.target(new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), OBlocks.SILVER_ORE.get().defaultBlockState()), OreConfiguration.target(new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), OBlocks.DEEPSLATE_SILVER_ORE.get().defaultBlockState())), 6));

public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<ConfiguredFeature<FC, ?>> registerConfiguredFeature(String id, F feature, FC featureConfiguration) {
ResourceLocation modLoc = new ResourceLocation(Oreganized.MOD_ID, id);

if (BuiltinRegistries.CONFIGURED_FEATURE.keySet().contains(modLoc))
throw new IllegalStateException("Placed Feature ID: \"" + modLoc + "\" already exists in the Placed Features registry!");

return BuiltinRegistries.registerExact(BuiltinRegistries.CONFIGURED_FEATURE, modLoc.toString(), new ConfiguredFeature<>(feature, featureConfiguration));
}
}
36 changes: 36 additions & 0 deletions src/main/java/galena/oreganized/content/index/OFluids.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package galena.oreganized.content.index;

import galena.oreganized.Oreganized;
import galena.oreganized.content.fluid.MoltenLeadFluid;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.function.Consumer;

public class OFluids {

public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(ForgeRegistries.FLUIDS, Oreganized.MOD_ID);
public static final DeferredRegister<FluidType> TYPES = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, Oreganized.MOD_ID);

public static final RegistryObject<FluidType> MOLTEN_LEAD_TYPE = TYPES.register("molten_lead", () -> new FluidType(FluidType.Properties.create().lightLevel(8).density(1500).temperature(600).viscosity(3000).motionScale(0.007D).canExtinguish(false)) {
@Override
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
consumer.accept(new IClientFluidTypeExtensions() {
@Override
public ResourceLocation getStillTexture() {
return new ResourceLocation(Oreganized.MOD_ID, "fluid/molten_lead");
}
});
}
});

public static final RegistryObject<FlowingFluid> MOLTEN_LEAD = FLUIDS.register("molten_lead", () -> new MoltenLeadFluid(OFluids.MOLTEN_LEAD_PROPERTIES));

public static final MoltenLeadFluid.Properties MOLTEN_LEAD_PROPERTIES = new MoltenLeadFluid.Properties(MOLTEN_LEAD_TYPE, MOLTEN_LEAD, MOLTEN_LEAD).bucket(OItems.MOLTEN_LEAD_BUCKET).block(OBlocks.MOLTEN_LEAD);
}
4 changes: 4 additions & 0 deletions src/main/java/galena/oreganized/content/index/OItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public class OItems {
() -> new ElectrumArmorItem(OArmorMaterials.ELECTRUM, EquipmentSlot.LEGS));
public static final RegistryObject<Item> ELECTRUM_BOOTS = ITEMS.register("electrum_boots",
() -> new ElectrumArmorItem(OArmorMaterials.ELECTRUM, EquipmentSlot.FEET));

// Compatibility
/*public static final RegistryObject<Item> ELECTRUM_KNIFE = ITEMS.register("electrum_knife",
() -> new KnifeItem(OItemTiers.ELECTRUM, 0.5F, -1.8F, (new Item.Properties()).tab(ModList.get().isLoaded(FarmersDelight.MODID) ? FarmersDelight.CREATIVE_TAB : null);*/
}
43 changes: 43 additions & 0 deletions src/main/java/galena/oreganized/content/index/OPlacedFeatures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package galena.oreganized.content.index;

import galena.oreganized.Oreganized;
import net.minecraft.core.Holder;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.*;

import java.util.List;

public class OPlacedFeatures {

public static void register() {

}

public static final Holder<PlacedFeature> SILVER_ORE_LOW = registerPlacedFeature("silver_ore", OConfiguredFeatures.SILVER_ORE_LOW, commonOrePlacement(4, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(48))));

public static <FC extends FeatureConfiguration> Holder<PlacedFeature> registerPlacedFeature(String id, Holder<ConfiguredFeature<FC, ?>> feature, PlacementModifier... placementModifiers) {
return registerPlacedFeature(id, feature, List.of(placementModifiers));
}

public static <FC extends FeatureConfiguration> Holder<PlacedFeature> registerPlacedFeature(String id, Holder<ConfiguredFeature<FC, ?>> feature, List<PlacementModifier> placementModifiers) {
ResourceLocation modLoc = new ResourceLocation(Oreganized.MOD_ID, id);
if (BuiltinRegistries.PLACED_FEATURE.keySet().contains(modLoc))
throw new IllegalStateException("Placed Feature ID: \"" + modLoc + "\" already exists in the Placed Features registry!");

PlacedFeature placedFeature = new PlacedFeature(Holder.hackyErase(feature), List.copyOf(placementModifiers));

return BuiltinRegistries.register(BuiltinRegistries.PLACED_FEATURE, modLoc, placedFeature);
}

private static List<PlacementModifier> orePlacement(PlacementModifier modifier, PlacementModifier modifier2) {
return List.of(modifier, InSquarePlacement.spread(), modifier2, BiomeFilter.biome());
}

private static List<PlacementModifier> commonOrePlacement(int count, PlacementModifier modifier) {
return orePlacement(CountPlacement.of(count), modifier);
}
}
25 changes: 25 additions & 0 deletions src/main/java/galena/oreganized/world/OreganizedBiomeModifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package galena.oreganized.world;

import com.mojang.serialization.Codec;
import galena.oreganized.content.index.OBiomeModifiers;
import galena.oreganized.content.index.OPlacedFeatures;
import net.minecraft.core.Holder;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraftforge.common.world.BiomeModifier;
import net.minecraftforge.common.world.ModifiableBiomeInfo;

public class OreganizedBiomeModifier implements BiomeModifier {

@Override
public void modify(Holder<Biome> biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) {
if (phase == Phase.ADD) {
builder.getGenerationSettings().addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OPlacedFeatures.SILVER_ORE_LOW);
}
}

@Override
public Codec<? extends BiomeModifier> codec() {
return OBiomeModifiers.OREGANIZED_BIOME_MODIFIER.get();
}
}
Loading

0 comments on commit 68faad6

Please sign in to comment.