Bausystem geht™️

This commit is contained in:
2024-11-27 19:06:30 +01:00
parent 510aec048b
commit 313d63e99d
20 changed files with 184 additions and 40 deletions
@@ -0,0 +1,44 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.core;
import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.syncher.DataWatcher;
import java.util.ArrayList;
public class ChatWrapper21 implements ChatWrapper {
@Override
public Object stringToChatComponent(String text) {
return IChatMutableComponent.a(LiteralContents.a(text));
}
@Override
public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) {
ArrayList<DataWatcher.c<?>> nativeWatchers = new ArrayList<>(1);
for(int i = 0; i < dataWatcherKeyValues.length; i+=2) {
nativeWatchers.add(((DataWatcher.Item<?>) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e());
}
return new PacketPlayOutEntityMetadata(entityId, nativeWatchers);
}
}
@@ -0,0 +1,41 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.world.level.World;
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.lighting.LevelLightEngine;
import org.bukkit.entity.Player;
public class CraftbukkitWrapper21 implements CraftbukkitWrapper.ICraftbukkitWrapper {
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle", ChunkStatus.class);
private static final Reflection.MethodInvoker getLightEngine = Reflection.getTypedMethod(World.class, null, LevelLightEngine.class);
@Override
public void sendChunk(Player p, int chunkX, int chunkZ) {
Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n);
TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true));
}
}
@@ -19,8 +19,11 @@
package de.steamwar.core;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.InventoryView;
public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
@Override
@@ -32,4 +35,19 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
public Enchantment getUnbreakingEnchantment() {
return Enchantment.UNBREAKING;
}
@Override
public Material getTurtleScute() {
return Material.TURTLE_SCUTE;
}
@Override
public Particle getVillagerHappyParticle() {
return Particle.HAPPY_VILLAGER;
}
@Override
public String getInventoryTitle(InventoryView view) {
return view.getTitle();
}
}