update to minecraft 1.16.5

This commit is contained in:
QuImUfu 2021-03-31 22:10:05 +02:00
parent 148bd5b6ad
commit 9162bfb48c
4 changed files with 31 additions and 36 deletions

View File

@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.2.6-SNAPSHOT'
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'maven-publish'
}
@ -19,7 +19,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
processResources {
@ -76,4 +76,4 @@ publishing {
// uncomment to publish to the local maven
// mavenLocal()
}
}
}

View File

@ -1,14 +1,15 @@
org.gradle.jvmargs = -Xmx1G
#Fabric properties
minecraft_version = 1.15.2
yarn_mappings = 1.15.2+build.15
loader_version = 0.8.2+build.194
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.6
loader_version=0.11.3
#Fabric api
fabric_version=0.32.5+1.16
#Mod properties
mod_version = 0.7.0
mod_version = 0.8.0
maven_group = quimufu.structure_item
archives_base_name = structure_item
#Dependencies
fabric_api_version = 0.5.1+build.294-1.15

View File

@ -1,17 +1,13 @@
package quimufu.structure_item;
import com.google.common.collect.Lists;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.datafixer.NbtOps;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.*;
import net.minecraft.network.MessageType;
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
@ -53,8 +49,8 @@ public class MyItem extends Item {
texts.add(new TranslatableText("item.structure_item.item.tooltip.allowed.on"));
texts.add(new LiteralText(" " + tag.getString("allowedOn")));
}
if (tag.contains("offset")) {
BlockPos offset = BlockPos.deserialize(new Dynamic<Tag>(NbtOps.INSTANCE, tag.get("offset")));
if (tag.contains("offset", 10)) {
BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
texts.add(new TranslatableText("item.structure_item.item.tooltip.fixed.offset"));
Text c = new TranslatableText("item.structure_item.item.tooltip.xyz",
new LiteralText(String.valueOf(offset.getX())),
@ -145,8 +141,8 @@ public class MyItem extends Item {
}
BlockPos loc = c.getBlockPos().offset(c.getSide());
if (tag.contains("offset")) {
BlockPos offset = BlockPos.deserialize(new Dynamic<Tag>(NbtOps.INSTANCE, tag.get("offset")));
if (tag.contains("offset", 10)) {
BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
loc = loc.add(offset);
} else if (c.getPlayer() != null) {
Direction direction = Direction.getEntityFacingOrder(c.getPlayer())[0];
@ -176,11 +172,11 @@ public class MyItem extends Item {
}
ps.setWorld(c.getWorld())
.setSize(x.getSize())
.setMirrored(BlockMirror.NONE)
.setMirror(BlockMirror.NONE)
.setRotation(BlockRotation.NONE)
.setChunkPosition(null);
boolean succes = x.method_15172(c.getWorld(), loc, ps, 2);
if (succes) {
boolean success = x.place((ServerWorld)c.getWorld(), loc, loc, ps, c.getWorld().getRandom(), 2);
if (success) {
c.getStack().decrement(1);
return ActionResult.SUCCESS;
}
@ -204,8 +200,8 @@ public class MyItem extends Item {
private static void sendPlayerChat(ServerPlayerEntity player, Text message) {
if (player != null)
player.sendChatMessage(message, MessageType.SYSTEM);
LOGGER.info(message.asFormattedString());
player.sendMessage(message, false);
LOGGER.info(message.asString());
}
private BlockPos getDirectionalOffset(Direction direction, BlockPos size) {

View File

@ -7,7 +7,6 @@ import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import java.util.ArrayList;
@ -18,13 +17,12 @@ public class MyPlacementSettings extends StructurePlacementData {
private World world;
private BlockPos size;
public MyPlacementSettings forbidOverwrite(List<Block> blocks) {
public void forbidOverwrite(List<Block> blocks) {
if (blocks.size() == 0) {
blacklist = null;
return this;
return;
}
blacklist = Lists.newArrayList(blocks);
return this;
}
public MyPlacementSettings setWorld(World w) {
@ -38,16 +36,16 @@ public class MyPlacementSettings extends StructurePlacementData {
}
@Override
public List<Structure.StructureBlockInfo> method_15121(List<List<Structure.StructureBlockInfo>> blocks, BlockPos pos) {
public Structure.PalettedBlockInfoList getRandomBlockInfos(List<Structure.PalettedBlockInfoList> blocks, BlockPos pos) {
if (world == null || pos == null || size == null) {
return super.method_15121(blocks, pos);
return super.getRandomBlockInfos(blocks, pos);
}
List<List<Structure.StructureBlockInfo>> eligibleStructures = new ArrayList<>();
List<Structure.PalettedBlockInfoList> eligibleStructures = new ArrayList<>();
if (blacklist == null) {
eligibleStructures = blocks;
} else {
for (List<Structure.StructureBlockInfo> struct : blocks) {
for (Structure.PalettedBlockInfoList struct : blocks) {
if (isValid(struct, pos)) {
eligibleStructures.add(struct);
}
@ -55,24 +53,24 @@ public class MyPlacementSettings extends StructurePlacementData {
}
if (eligibleStructures.size() == 0)
setIgnoreEntities(true);
List<Structure.StructureBlockInfo> locs = super.method_15121(eligibleStructures, pos);
Structure.PalettedBlockInfoList randomBlockInfos = super.getRandomBlockInfos(eligibleStructures, pos);
List<Structure.StructureBlockInfo> locs = randomBlockInfos.getAll();
if (!locs.isEmpty()) {
List<Entity> entitiesWithinAABB = world.getNonSpectatingEntities(Entity.class, new Box(pos,pos.add(size)));
for (Structure.StructureBlockInfo blockInfo : locs) {
BlockPos posToClean = blockInfo.pos.add(pos);
for (Entity e : entitiesWithinAABB) {
e.getBoundingBox().contains(new Vec3d(posToClean));
if (e.getBoundingBox().intersects(new Box(posToClean))) {
e.remove();
}
}
}
}
return locs;
return randomBlockInfos;
}
private boolean isValid(List<Structure.StructureBlockInfo> struct, BlockPos pos) {
for (Structure.StructureBlockInfo bi : struct) {
private boolean isValid(Structure.PalettedBlockInfoList struct, BlockPos pos) {
for (Structure.StructureBlockInfo bi : struct.getAll()) {
BlockPos posToCheck = bi.pos.add(pos);
if (World.isValid(posToCheck)) {
Block blockToCheck = world.getBlockState(posToCheck).getBlock();