Skip to content

Commit c30dfd9

Browse files
committed
Merge remote-tracking branch 'origin/structure_block' into structure_block
2 parents eb019f1 + 560ad92 commit c30dfd9

22 files changed

+323
-43
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
44
[![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](https://discord.gg/geysermc)
5-
[![Crowdin](https://badges.crowdin.net/geyser/localized.svg)](https://translate.geysermc.org/)
5+
[![Crowdin](https://badges.crowdin.net/e/51361b7f8a01644a238d0fe8f3bddc62/localized.svg)](https://translate.geysermc.org/)
66

77
Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform.
88

@@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
1414

1515
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
1616

17-
### Currently supporting Minecraft Bedrock 1.20.40 - 1.20.72 and Minecraft Java 1.20.4
17+
### Currently supporting Minecraft Bedrock 1.20.40 - 1.20.73 and Minecraft Java 1.20.4
1818

1919
## Setting Up
2020
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*
22+
* @author GeyserMC
23+
* @link https://github.com/GeyserMC/Geyser
24+
*/
25+
26+
package org.geysermc.geyser.api.event.connection;
27+
28+
import org.checkerframework.checker.nullness.qual.NonNull;
29+
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.geysermc.event.Cancellable;
31+
import org.geysermc.event.Event;
32+
33+
import java.net.InetSocketAddress;
34+
35+
/**
36+
* Called whenever a client attempts to connect to the server, before the connection is accepted.
37+
*/
38+
public final class ConnectionRequestEvent implements Event, Cancellable {
39+
40+
private boolean cancelled;
41+
private final InetSocketAddress ip;
42+
private final InetSocketAddress proxyIp;
43+
44+
public ConnectionRequestEvent(@NonNull InetSocketAddress ip, @Nullable InetSocketAddress proxyIp) {
45+
this.ip = ip;
46+
this.proxyIp = proxyIp;
47+
}
48+
49+
/**
50+
* The IP address of the client attempting to connect
51+
*
52+
* @return the IP address of the client attempting to connect
53+
*/
54+
@NonNull
55+
public InetSocketAddress getInetSocketAddress() {
56+
return ip;
57+
}
58+
59+
/**
60+
* The IP address of the proxy handling the connection. It will return null if there is no proxy.
61+
*
62+
* @return the IP address of the proxy handling the connection
63+
*/
64+
@Nullable
65+
public InetSocketAddress getProxyIp() {
66+
return proxyIp;
67+
}
68+
69+
/**
70+
* The cancel status of this event. If this event is cancelled, the connection will be rejected.
71+
*
72+
* @return the cancel status of this event
73+
*/
74+
@Override
75+
public boolean isCancelled() {
76+
return cancelled;
77+
}
78+
79+
/**
80+
* Sets the cancel status of this event. If this event is canceled, the connection will be rejected.
81+
*
82+
* @param cancelled the cancel status of this event.
83+
*/
84+
@Override
85+
public void setCancelled(boolean cancelled) {
86+
this.cancelled = cancelled;
87+
}
88+
}

api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -161,6 +161,13 @@ default boolean isTool() {
161161
return displayHandheld();
162162
}
163163

164+
/**
165+
* Gets the block the item places.
166+
*
167+
* @return the block the item places
168+
*/
169+
String block();
170+
164171
static NonVanillaCustomItemData.Builder builder() {
165172
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
166173
}
@@ -201,6 +208,8 @@ interface Builder extends CustomItemData.Builder {
201208

202209
Builder chargeable(boolean isChargeable);
203210

211+
Builder block(String block);
212+
204213
/**
205214
* @deprecated Use {@link #displayHandheld(boolean)} instead.
206215
*/

api/src/main/java/org/geysermc/geyser/api/util/CreativeCategory.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -31,11 +31,10 @@
3131
* Represents the creative menu categories or tabs.
3232
*/
3333
public enum CreativeCategory {
34-
COMMANDS("commands", 1),
35-
CONSTRUCTION("construction", 2),
34+
CONSTRUCTION("construction", 1),
35+
NATURE("nature", 2),
3636
EQUIPMENT("equipment", 3),
3737
ITEMS("items", 4),
38-
NATURE("nature", 5),
3938
NONE("none", 6);
4039

4140
private final String internalName;

bootstrap/mod/fabric/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies {
4141

4242
// Let's shade in our own api
4343
shadow(projects.api) { isTransitive = false }
44+
shadow(projects.common) { isTransitive = false }
4445

4546
// Permissions
4647
modImplementation(libs.fabric.permissions)

bootstrap/mod/neoforge/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies {
3131

3232
// Let's shade in our own api
3333
shadow(projects.api) { isTransitive = false }
34+
shadow(projects.common) { isTransitive = false }
3435

3536
// Include all transitive deps of core via JiJ
3637
includeTransitive(projects.core)

core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
import org.geysermc.geyser.network.CIDRMatcher;
4141
import org.geysermc.geyser.text.AsteriskSerializer;
4242
import org.geysermc.geyser.text.GeyserLocale;
43+
import org.geysermc.geyser.util.WebUtils;
4344

4445
import java.io.IOException;
4546
import java.nio.file.Path;
47+
import java.util.ArrayList;
4648
import java.util.Collections;
4749
import java.util.List;
4850
import java.util.UUID;
@@ -233,7 +235,18 @@ public List<CIDRMatcher> getWhitelistedIPsMatchers() {
233235
List<CIDRMatcher> matchers = this.whitelistedIPsMatchers;
234236
if (matchers == null) {
235237
synchronized (this) {
236-
this.whitelistedIPsMatchers = matchers = proxyProtocolWhitelistedIPs.stream()
238+
// Check if proxyProtocolWhitelistedIPs contains URLs we need to fetch and parse by line
239+
List<String> whitelistedCIDRs = new ArrayList<>();
240+
for (String ip: proxyProtocolWhitelistedIPs) {
241+
if (!ip.startsWith("http")) {
242+
whitelistedCIDRs.add(ip);
243+
continue;
244+
}
245+
246+
WebUtils.getLineStream(ip).forEach(whitelistedCIDRs::add);
247+
}
248+
249+
this.whitelistedIPsMatchers = matchers = whitelistedCIDRs.stream()
237250
.map(CIDRMatcher::new)
238251
.collect(Collectors.toList());
239252
}

core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -55,6 +55,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
5555
private final boolean isEdible;
5656
private final boolean canAlwaysEat;
5757
private final boolean isChargeable;
58+
private final String block;
5859

5960
public GeyserNonVanillaCustomItemData(Builder builder) {
6061
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
@@ -78,6 +79,7 @@ public GeyserNonVanillaCustomItemData(Builder builder) {
7879
this.isEdible = builder.edible;
7980
this.canAlwaysEat = builder.canAlwaysEat;
8081
this.isChargeable = builder.chargeable;
82+
this.block = builder.block;
8183
}
8284

8385
@Override
@@ -160,6 +162,11 @@ public boolean isChargeable() {
160162
return isChargeable;
161163
}
162164

165+
@Override
166+
public String block() {
167+
return block;
168+
}
169+
163170
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
164171
private String identifier = null;
165172
private int javaId = -1;
@@ -186,6 +193,7 @@ public static class Builder extends GeyserCustomItemData.Builder implements NonV
186193
private boolean edible = false;
187194
private boolean canAlwaysEat = false;
188195
private boolean chargeable = false;
196+
private String block = null;
189197

190198
@Override
191199
public Builder name(@NonNull String name) {
@@ -339,6 +347,12 @@ public Builder chargeable(boolean isChargeable) {
339347
return this;
340348
}
341349

350+
@Override
351+
public Builder block(String block) {
352+
this.block = block;
353+
return this;
354+
}
355+
342356
@Override
343357
public NonVanillaCustomItemData build() {
344358
if (identifier == null || javaId == -1) {

core/src/main/java/org/geysermc/geyser/item/type/ArmorItem.java

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull Compo
4747
if (tag.get("Trim") instanceof CompoundTag trim) {
4848
StringTag material = trim.remove("material");
4949
StringTag pattern = trim.remove("pattern");
50+
51+
// discard custom trim patterns/materials to prevent visual glitches on bedrock
52+
if (!material.getValue().startsWith("minecraft:")
53+
|| !pattern.getValue().startsWith("minecraft:")) {
54+
tag.remove("Trim");
55+
return;
56+
}
57+
5058
// bedrock has an uppercase first letter key, and the value is not namespaced
5159
trim.put(new StringTag("Material", stripNamespace(material.getValue())));
5260
trim.put(new StringTag("Pattern", stripNamespace(pattern.getValue())));

core/src/main/java/org/geysermc/geyser/network/GameProtocol.java

+24-10
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727

2828
import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
2929
import com.github.steveice10.mc.protocol.codec.PacketCodec;
30+
import io.netty.buffer.ByteBuf;
3031
import org.checkerframework.checker.nullness.qual.Nullable;
3132
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
33+
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
34+
import org.cloudburstmc.protocol.bedrock.codec.v582.serializer.TrimDataSerializer_v582;
3235
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
3336
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
3437
import org.cloudburstmc.protocol.bedrock.codec.v649.Bedrock_v649;
3538
import org.cloudburstmc.protocol.bedrock.codec.v662.Bedrock_v662;
3639
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
40+
import org.cloudburstmc.protocol.bedrock.packet.TrimDataPacket;
3741
import org.geysermc.geyser.session.GeyserSession;
3842

3943
import java.util.ArrayList;
@@ -48,7 +52,7 @@ public final class GameProtocol {
4852
* Default Bedrock codec that should act as a fallback. Should represent the latest available
4953
* release of the game that Geyser supports.
5054
*/
51-
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v662.CODEC;
55+
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = processCodec(Bedrock_v662.CODEC);
5256

5357
/**
5458
* A list of all supported Bedrock versions that can join Geyser
@@ -62,18 +66,18 @@ public final class GameProtocol {
6266
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;
6367

6468
static {
65-
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v622.CODEC.toBuilder()
69+
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v622.CODEC.toBuilder()
6670
.minecraftVersion("1.20.40/1.20.41")
67-
.build());
68-
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v630.CODEC.toBuilder()
71+
.build()));
72+
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v630.CODEC.toBuilder()
6973
.minecraftVersion("1.20.50/1.20.51")
70-
.build());
71-
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v649.CODEC.toBuilder()
74+
.build()));
75+
SUPPORTED_BEDROCK_CODECS.add(processCodec(Bedrock_v649.CODEC.toBuilder()
7276
.minecraftVersion("1.20.60/1.20.62")
73-
.build());
74-
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
75-
.minecraftVersion("1.20.70/1.20.72")
76-
.build());
77+
.build()));
78+
SUPPORTED_BEDROCK_CODECS.add(processCodec(DEFAULT_BEDROCK_CODEC.toBuilder()
79+
.minecraftVersion("1.20.70/1.20.73")
80+
.build()));
7781
}
7882

7983
/**
@@ -164,6 +168,16 @@ public static String getAllSupportedJavaVersions() {
164168
return joiner.toString();
165169
}
166170

171+
private static BedrockCodec processCodec(BedrockCodec codec) {
172+
return codec.toBuilder()
173+
.updateSerializer(TrimDataPacket.class, new TrimDataSerializer_v582() {
174+
@Override
175+
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, TrimDataPacket packet) {
176+
}
177+
})
178+
.build();
179+
}
180+
167181
private GameProtocol() {
168182
}
169183
}

core/src/main/java/org/geysermc/geyser/network/LoggingPacketHandler.java

+5
Original file line numberDiff line numberDiff line change
@@ -891,4 +891,9 @@ public PacketSignal handle(RequestNetworkSettingsPacket packet) {
891891
public PacketSignal handle(ToggleCrafterSlotRequestPacket packet) {
892892
return defaultHandler(packet);
893893
}
894+
895+
@Override
896+
public PacketSignal handle(TrimDataPacket packet) {
897+
return defaultHandler(packet);
898+
}
894899
}

0 commit comments

Comments
 (0)