Fix beacon beams for loaded chunks
This commit is contained in:
-21
@@ -218,27 +218,6 @@ public class LodDataBuilder
|
||||
biome = newBiome;
|
||||
blockState = newBlockState;
|
||||
|
||||
// TODO temp
|
||||
if (blockState.getSerialString().contains("beacon"))
|
||||
{
|
||||
int blockX = chunkWrapper.getChunkPos().x * LodUtil.CHUNK_WIDTH + relBlockX;
|
||||
int blockZ = chunkWrapper.getChunkPos().z * LodUtil.CHUNK_WIDTH + relBlockZ;
|
||||
|
||||
if (GenericObjectRenderer.INSTANCE.testBeaconPosSet
|
||||
.add(new DhBlockPos(blockX, y, blockZ)))
|
||||
{
|
||||
IDhApiRenderableBoxGroup beaconBeam = GenericObjectRenderer.INSTANCE.createForSingleBox(
|
||||
new DhApiRenderableBox(
|
||||
new DhApiVec3f(blockX, y+1, blockZ),
|
||||
new DhApiVec3f(blockX+1, 5_000, blockZ+1),
|
||||
Color.WHITE)
|
||||
);
|
||||
beaconBeam.setBlockLight(15);
|
||||
beaconBeam.setSkyLight(15);
|
||||
GenericObjectRenderer.INSTANCE.add(beaconBeam);
|
||||
}
|
||||
}
|
||||
|
||||
mappedId = dataSource.mapping.addIfNotPresentAndGetId(biome, blockState);
|
||||
blockLight = newBlockLight;
|
||||
skyLight = newSkyLight;
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO;
|
||||
import com.seibel.distanthorizons.core.sql.dto.ChunkHashDTO;
|
||||
import com.seibel.distanthorizons.core.sql.repo.BeaconBeamRepo;
|
||||
import com.seibel.distanthorizons.core.sql.repo.ChunkHashRepo;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -247,14 +248,16 @@ public abstract class AbstractDhLevel implements IDhLevel
|
||||
new DhApiVec3f(newBeam.pos.x+1, 2_000, newBeam.pos.z+1),
|
||||
newBeam.color
|
||||
));
|
||||
beamRenderGroupByPos.put(newBeam.pos, beaconBox);
|
||||
beaconBox.setBlockLight(LodUtil.MAX_MC_LIGHT);
|
||||
beaconBox.setSkyLight(LodUtil.MAX_MC_LIGHT);
|
||||
this.beamRenderGroupByPos.put(newBeam.pos, beaconBox);
|
||||
GenericObjectRenderer.INSTANCE.add(beaconBox);
|
||||
}
|
||||
else if (existingBeam != null && newBeam == null)
|
||||
{
|
||||
// beam no longer exists at position, remove
|
||||
this.beaconBeamRepo.deleteWithKey(beaconPos);
|
||||
IDhApiRenderableBoxGroup beaconBox = beamRenderGroupByPos.remove(newBeam.pos);
|
||||
IDhApiRenderableBoxGroup beaconBox = this.beamRenderGroupByPos.remove(existingBeam.pos);
|
||||
if (beaconBox != null)
|
||||
{
|
||||
GenericObjectRenderer.INSTANCE.remove(beaconBox.getId());
|
||||
|
||||
-5
@@ -120,11 +120,6 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
|
||||
private final ReentrantLock mapModifyLock = new ReentrantLock();
|
||||
|
||||
|
||||
// TODO just for testing
|
||||
@Deprecated
|
||||
public final HashSet<DhBlockPos> testBeaconPosSet = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
/** A box from 0,0,0 to 1,1,1 */
|
||||
private static final float[] BOX_VERTICES = {
|
||||
|
||||
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.core.sql.repo;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO;
|
||||
import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -30,6 +31,7 @@ import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -145,7 +147,26 @@ public class BeaconBeamRepo extends AbstractDhRepo<DhBlockPos, BeaconBeamDTO>
|
||||
|
||||
public List<BeaconBeamDTO> getAllBeamsForSectionPos(long pos)
|
||||
{
|
||||
return null;
|
||||
int minBlockX = DhSectionPos.getMinCornerBlockX(pos);
|
||||
int minBlockZ = DhSectionPos.getMinCornerBlockZ(pos);
|
||||
int maxBlockX = minBlockX + DhSectionPos.getBlockWidth(pos);
|
||||
int maxBlockZ = minBlockZ + DhSectionPos.getBlockWidth(pos);
|
||||
|
||||
|
||||
List<Map<String, Object>> objectMapList = this.queryDictionary(
|
||||
"SELECT * " +
|
||||
"FROM "+this.getTableName()+" " +
|
||||
"WHERE " +
|
||||
"BlockPosX >= "+minBlockX+" AND BlockPosX <= "+maxBlockX+" " +
|
||||
"AND BlockPosZ >= "+minBlockZ+" AND BlockPosX <= "+maxBlockZ);
|
||||
|
||||
ArrayList<BeaconBeamDTO> beamList = new ArrayList<>();
|
||||
for (Map<String, Object> objectMap : objectMapList)
|
||||
{
|
||||
beamList.add(this.convertDictionaryToDto(objectMap));
|
||||
}
|
||||
|
||||
return beamList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ public interface IChunkWrapper extends IBindable
|
||||
{
|
||||
DhBlockPos pos = blockPosList.get(i).convertToChunkRelativePos();
|
||||
IBlockStateWrapper block = this.getBlockState(pos);
|
||||
if (block.getSerialString().equalsIgnoreCase("minecraft:beacon"))
|
||||
if (block.getSerialString().toLowerCase().contains("minecraft:beacon"))
|
||||
{
|
||||
BeaconBeamDTO beam = new BeaconBeamDTO(pos, Color.WHITE); // TODO
|
||||
beaconPosList.add(beam);
|
||||
|
||||
Reference in New Issue
Block a user