small test involving jars

This commit is contained in:
Boblet 2022-08-22 16:09:48 +02:00
parent 8e1b32cb42
commit 9c57c73d11
6 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package com.hbm.wiaj;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.profiler.Profiler;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.storage.SaveHandlerMP;
@SideOnly(Side.CLIENT)
public class FauxWorld extends World {
public FauxWorld(String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_) {
super(new SaveHandlerMP(), "FauxWorld", p_i45368_3_, p_i45368_4_, p_i45368_5_);
}
@Override
protected IChunkProvider createChunkProvider() {
return null;
}
@Override
protected int func_152379_p() {
return 0;
}
@Override
public Entity getEntityByID(int id) {
return null;
}
}

View File

@ -0,0 +1,8 @@
package com.hbm.wiaj;
import net.minecraft.client.gui.GuiScreen;
//krass
public class GuiWorldInAJar extends GuiScreen {
}

View File

@ -0,0 +1,6 @@
package com.hbm.wiaj;
public interface ITileActorRenderer {
public void renderActor(Object... data);
}

View File

@ -0,0 +1,109 @@
package com.hbm.wiaj;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
/**
* A hastily put together implementation of IBlockAccess in order to render things using ISBRH...
* It can handle blocks, and not a whole lot else.
* @author hbm
*/
public class WorldInAJar implements IBlockAccess {
private int sizeX;
private int sizeY;
private int sizeZ;
private Block[][][] blocks;
private short[][][] meta;
private TileEntity[][][] tiles;
public WorldInAJar(int x, int y, int z) {
this.sizeX = x;
this.sizeY = y;
this.sizeZ = z;
this.blocks = new Block[x][y][z];
this.meta = new short[x][y][z];
this.tiles = new TileEntity[x][y][z];
}
@Override
public Block getBlock(int x, int y, int z) {
if(x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ)
return Blocks.air;
return this.blocks[x][y][z] != null ? this.blocks[x][y][z] : Blocks.air;
}
public void setBlock(int x, int y, int z, Block b, int meta) {
if(x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ)
return;
this.blocks[x][y][z] = b;
this.meta[x][y][z] = (short) Math.abs(meta % 16);
}
@Override
public int getBlockMetadata(int x, int y, int z) {
if(x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ)
return 0;
return this.meta[x][y][z];
}
//shaky, we may kick tile entities entirely and rely on outside-the-world tile actors for rendering
//might still come in handy for manipulating things using dummy tiles, like cable connections
@Override
public TileEntity getTileEntity(int x, int y, int z) {
if(x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ)
return null;
TileEntity tile = this.tiles[x][y][z];
return null;
}
//always render fullbright, if the situation requires it we could add a very rudimentary system that
//darkens blocks id there is a solid one above
@Override
public int getLightBrightnessForSkyBlocks(int x, int y, int z, int blockBrightness) {
return 15; //always be on fullbright
}
//redstone could theoretically be implemented, but we will wait for now
@Override
public int isBlockProvidingPowerTo(int x, int y, int z, int dir) {
return 0;
}
@Override
public boolean isAirBlock(int x, int y, int z) {
return this.getBlock(x, y, z).isAir(this, x, y, z);
}
//biomes don't matter to us, if the situation requires it we could implement a primitive biome mask
@Override
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
return BiomeGenBase.plains;
}
@Override
public int getHeight() {
return this.sizeY;
}
@Override
public boolean extendedLevelsInChunkCache() {
return false;
}
@Override
public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) {
return getBlock(x, y, z).isSideSolid(this, x, y, z, side);
}
}

View File

@ -0,0 +1,31 @@
package com.hbm.wiaj.actions;
import com.hbm.wiaj.WorldInAJar;
import net.minecraft.block.Block;
public class ActionSetBlock implements IWorldAction {
int x;
int y;
int z;
Block b;
int meta;
public ActionSetBlock(int x, int y, int z, Block b) {
this(x, y, z, b, 0);
}
public ActionSetBlock(int x, int y, int z, Block b, int meta) {
this.x = x;
this.y = y;
this.z = z;
this.b = b;
this.meta = meta;
}
@Override
public void act(WorldInAJar world) {
world.setBlock(x, y, z, b, meta);
}
}

View File

@ -0,0 +1,8 @@
package com.hbm.wiaj.actions;
import com.hbm.wiaj.WorldInAJar;
public interface IWorldAction {
public void act(WorldInAJar world);
}