NEVER TELL ME THE RULES
This commit is contained in:
parent
64be11775f
commit
926721b349
3 changed files with 130 additions and 6 deletions
|
@ -0,0 +1,27 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.utils;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class FakePlayer extends Player {
|
||||||
|
|
||||||
|
public FakePlayer(Level lvl, BlockPos blockPos) {
|
||||||
|
super(lvl, blockPos, 0, new GameProfile(UUID.randomUUID(), "DigitalInterfaceFakePlayer"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpectator() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCreative() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -758,6 +759,11 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
|
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the skin of the TARDIM
|
||||||
|
* @param skin Skin name to change to
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
@LuaFunction(mainThread = true)
|
@LuaFunction(mainThread = true)
|
||||||
public final void setSkin(String skin) throws LuaException {
|
public final void setSkin(String skin) throws LuaException {
|
||||||
if (this.tileEntity.getLevel().isClientSide()) {
|
if (this.tileEntity.getLevel().isClientSide()) {
|
||||||
|
@ -785,13 +791,39 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skinToApply == null) {
|
if (skinToApply == null) {
|
||||||
throw new LuaException("Skin" + skin + "' not found");
|
throw new LuaException("Skin '" + skin + "' not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
TardimData.Location loc = data.getCurrentLocation();
|
TardimData.Location loc = data.getCurrentLocation();
|
||||||
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
|
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
|
||||||
data.setIdentifier(skinToApply);
|
data.setIdentifier(skinToApply);
|
||||||
|
|
||||||
//TardimRegistry.getTardimBuilder(skinToApply).changeTardimSkin(data, level, loc.getPos(), loc.getFacing(), player);
|
// FakePlayer...
|
||||||
|
TardimRegistry.getTardimBuilder(skinToApply).changeTardimSkin(data, level, loc.getPos(), loc.getFacing(), new FakePlayer(this.tileEntity.getLevel(), this.tileEntity.getPos()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all available TARDIM skins. Useful for making a GUI skin selection.
|
||||||
|
*
|
||||||
|
* @return ObjectLuaTable of the available skins
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getSkins() throws LuaException {
|
||||||
|
if (this.tileEntity.getLevel().isClientSide()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, String> skins = new HashMap<>();
|
||||||
|
|
||||||
|
Iterator var5 = TardimRegistry.getRegistry().keySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while(var5.hasNext()) {
|
||||||
|
ResourceLocation builder = (ResourceLocation)var5.next();
|
||||||
|
TardimRegistry.TardimBuilder b = TardimRegistry.getTardimBuilder(builder);
|
||||||
|
skins.put(i + 1, b.getDisplayName());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ObjectLuaTable(skins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,20 +24,17 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
import dan200.computercraft.api.lua.ObjectLuaTable;
|
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
|
||||||
// TODO: Fabric and Forge diffirence? (Bottom: Fabric)
|
|
||||||
import com.swdteam.tardim.TardimData;
|
import com.swdteam.tardim.TardimData;
|
||||||
import com.swdteam.tardim.TardimManager;
|
import com.swdteam.tardim.TardimManager;
|
||||||
import com.swdteam.tardim.TardimData.Location;
|
import com.swdteam.tardim.TardimData.Location;
|
||||||
import com.swdteam.common.init.TardimRegistry;
|
import com.swdteam.common.init.TardimRegistry;
|
||||||
//import com.swdteam.tardim.tardim.TardimManager;
|
|
||||||
//import com.swdteam.tardim.tardim.TardimData;
|
|
||||||
|
|
||||||
import com.swdteam.common.command.tardim.CommandTravel;
|
import com.swdteam.common.command.tardim.CommandTravel;
|
||||||
import com.swdteam.common.data.DimensionMapReloadListener;
|
import com.swdteam.common.data.DimensionMapReloadListener;
|
||||||
import com.swdteam.common.init.TRDSounds;
|
import com.swdteam.common.init.TRDSounds;
|
||||||
import com.swdteam.common.item.ItemTardim;
|
import com.swdteam.common.item.ItemTardim;
|
||||||
import com.swdteam.main.Tardim;
|
import com.swdteam.main.Tardim;
|
||||||
|
|
||||||
|
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -748,4 +745,72 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
);
|
);
|
||||||
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
|
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the skin of the TARDIM
|
||||||
|
* @param skin Skin name to change to
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final void setSkin(String skin) throws LuaException {
|
||||||
|
if (this.tileEntity.getLevel().isClientSide()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TardimData data = getTardimData();
|
||||||
|
|
||||||
|
ResourceLocation skinToApply = null;
|
||||||
|
Iterator var13 = TardimRegistry.getRegistry().keySet().iterator();
|
||||||
|
|
||||||
|
label39: {
|
||||||
|
ResourceLocation builder;
|
||||||
|
TardimRegistry.TardimBuilder b;
|
||||||
|
do {
|
||||||
|
if (!var13.hasNext()) {
|
||||||
|
break label39;
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = (ResourceLocation)var13.next();
|
||||||
|
b = TardimRegistry.getTardimBuilder(builder);
|
||||||
|
} while(!b.getDisplayName().equalsIgnoreCase(skin) && !builder.toString().equalsIgnoreCase(skin));
|
||||||
|
|
||||||
|
skinToApply = builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skinToApply == null) {
|
||||||
|
throw new LuaException("Skin '" + skin + "' not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
TardimData.Location loc = data.getCurrentLocation();
|
||||||
|
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
|
||||||
|
data.setIdentifier(skinToApply);
|
||||||
|
|
||||||
|
// FakePlayer...
|
||||||
|
TardimRegistry.getTardimBuilder(skinToApply).changeTardimSkin(data, level, loc.getPos(), loc.getFacing(), new FakePlayer(this.tileEntity.getLevel(), this.tileEntity.getPos()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all available TARDIM skins. Useful for making a GUI skin selection.
|
||||||
|
*
|
||||||
|
* @return ObjectLuaTable of the available skins
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getSkins() throws LuaException {
|
||||||
|
if (this.tileEntity.getLevel().isClientSide()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, String> skins = new HashMap<>();
|
||||||
|
|
||||||
|
Iterator var5 = TardimRegistry.getRegistry().keySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while(var5.hasNext()) {
|
||||||
|
ResourceLocation builder = (ResourceLocation)var5.next();
|
||||||
|
TardimRegistry.TardimBuilder b = TardimRegistry.getTardimBuilder(builder);
|
||||||
|
skins.put(i + 1, b.getDisplayName());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ObjectLuaTable(skins);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue