update to 1.21.4 and add whitelist
This commit is contained in:
parent
3fbb838550
commit
493d9f46e1
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "com.modrinth.minotaur" version "2.+"
|
id "com.modrinth.minotaur" version "2.+"
|
||||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
id 'fabric-loom' version '1.9-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
org.gradle.jvmargs = -Xmx1G
|
org.gradle.jvmargs = -Xmx1G
|
||||||
|
|
||||||
#Fabric properties
|
#Fabric properties
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.4
|
||||||
yarn_mappings=1.21.1+build.3
|
yarn_mappings=1.21.4+build.7
|
||||||
loader_version=0.16.7
|
loader_version=0.16.9
|
||||||
|
|
||||||
# Fabric API
|
# Fabric API
|
||||||
fabric_version=0.105.0+1.21.1
|
fabric_version=0.114.0+1.21.4
|
||||||
|
|
||||||
#Mod properties
|
#Mod properties
|
||||||
mod_version = 0.9.6
|
mod_version = 0.9.7
|
||||||
maven_group = quimufu.structure_item
|
maven_group = quimufu.structure_item
|
||||||
archives_base_name = structure_item
|
archives_base_name = structure_item
|
||||||
|
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
5
gradlew
vendored
5
gradlew
vendored
|
@ -15,6 +15,8 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -84,7 +86,8 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
|
@ -13,6 +13,8 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
|
@ -34,9 +34,8 @@ import java.util.Optional;
|
||||||
import static quimufu.structure_item.StructureItemMod.LOGGER;
|
import static quimufu.structure_item.StructureItemMod.LOGGER;
|
||||||
|
|
||||||
public class MyItem extends Item {
|
public class MyItem extends Item {
|
||||||
static Item.Settings p = new Item.Settings().fireproof().rarity(Rarity.RARE).maxCount(1);
|
|
||||||
|
|
||||||
public MyItem() {
|
public MyItem(Item.Settings p) {
|
||||||
super(p);
|
super(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +89,19 @@ public class MyItem extends Item {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (tag.contains("whitelist", 9)) {
|
||||||
|
texts.add(Text.translatable("item.structure_item.item.tooltip.whitelist"));
|
||||||
|
NbtList bl = tag.getList("whitelist", 8);
|
||||||
|
int i = 0;
|
||||||
|
for (NbtElement entry : bl) {
|
||||||
|
texts.add(Text.literal(" " + entry.asString()));
|
||||||
|
i++;
|
||||||
|
if (i == 4) {
|
||||||
|
texts.add(Text.translatable("item.structure_item.item.tooltip.whitelist.more",
|
||||||
|
Text.literal(String.valueOf(bl.size() - i))));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!tag.contains("replaceEntities", 99) || tag.getBoolean("replaceEntities")) {
|
if (!tag.contains("replaceEntities", 99) || tag.getBoolean("replaceEntities")) {
|
||||||
texts.add(Text.translatable("item.structure_item.item.tooltip.replaceEntities"));
|
texts.add(Text.translatable("item.structure_item.item.tooltip.replaceEntities"));
|
||||||
|
@ -261,6 +273,22 @@ public class MyItem extends Item {
|
||||||
|
|
||||||
}
|
}
|
||||||
ps.forbidOverwrite(blacklist);
|
ps.forbidOverwrite(blacklist);
|
||||||
|
} else if (tag.contains("whitelist", 9)) {
|
||||||
|
NbtList bl = tag.getList("whitelist", 8);
|
||||||
|
List<Block> whitelist = Lists.newArrayList();
|
||||||
|
for (NbtElement b : bl) {
|
||||||
|
Block block = getBlock(b.asString());
|
||||||
|
if (block != null) {
|
||||||
|
whitelist.add(block);
|
||||||
|
} else {
|
||||||
|
Text message =
|
||||||
|
Text.translatable("items.structure.spawner.invalid.block",
|
||||||
|
Text.literal(b.asString()));
|
||||||
|
sendPlayerChat(player, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ps.overwriteOnly(whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class MyPlacementSettings extends StructurePlacementData {
|
public class MyPlacementSettings extends StructurePlacementData {
|
||||||
private List<Block> blacklist;
|
private List<Block> blacklist;
|
||||||
|
private List<Block> whitelist;
|
||||||
private World world;
|
private World world;
|
||||||
private Vec3i size;
|
private Vec3i size;
|
||||||
private boolean replaceEntities = true;
|
private boolean replaceEntities = true;
|
||||||
|
@ -37,6 +38,7 @@ public class MyPlacementSettings extends StructurePlacementData {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blacklist = Lists.newArrayList(blocks);
|
blacklist = Lists.newArrayList(blocks);
|
||||||
|
this.whitelist = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyPlacementSettings setWorld(World w) {
|
public MyPlacementSettings setWorld(World w) {
|
||||||
|
@ -57,6 +59,15 @@ public class MyPlacementSettings extends StructurePlacementData {
|
||||||
this.replaceEntities = replaceEntities;
|
this.replaceEntities = replaceEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void overwriteOnly(List<Block> whitelist) {
|
||||||
|
if (whitelist.isEmpty()) {
|
||||||
|
this.whitelist = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.whitelist = Lists.newArrayList(whitelist);
|
||||||
|
this.blacklist = null;
|
||||||
|
}
|
||||||
|
|
||||||
public class CheckingStructureProcess extends StructureProcessor {
|
public class CheckingStructureProcess extends StructureProcessor {
|
||||||
|
|
||||||
List<? extends Entity> entitiesWithinAABB;
|
List<? extends Entity> entitiesWithinAABB;
|
||||||
|
@ -79,7 +90,10 @@ public class MyPlacementSettings extends StructurePlacementData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Block blockToCheck = world.getBlockState(posToCheck).getBlock();
|
Block blockToCheck = world.getBlockState(posToCheck).getBlock();
|
||||||
if (blacklist.contains(blockToCheck)) {
|
if (blacklist != null && blacklist.contains(blockToCheck)) {
|
||||||
|
throw new PlacementNotAllowedException(blockToCheck.getName(), posToCheck);
|
||||||
|
}
|
||||||
|
if (whitelist != null && !whitelist.contains(blockToCheck)) {
|
||||||
throw new PlacementNotAllowedException(blockToCheck.getName(), posToCheck);
|
throw new PlacementNotAllowedException(blockToCheck.getName(), posToCheck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,13 @@ package quimufu.structure_item;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.Rarity;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -15,12 +20,18 @@ public class StructureItemMod implements ModInitializer {
|
||||||
|
|
||||||
public static final String MOD_ID = "structure_item";
|
public static final String MOD_ID = "structure_item";
|
||||||
public static final String MOD_NAME = "Structure Item Mod (Fabric)";
|
public static final String MOD_NAME = "Structure Item Mod (Fabric)";
|
||||||
public static final Item item = new MyItem();
|
public static final Item ITEM = Items.register(
|
||||||
|
RegistryKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "item")),
|
||||||
|
MyItem::new,
|
||||||
|
new Item.Settings()
|
||||||
|
.fireproof()
|
||||||
|
.rarity(Rarity.RARE)
|
||||||
|
.maxCount(1)
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
log(Level.INFO, "Initializing");
|
log(Level.INFO, "Initializing");
|
||||||
Registry.register(Registries.ITEM, MOD_ID + ":item", item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Level level, String message) {
|
public static void log(Level level, String message) {
|
||||||
|
|
6
src/main/resources/assets/structure_item/items/item.json
Normal file
6
src/main/resources/assets/structure_item/items/item.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "structure_item:item/item"
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,8 @@
|
||||||
"item.structure_item.item.tooltip.dynamic.offset": "Dynamic offset",
|
"item.structure_item.item.tooltip.dynamic.offset": "Dynamic offset",
|
||||||
"item.structure_item.item.tooltip.blacklist": "Blacklist:",
|
"item.structure_item.item.tooltip.blacklist": "Blacklist:",
|
||||||
"item.structure_item.item.tooltip.blacklist.more": " And %s more...",
|
"item.structure_item.item.tooltip.blacklist.more": " And %s more...",
|
||||||
|
"item.structure_item.item.tooltip.whitelist": "Whitelist:",
|
||||||
|
"item.structure_item.item.tooltip.whitelist.more": " And %s more...",
|
||||||
"item.structure_item.item.tooltip.replaceEntities": "Deletes Entities in the way",
|
"item.structure_item.item.tooltip.replaceEntities": "Deletes Entities in the way",
|
||||||
"item.structure_item.item.tooltip.doNotReplaceEntities": "Doesn't allow placement with entities in the way",
|
"item.structure_item.item.tooltip.doNotReplaceEntities": "Doesn't allow placement with entities in the way",
|
||||||
"item.structure_item.item.tooltip.placeEntities": "Places contained Entities",
|
"item.structure_item.item.tooltip.placeEntities": "Places contained Entities",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"parent": "item/handheld",
|
"parent": "minecraft:item/handheld",
|
||||||
"textures": {
|
"textures": {
|
||||||
"layer0": "item/stick"
|
"layer0": "minecraft:item/stick"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user