mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 04:32:15 +00:00
Setup and import of 1.16 YEET
This commit is contained in:
931 files changed
+18847
-9127
No files matched your search
@@ -29,7 +29,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -66,7 +65,7 @@ public class BlockSnapshot
|
||||
public BlockSnapshot(IWorld world, BlockPos pos, BlockState state, @Nullable CompoundNBT nbt)
|
||||
{
|
||||
this.setWorld(world);
|
||||
this.dimId = world.getDimension().getType().getId();
|
||||
this.dimId = 0; //world.getDimension().getType().getId(); //TODO
|
||||
this.pos = pos.toImmutable();
|
||||
this.setReplacedBlock(state);
|
||||
this.registryName = state.getBlock().getRegistryName();
|
||||
@@ -74,7 +73,7 @@ public class BlockSnapshot
|
||||
this.nbt = nbt;
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta());
|
||||
System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo()/*TODO .getWorldName()*/, pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +135,8 @@ public class BlockSnapshot
|
||||
IWorld world = this.world != null ? this.world.get() : null;
|
||||
if (world == null)
|
||||
{
|
||||
world = ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.getById(getDimId()));
|
||||
//TODO
|
||||
//world = ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.getById(getDimId()));
|
||||
this.world = new WeakReference<IWorld>(world);
|
||||
}
|
||||
return world;
|
||||
@@ -154,7 +154,7 @@ public class BlockSnapshot
|
||||
@Nullable
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return getNbt() != null ? TileEntity.create(getNbt()) : null;
|
||||
return getNbt() != null ? TileEntity.func_235657_b_(getReplacedBlock(), getNbt()) : null;
|
||||
}
|
||||
|
||||
public boolean restore()
|
||||
@@ -201,14 +201,14 @@ public class BlockSnapshot
|
||||
te = world.getTileEntity(pos);
|
||||
if (te != null)
|
||||
{
|
||||
te.read(getNbt());
|
||||
te.func_230337_a_(getReplacedBlock(), getNbt());
|
||||
te.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][State: %s ][Block: %s ][TileEntity: %s ][force: %s ][notifyNeighbors: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced, replaced.getBlock().delegate.name(), te, force, notifyNeighbors);
|
||||
System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][State: %s ][Block: %s ][TileEntity: %s ][force: %s ][notifyNeighbors: %s]", world.getWorldInfo()/*TODO .getWorldName()*/, pos.getX(), pos.getY(), pos.getZ(), replaced, replaced.getBlock().delegate.name(), te, force, notifyNeighbors);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,14 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.PlayerInteractionManager;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
//Preliminary, simple Fake Player class
|
||||
public class FakePlayer extends ServerPlayerEntity
|
||||
{
|
||||
@@ -45,9 +47,10 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
super(world.getServer(), world, name, new PlayerInteractionManager(world));
|
||||
}
|
||||
|
||||
@Override public Vec3d getPositionVector(){ return new Vec3d(0, 0, 0); }
|
||||
@Override public Vector3d getPositionVec(){ return new Vector3d(0, 0, 0); }
|
||||
@Override public BlockPos func_233580_cy_(){ return BlockPos.ZERO; }
|
||||
@Override public void sendStatusMessage(ITextComponent chatComponent, boolean actionBar){}
|
||||
@Override public void sendMessage(ITextComponent component) {}
|
||||
@Override public void sendMessage(ITextComponent component, UUID p_145747_2_) {}
|
||||
@Override public void addStat(Stat par1StatBase, int par2){}
|
||||
//@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
|
||||
@Override public boolean isInvulnerableTo(DamageSource source){ return true; }
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.function.Function;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,35 +21,36 @@ package net.minecraftforge.common.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.TagCollection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ReverseTagWrapper<T>
|
||||
{
|
||||
private final T target;
|
||||
private final IntSupplier genSupplier;
|
||||
private final Supplier<TagCollection<T>> colSupplier;
|
||||
|
||||
private int generation = -1;
|
||||
//This map is immutable we track its identity change.
|
||||
private Map<ResourceLocation, ITag<T>> colCache;
|
||||
private Set<ResourceLocation> cache = null;
|
||||
|
||||
public ReverseTagWrapper(T target, IntSupplier genSupplier, Supplier<TagCollection<T>> colSupplier)
|
||||
public ReverseTagWrapper(T target, Supplier<TagCollection<T>> colSupplier)
|
||||
{
|
||||
this.target = target;
|
||||
this.genSupplier = genSupplier;
|
||||
this.colSupplier = colSupplier;
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getTagNames()
|
||||
{
|
||||
if (cache == null || generation != genSupplier.getAsInt())
|
||||
TagCollection<T> collection = colSupplier.get();
|
||||
if (cache == null || colCache != collection.getTagMap()) // Identity equals.
|
||||
{
|
||||
this.cache = Collections.unmodifiableSet(new HashSet<>(colSupplier.get().getOwningTags(target)));
|
||||
this.generation = genSupplier.getAsInt();
|
||||
this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getOwningTags(target)));
|
||||
this.colCache = collection.getTagMap();
|
||||
}
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ package net.minecraftforge.common.util;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
public class WorldCapabilityData extends WorldSavedData
|
||||
@@ -68,7 +67,7 @@ public class WorldCapabilityData extends WorldSavedData
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCapabilities(Dimension provider, INBTSerializable<CompoundNBT> capabilities)
|
||||
public void setCapabilities(INBTSerializable<CompoundNBT> capabilities)
|
||||
{
|
||||
this.serializable = capabilities;
|
||||
if (this.capNBT != null && serializable != null)
|
||||
|
||||
Reference in new issue
Block a user