Skip to content

Commit

Permalink
some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed May 21, 2022
1 parent 36d1dfa commit 43d673c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import nova.committee.avaritia.api.common.block.BaseBlock;
import nova.committee.avaritia.common.menu.CraftingMenu;
import org.jetbrains.annotations.Nullable;

/**
* Description:
Expand All @@ -34,22 +32,24 @@ public AbstractCraftingTable(Material material, SoundType sound, float hardness,
setRegistryName(name);
}

public static MenuProvider getCrafterContainerElement(Player player, Level world, BlockPos pos) {
return new SimpleMenuProvider((p_52229_, p_52230_, p_52231_) -> {
return new CraftingMenu(0, player.getInventory(), ContainerLevelAccess.create(world, pos)) {
@Override
public boolean stillValid(Player playerIn) {
return true;
}
};
}, CONTAINER_TITLE);
}

@Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
if (pLevel.isClientSide) {
return InteractionResult.SUCCESS;
} else {
pPlayer.openMenu(pState.getMenuProvider(pLevel, pPos));
pPlayer.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE);
pPlayer.openMenu(getCrafterContainerElement(pPlayer, pLevel, pPos));
return InteractionResult.CONSUME;
}
}

@Nullable
@Override
public MenuProvider getMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) {
return new SimpleMenuProvider((p_52229_, p_52230_, p_52231_) -> {
return new CraftingMenu(p_52229_, p_52230_, ContainerLevelAccess.create(pLevel, pPos));
}, CONTAINER_TITLE);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
package nova.committee.avaritia.common.block.craft;

import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;

/**
* Description:
Expand All @@ -29,26 +13,5 @@ public class CompressedCraftingTableBlock extends AbstractCraftingTable {
public CompressedCraftingTableBlock() {
super(Material.WOOD, SoundType.WOOD, 5F, 100F, true, "compressed_crafting_table");
}

@Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
if (pLevel.isClientSide) {
return InteractionResult.SUCCESS;
} else {
pPlayer.openMenu(getCrafterContainerElement(pPlayer, pLevel, pPos));
return InteractionResult.CONSUME;
}
}

public static MenuProvider getCrafterContainerElement(Player player, Level world, BlockPos pos) {
return new SimpleMenuProvider((p_52229_, p_52230_, p_52231_) -> {
return new CraftingMenu(0, player.getInventory(), ContainerLevelAccess.create(world, pos)) {
@Override
public boolean stillValid(Player playerIn) {
return true;
}
};
}, CONTAINER_TITLE);
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
package nova.committee.avaritia.common.block.craft;

import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;

/**
* Description:
Expand All @@ -30,27 +14,5 @@ public class DoubleCompressedCraftingTableBlock extends AbstractCraftingTable {
public DoubleCompressedCraftingTableBlock() {
super(Material.WOOD, SoundType.WOOD, 20F, 500F, true, "double_compressed_crafting_table");
}

@Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
if (pLevel.isClientSide) {
return InteractionResult.SUCCESS;
} else {
pPlayer.openMenu(getCrafterContainerElement(pPlayer, pLevel, pPos));
return InteractionResult.CONSUME;
}
}

public static MenuProvider getCrafterContainerElement(Player player, Level world, BlockPos pos) {
return new SimpleMenuProvider((p_52229_, p_52230_, p_52231_) -> {
return new CraftingMenu(0, player.getInventory(), ContainerLevelAccess.create(world, pos)) {
@Override
public boolean stillValid(Player playerIn) {
return true;
}
};
}, CONTAINER_TITLE);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> registry = event.getRegistry();

registry.registerAll(
compressed_crafting_table = new CompressedCraftingTableBlock(2.5F),
double_compressed_crafting_table = new DoubleCompressedCraftingTableBlock(20F),
compressed_crafting_table = new CompressedCraftingTableBlock(),
double_compressed_crafting_table = new DoubleCompressedCraftingTableBlock(),
extreme_crafting_table = new ExtremeCraftingTableBlock(),
neutron_collector = new NeutronCollectorBlock(),

neutronium = new ResourceBlock(SoundType.METAL ,"neutronium"),
neutronium = new ResourceBlock(SoundType.METAL, "neutronium"),
infinity = new ResourceBlock(SoundType.METAL, "infinity"),
crystal_matrix = new ResourceBlock(SoundType.GLASS, "crystal_matrix"),
compressor = new CompressorBlock()
Expand Down
35 changes: 3 additions & 32 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,25 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="MIT"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="http://my.issue.tracker/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="avaritia" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="Avaritia" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
displayName="Avaritia-Reforged" #mandatory
#updateJSONURL="http://myurl.me/" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="http://example.com/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="avaritia.png" #optional
# A text field displayed in the mod UI
logoFile="avaritia.png" #optional
#credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors="cnlimiter" #optional
# The description text for the mod (multi line!) (#mandatory)
authors="cnlimiter, Asek3, MikhailTapio" #optional
description='''
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.avaritia]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[40,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.avaritia]]
modId="minecraft"
mandatory=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
{
"parent": "minecraft:block/cube",
"textures": {
"north": "avaritia:blocks/craft/extreme_side",
"east": "avaritia:blocks/craft/extreme_side",
"south": "avaritia:blocks/craft/extreme_side",
"west": "avaritia:blocks/craft/extreme_side",
"up": "avaritia:blocks/craft/extreme_top",
"down": "avaritia:blocks/resource/crystal_matrix",
"particle": "avaritia:blocks/resource/crystal_matrix"
"parent": "minecraft:block/cube",
"credit": "Made with Blockbench",
"textures": {
"1": "avaritia:blocks/craft/extreme_side",
"2": "avaritia:blocks/craft/extreme_top",
"particle": "avaritia:blocks/craft/extreme_clean"
"particle": "avaritia:blocks/resource/crystal_matrix"
},
"elements": [
{
Expand Down
Binary file added src/main/resources/avaritia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 43d673c

Please sign in to comment.