Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

1.13.1 #50

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ repositories {
maven { url 'https://libraries.minecraft.net/' }
maven { url 'https://www.dimdev.org/maven/' }
maven { url = 'https://repo.spongepowered.org/maven/' }
mavenLocal()
}

dependencies {
Expand All @@ -43,7 +44,7 @@ dependencies {
}

minecraft {
version = '1.13'
version = '1.13.1'
mappings = 'snapshot_20180908'
runDir = 'run'
tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.world.gen.ChunkGeneratorType;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.IChunkGeneratorFactory;

import javax.annotation.Nullable;
import java.util.function.Supplier;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/dimdev/rift/listener/MessageAdder.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.dimdev.rift.listener;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.util.registry.IRegistry;
import org.dimdev.rift.network.Message;

public interface MessageAdder {
void registerMessages(RegistryNamespaced<ResourceLocation, Class<? extends Message>> registry);
void registerMessages(IRegistry<Class<? extends Message>> registry);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MixinDimensionType {
private static HashMap<Integer, DimensionType> dimensionTypes = new HashMap<>();

static {
for (DimensionType dimensionType : DimensionType.values()) {
for (DimensionType dimensionType : DimensionType.func_212681_b()) {
dimensionTypes.put(dimensionType.getId(), dimensionType);
}

Expand Down
38 changes: 15 additions & 23 deletions src/main/java/org/dimdev/rift/mixin/hook/MixinMinecraftServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.storage.WorldSavedDataStorage;
import org.dimdev.rift.listener.DataPackFinderAdder;
import org.dimdev.rift.listener.ServerTickable;
import org.dimdev.riftloader.RiftLoader;
Expand All @@ -33,14 +34,15 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

@Mixin(MinecraftServer.class)
public abstract class MixinMinecraftServer {
@Shadow @Final private ResourcePackList<ResourcePackInfo> resourcePacks;
@Shadow @Final public Profiler profiler;
@Shadow public abstract void convertMapIfNeeded(String p_convertMapIfNeeded_1_);
@Shadow public WorldServer[] worlds;
@Shadow public long[][] timeOfLastDimensionTick;
@Shadow public Map<DimensionType, WorldServer> worlds;
@Shadow public Map<DimensionType, long[]> timeOfLastDimensionTick;
@Shadow public abstract ISaveFormat getActiveAnvilConverter();
@Shadow public abstract void setResourcePackFromWorld(String p_setResourcePackFromWorld_1_, ISaveHandler p_setResourcePackFromWorld_2_);
@Shadow public abstract String getFolderName();
Expand All @@ -49,7 +51,6 @@ public abstract class MixinMinecraftServer {
@Shadow public abstract boolean canStructuresSpawn();
@Shadow public abstract boolean isHardcore();
@Shadow public abstract void func_195560_a(File p_195560_1_, WorldInfo p_195560_2_);
@Shadow public abstract void initialWorldChunkLoad();
@Shadow public abstract void setDifficultyForAllWorlds(EnumDifficulty p_setDifficultyForAllWorlds_1_);
@Shadow public abstract CustomBossEvents getCustomBossEvents();
@Shadow public abstract PlayerList getPlayerList();
Expand Down Expand Up @@ -101,9 +102,9 @@ public void loadAllWorlds(String saveName, String worldName, long seed, WorldTyp
func_195560_a(saveHandler.getWorldDirectory(), worldInfo);

// Create overworld
WorldServer overworld = isDemo() ? new WorldServerDemo((MinecraftServer) (Object) this, saveHandler, worldInfo, 0, profiler)
: new WorldServer((MinecraftServer) (Object) this, saveHandler, worldInfo, 0, profiler);
overworld.init();
WorldServer overworld = isDemo() ? new WorldServerDemo((MinecraftServer) (Object) this, saveHandler, new WorldSavedDataStorage(saveHandler), worldInfo, DimensionType.OVERWORLD, profiler)
: new WorldServer((MinecraftServer) (Object) this, saveHandler, new WorldSavedDataStorage(saveHandler), worldInfo, DimensionType.OVERWORLD, profiler);
overworld.func_212251_i__();

overworld.initialize(worldSettings);
overworld.addEventListener(new ServerWorldEventHandler((MinecraftServer) (Object) this, overworld));
Expand Down Expand Up @@ -132,8 +133,8 @@ public void loadAllWorlds(String saveName, String worldName, long seed, WorldTyp
for (DimensionType dimensionType : dimensionTypes) {
dimensionIdToWorldIndex.put(dimensionType.getId(), worldList.size());
dimensionTypeToWorldIndex.put(dimensionType, worldList.size());
WorldServerMulti world = new WorldServerMulti((MinecraftServer) (Object) this, saveHandler, dimensionType.getId(), overworld, profiler);
world.init();
WorldServerMulti world = new WorldServerMulti((MinecraftServer) (Object) this, saveHandler, dimensionType, overworld, profiler);
world.func_212251_i__();
world.addEventListener(new ServerWorldEventHandler((MinecraftServer) (Object) this, world));
if (!isSinglePlayer()) {
world.getWorldInfo().setGameType(getGameType());
Expand All @@ -143,19 +144,20 @@ public void loadAllWorlds(String saveName, String worldName, long seed, WorldTyp
}

// Initialize other things
worlds = worldList.toArray(new WorldServer[0]);
timeOfLastDimensionTick = new long[worlds.length][100];
worlds = new HashMap<>();
worldList.forEach(worldServer -> worlds.put(worldServer.dimension.getType(), worldServer));

getPlayerList().setPlayerManager(worlds);
timeOfLastDimensionTick = new HashMap<>();
worldList.forEach(worldServer -> timeOfLastDimensionTick.put(worldServer.dimension.getType(), new long[100]));

getPlayerList().func_212504_a(worlds.get(DimensionType.OVERWORLD));
if (worldInfo.getCustomBossEvents() != null) {
getCustomBossEvents().read(worldInfo.getCustomBossEvents());
}

if (overworld.getWorldInfo().getDifficulty() == null) {
setDifficultyForAllWorlds(getInitialDifficulty());
}

// initialWorldChunkLoad();
}

protected WorldSettings getWorldSettings(@Nullable WorldInfo worldInfo, long seed, WorldType worldType, JsonElement generatorOptions) {
Expand All @@ -178,14 +180,4 @@ protected WorldSettings getWorldSettings(@Nullable WorldInfo worldInfo, long see
protected EnumDifficulty getInitialDifficulty() {
return getDifficulty();
}

@Overwrite
public WorldServer getWorld(DimensionType dimensionType) {
return worlds[dimensionTypeToWorldIndex.get(dimensionType)];
}

@Overwrite
public WorldServer getWorld(int dimensionId) {
return worlds[dimensionIdToWorldIndex.get(dimensionId)];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ private void handleModCustomPayload(CPacketCustomPayload packet, CallbackInfo ci
}
}

if(Message.REGISTRY.isEmpty()){
return;
}

Class<? extends Message> messageClass = Message.REGISTRY.get(channelName);
if (messageClass != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.datafix.DataFixesManager;
import net.minecraft.util.datafix.TypeReferences;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.RegistryNamespaced;
import org.apache.logging.log4j.Logger;
import org.dimdev.rift.listener.TileEntityTypeAdder;
Expand All @@ -22,7 +23,6 @@
@Mixin(TileEntityType.class)
public abstract class MixinTileEntityType {
@Shadow @Final private static Logger LOGGER;
@Shadow @Final public static RegistryNamespaced<ResourceLocation, TileEntityType<?>> REGISTRY;

@Overwrite
public static <T extends TileEntity> TileEntityType<T> registerTileEntityType(String id, TileEntityType.Builder<T> builder) {
Expand All @@ -35,7 +35,7 @@ public static <T extends TileEntity> TileEntityType<T> registerTileEntityType(St
}

TileEntityType<T> tileEntityType = builder.build(dataFixerType);
REGISTRY.put(new ResourceLocation(id), tileEntityType);
IRegistry.field_212626_o.put(new ResourceLocation(id), tileEntityType);
return tileEntityType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ private void handleModCustomPayload(SPacketCustomPayload packet, CallbackInfo ci
}
}

if(Message.REGISTRY.isEmpty()){
return;
}

Class<? extends Message> messageClass = Message.REGISTRY.get(channelName);
if (messageClass != null) {
try {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/dimdev/rift/network/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.world.WorldServer;
import org.dimdev.rift.util.RegistryUtil;

import java.util.function.Predicate;

public abstract class Message {
public static final RegistryNamespaced<ResourceLocation, Class<? extends Message>> REGISTRY = new RegistryNamespaced<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the "message" string not be namespaced?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be better, I wasn't sure if it was best to add a new class or use mixin's to add the method straight to IRegistry

public static final IRegistry<Class<? extends Message>> REGISTRY = RegistryUtil.createRegistry(new ResourceLocation("rift", "message"), new RegistryNamespaced());

public abstract void write(PacketBuffer buffer);

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/dimdev/rift/util/RegistryUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.dimdev.rift.util;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;

public class RegistryUtil {

public static <T> IRegistry<T> createRegistry(ResourceLocation resourceLocation, IRegistry<T> registry) {
IRegistry.field_212617_f.put(resourceLocation, registry);
return registry;
}

}
2 changes: 1 addition & 1 deletion src/main/resources/access_transformations.at
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public class bms$a # net.minecraft.world.gen.ChunkGeneratorType$Settings
public class bmu # net.minecraft.world.chunk.ChunkStatus
public method bwp b (Ljava/lang/Class;Ljava/lang/String;)V registerStructure # net.minecraft.world.gen.feature.structure.StructureIO/registerStructure
public method bwp a (Ljava/lang/Class;Ljava/lang/String;)V # net.minecraft.world.gen.feature.structure.StructureIO/registerStructure
public field aqz g [I # net.minecraft.item.ArmorMaterial/MAX_DAMAGE_ARRAY
public field arc g [I # net.minecraft.item.ArmorMaterial/MAX_DAMAGE_ARRAY