Skip to content

Commit

Permalink
- fix playSounds event
Browse files Browse the repository at this point in the history
- fix JEI error
- remove jei error spam
- fix oxygen capability
- rename PlanetsRegistry to PlanetRegistry to be coherent with other registries
- fix flag duplication bug
  • Loading branch information
st0x0ef committed Mar 8, 2023
1 parent b9e6cc9 commit f7b51e4
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 102 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=6.4
mod_version=6.4b

mc_version=1.19.2
loader_version=43
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/net/mrscauthd/beyond_earth/BeyondEarth.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public BeyondEarth() {
FeatureRegistry.FEATURES.register(bus);
ModPlacedFeature.PLACED_FEATURE.register(bus);
ModConfiguredFeature.CONFIGURED_FEATURES.register(bus);
//ModBiomeModifiers.BIOME_MODIFIERS.register(bus);

MinecraftForge.EVENT_BUS.register(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ public static void playSounds(PlaySoundEvent event) {
Minecraft mc = Minecraft.getInstance();
Player player = mc.player;
SoundInstance instance = event.getSound();
SoundSource source = instance.getSource();

if (event.getSound() == null || player == null) {
if (instance == null || player == null) {
return;
}

/** JET SUIT FLY SOUND */
if (instance instanceof ElytraOnPlayerSoundInstance) {
SoundSource source = instance.getSource();

/** JET SUIT FLY SOUND */
if (Methods.isLivingInJetSuit(player) && instance instanceof ElytraOnPlayerSoundInstance) {
mc.getSoundManager().play(new TickableJetSuitFlySound((LocalPlayer) player));
}

/** SPACE SOUND SYSTEM */
if (ClientMethods.isNotGuiSoundSource(source) && Methods.isSpaceLevelWithoutOxygen(player.level)) {

if (instance instanceof TickableSoundInstance) {
event.setSound(new TickableSpaceSoundSystem((TickableSoundInstance) instance));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void appendHoverText(ItemStack itemStack, Level level, List<Component> li

@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new OxygenProvider(this.getOxygenCapacity());
return new OxygenProvider(stack, this.getOxygenCapacity());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package net.mrscauthd.beyond_earth.common.blocks;

import javax.annotation.Nullable;

import com.mojang.authlib.GameProfile;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -22,25 +19,25 @@
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.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.mrscauthd.beyond_earth.common.blocks.entities.FlagBlockEntity;
import net.mrscauthd.beyond_earth.common.registries.ItemsRegistry;

import javax.annotation.Nullable;

import static net.minecraft.world.level.block.state.properties.BlockStateProperties.DOUBLE_BLOCK_HALF;

public class FlagBlock extends BaseEntityBlock implements SimpleWaterloggedBlock {
public static final EnumProperty<DoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF;
public static final EnumProperty<DoubleBlockHalf> HALF = DOUBLE_BLOCK_HALF;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
Expand Down Expand Up @@ -82,6 +79,7 @@ public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Pla
removeBottomHalf(worldIn, pos, state, player);
}
super.playerWillDestroy(worldIn, pos, state, player);
player.addItem(ItemsRegistry.FLAG_ITEM.get().getDefaultInstance());
}

protected static void removeBottomHalf(Level world, BlockPos pos, BlockState state, Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ public FlagBlockEntity(BlockPos pos, BlockState state) {
}

@Override
protected void saveAdditional(CompoundTag p_187518_) {
super.saveAdditional(p_187518_);
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
if (this.owner != null) {
CompoundTag compoundtag = new CompoundTag();
NbtUtils.writeGameProfile(compoundtag, this.owner);
p_187518_.put("FlagOwner", compoundtag);
tag.put("FlagOwner", compoundtag);
}

}

@Override
public void load(CompoundTag p_155745_) {
super.load(p_155745_);
if (p_155745_.contains("FlagOwner", 10)) {
this.setOwner(NbtUtils.readGameProfile(p_155745_.getCompound("FlagOwner")));
} else if (p_155745_.contains("ExtraType", 8)) {
String s = p_155745_.getString("ExtraType");
public void load(CompoundTag tag) {
super.load(tag);
if (tag.contains("FlagOwner", 10)) {
this.setOwner(NbtUtils.readGameProfile(tag.getCompound("FlagOwner")));
} else if (tag.contains("ExtraType", 8)) {
String s = tag.getString("ExtraType");
if (!StringUtil.isNullOrEmpty(s)) {
this.setOwner(new GameProfile(null, s));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
Expand All @@ -11,29 +12,34 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class OxygenProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> {
public class OxygenProvider implements ICapabilityProvider, IOxygenStorageHolder {
public static Capability<OxygenStorage> OXYGEN = CapabilityManager.get(new CapabilityToken<>() {
});
public static final String KEY_OXYGEN = "Energy"; // for compatible other code

private OxygenStorage oxygenStorage;
private final int capacity;
private ItemStack itemStack;
private IOxygenStorage oxygenStorage;

public OxygenProvider(int capacity) {
this.capacity = capacity;
public OxygenProvider(ItemStack itemStack, int capacity) {
this.itemStack = itemStack;
this.oxygenStorage = new OxygenStorage(this, capacity);

this.readOxygen();
}

private OxygenStorage getOxygenStorage() {
if (this.oxygenStorage == null) {
this.oxygenStorage = new OxygenStorage();
this.oxygenStorage.setMaxCapacity(this.capacity);
}
private void readOxygen() {
CompoundTag compound = this.getItemStack().getOrCreateTag();
this.getOxygenStorage().setOxygen(compound.getInt(KEY_OXYGEN));
}

return this.oxygenStorage;
public void writeOxygen() {
CompoundTag compound = this.getItemStack().getOrCreateTag();
compound.putInt(KEY_OXYGEN, this.getOxygenStorage().getOxygen());
}

@Override
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
LazyOptional<T> oxygenCapability = OxygenUtil.getOxygenCapability(cap, this::getOxygenStorage);
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction direction) {
LazyOptional<T> oxygenCapability = OxygenUtil.getOxygenCapability(capability, this::getOxygenStorage);

if (oxygenCapability.isPresent()) {
return oxygenCapability;
Expand All @@ -43,12 +49,15 @@ private OxygenStorage getOxygenStorage() {
}

@Override
public CompoundTag serializeNBT() {
return this.getOxygenStorage().serializeNBT();
public void onOxygenChanged(IOxygenStorage oxygenStorage, int oxygenDelta) {
this.writeOxygen();
}

@Override
public void deserializeNBT(CompoundTag nbt) {
this.getOxygenStorage().deserializeNBT(nbt);
public ItemStack getItemStack() {
return this.itemStack;
}

public IOxygenStorage getOxygenStorage() {
return this.oxygenStorage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ public class OxygenStorage implements IOxygenStorage {

private final IOxygenStorageHolder listener;

public OxygenStorage() {
this.listener = null;
public OxygenStorage(IOxygenStorageHolder holder, int capacity) {
this(holder, capacity, 0);
}

public OxygenStorage(IOxygenStorageHolder holder, int capacity, int oxygen) {
this.listener = holder;
this.capacity = capacity;
this.oxygen = Math.max(0, Math.min(capacity, oxygen));
}

public OxygenStorage(IOxygenStorageHolder listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static IOxygenStorage getItemStackOxygenStorage(ItemStack itemStack) {
* test receive oxygen to itemstack
*
* @param itemStack
* @param fluid
* @return
*/
public static boolean canReceive(ItemStack itemStack) {
Expand All @@ -60,7 +59,6 @@ public static boolean canReceive(ItemStack itemStack) {
* test extract oxygen from itemstack
*
* @param itemStack
* @param fluid
* @return
*/
public static boolean canExtract(ItemStack itemStack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public class Config {

/** Water to ice */
BUILDER.push("Water to Ice");
WATER_TO_ICE_MOON = BUILDER.comment("Enable or Disable Water the transformation of water into ice on the moon").define("Water to ice moon", false);
WATER_TO_ICE_GLACIO = BUILDER.comment("Enable or Disable Water the transformation of water into ice on glacio").define("Water to ice glacio", false);
WATER_TO_ICE_MOON = BUILDER.comment("Enable or Disable the transformation of water into ice on the moon").define("Water to ice moon", false);
WATER_TO_ICE_GLACIO = BUILDER.comment("Enable or Disable the transformation of water into ice on glacio").define("Water to ice glacio", false);
BUILDER.pop();

SPEC = BUILDER.build();
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/net/mrscauthd/beyond_earth/common/jei/Jei.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,37 @@ public ResourceLocation getPluginUid() {
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
final IGuiHelper helper = registration.getJeiHelpers().getGuiHelper();
registration.addRecipeCategories(new CoalGenerator(helper));
registration.addRecipeCategories(new Compressor(helper));
registration.addRecipeCategories(new FuelRefining(helper));
registration.addRecipeCategories(new OxygenLoader(helper));
registration.addRecipeCategories(new OxygenBubbleLoader(helper));
registration.addRecipeCategories(new NASAWorkbench(helper));
public void registerCategories(IRecipeCategoryRegistration register) {
final IGuiHelper helper = register.getJeiHelpers().getGuiHelper();
register.addRecipeCategories(new CoalGenerator(helper));
register.addRecipeCategories(new Compressor(helper));
register.addRecipeCategories(new FuelRefining(helper));
register.addRecipeCategories(new OxygenLoader(helper));
register.addRecipeCategories(new OxygenBubbleLoader(helper));
register.addRecipeCategories(new NASAWorkbench(helper));
}

@Override
public void registerIngredients(IModIngredientRegistration registration) {
registration.register(O2_INGREDIENT_TYPE, O2Ingredient.getIngredients(), O2Ingredient.INSTANCE,
public void registerIngredients(IModIngredientRegistration register) {
register.register(O2_INGREDIENT_TYPE, O2Ingredient.getIngredients(), O2Ingredient.INSTANCE,
new O2Ingredient.DummyRenderer());
registration.register(FE_INGREDIENT_TYPE, EnergyIngredient.getIngredients(), EnergyIngredient.INSTANCE,
register.register(FE_INGREDIENT_TYPE, EnergyIngredient.getIngredients(), EnergyIngredient.INSTANCE,
new EnergyIngredient.DummyRenderer());
}

@Override
public void registerRecipes(IRecipeRegistration registration) {
registration.addRecipes(COAL_TYPE,
public void registerRecipes(IRecipeRegistration register) {
register.addRecipes(COAL_TYPE,
RecipeTypeRegistry.COAL_GENERATING.get().getRecipes(Minecraft.getInstance().level));
registration.addRecipes(COMPRESS_TYPE,
register.addRecipes(COMPRESS_TYPE,
RecipeTypeRegistry.COMPRESSING.get().getRecipes(Minecraft.getInstance().level));
registration.addRecipes(REFINE_TYPE,
register.addRecipes(REFINE_TYPE,
RecipeTypeRegistry.FUEL_REFINING.get().getRecipes(Minecraft.getInstance().level));
registration.addRecipes(OXYGEN_LOADER_TYPE,
register.addRecipes(OXYGEN_LOADER_TYPE,
RecipeTypeRegistry.OXYGEN_LOADING.get().getRecipes(Minecraft.getInstance().level));
registration.addRecipes(OXYGEN_BUBBLE_TYPE,
register.addRecipes(OXYGEN_BUBBLE_TYPE,
RecipeTypeRegistry.OXYGEN_BUBBLE_DISTRIBUTING.get().getRecipes(Minecraft.getInstance().level));
registration.addRecipes(WORKBENCH_TYPE,
register.addRecipes(WORKBENCH_TYPE,
RecipeTypeRegistry.NASA_WORKBENCHING.get().getRecipes(Minecraft.getInstance().level));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EnergyIngredient implements IIngredientHelper<EnergyIngredient>, II
public static final class DummyRenderer implements IIngredientRenderer<EnergyIngredient> {
@Override
public void render(PoseStack stack, EnergyIngredient ingredient) {
System.err.println("DO NOT USE THIS, THIS IS BECAUSE JEI REQUIRES SIZE 16");
// DO NOT USE THIS, THIS IS BECAUSE JEI REQUIRES SIZE 16
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class O2Ingredient implements IIngredientHelper<O2Ingredient>, IIngredien
public static final class DummyRenderer implements IIngredientRenderer<O2Ingredient> {
@Override
public void render(PoseStack stack, O2Ingredient ingredient) {
System.err.println("DO NOT USE THIS, THIS IS BECAUSE JEI REQUIRES SIZE 16");
// DO NOT USE THIS, THIS IS BECAUSE JEI REQUIRES SIZE 16
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class BlockRegistry {
public static final RegistryObject<Block> GLACIO_GLOBE_BLOCK = BLOCKS.register("glacio_globe",() -> new GlobeBlock(BlockBehaviour.Properties.of(Material.STONE).strength(3.5F).sound(SoundType.STONE).noOcclusion().requiresCorrectToolForDrops(), new ResourceLocation(BeyondEarth.MODID, "textures/block/globes/glacio_globe.png")));

/** FLAG BLOCKS */
public static final RegistryObject<Block> FLAG_BLOCK = BLOCKS.register("flag",() -> new FlagBlock(BlockBehaviour.Properties.of(Material.STONE).strength(1.0F, 1.0F).sound(SoundType.STONE).noOcclusion().lightLevel(s -> 1).isRedstoneConductor((bs, br, bp) -> false)));
public static final RegistryObject<Block> FLAG_BLOCK = BLOCKS.register("flag",() -> new FlagBlock(BlockBehaviour.Properties.of(Material.STONE).strength(1.0F, 1.0F).sound(SoundType.STONE).noOcclusion().lightLevel(s -> 1).isRedstoneConductor((bs, br, bp) -> false).noLootTable()));

/** ORES */
public static final RegistryObject<Block> MOON_CHEESE_ORE = BLOCKS.register("moon_cheese_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE).sound(SoundType.STONE).strength(3.0F, 3.0F).requiresCorrectToolForDrops()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.mrscauthd.beyond_earth.BeyondEarth;
import net.mrscauthd.beyond_earth.common.util.Planets;

import static net.mrscauthd.beyond_earth.common.util.Planets.BY_DIMENSION;

public class PlanetsRegistry {
public class PlanetRegistry {

/** PLANET BAR TEXTURES */
private static final ResourceLocation MOON_PLANET_BAR = new ResourceLocation(BeyondEarth.MODID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import net.minecraftforge.common.MinecraftForge;
import net.mrscauthd.beyond_earth.BeyondEarth;
import net.mrscauthd.beyond_earth.common.events.forge.PlanetRegisterEvent;
import net.mrscauthd.beyond_earth.common.registries.LevelRegistry;

import static net.mrscauthd.beyond_earth.common.registries.PlanetsRegistry.registerDefaultPlanets;
import static net.mrscauthd.beyond_earth.common.registries.PlanetRegistry.registerDefaultPlanets;

public class Planets {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected void addTables() {
this.dropSelf(BlockRegistry.MERCURY_GLOBE_BLOCK.get());
this.dropSelf(BlockRegistry.VENUS_GLOBE_BLOCK.get());
this.dropSelf(BlockRegistry.GLACIO_GLOBE_BLOCK.get());
this.dropSelf(BlockRegistry.FLAG_BLOCK.get());
this.dropSelf(BlockRegistry.MOON_SAND.get());
this.dropSelf(BlockRegistry.MARS_SAND.get());
this.dropSelf(BlockRegistry.VENUS_SAND.get());
Expand Down
Loading

0 comments on commit f7b51e4

Please sign in to comment.