use of com.minecolonies.structures.helpers.Structure in project minecolonies by Minecolonies.
the class RenderUtils method renderSigns.
/**
* Render informal signs at the citizen.
*
* @param clientWorld the client world.
* @param partialTicks the partial ticks.
* @param citizenDataView the citizen data.
* @param player the player.
* @param citizen the citizen position
*/
public static void renderSigns(final WorldClient clientWorld, final float partialTicks, final CitizenDataView citizenDataView, final EntityPlayer player, final BlockPos citizen) {
final Block block = ModBlocks.blockInfoPoster;
final BlockPos vector = citizen.subtract(player.getPosition());
final EnumFacing facing = EnumFacing.getFacingFromVector(vector.getX(), 0, vector.getZ()).getOpposite();
final BlockPos pos = citizen.up(2).offset(facing);
final IBlockState iblockstate = block.getDefaultState().withProperty(BlockInfoPoster.FACING, facing);
final IBlockState iBlockExtendedState = block.getExtendedState(iblockstate, clientWorld, pos);
final IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(iblockstate);
final TileEntityInfoPoster sign = new TileEntityInfoPoster();
sign.setPos(pos);
for (int i = 0; i < sign.signText.length; i++) {
if (i < citizenDataView.getLatestStatus().length) {
sign.signText[i] = citizenDataView.getLatestStatus()[i];
}
}
final ModelHolder models = new ModelHolder(pos, iblockstate, iBlockExtendedState, sign, ibakedmodel);
Structure.getQuads(models, models.quads);
new Structure(Minecraft.getMinecraft().world).renderGhost(clientWorld, models, player, partialTicks, false);
}
use of com.minecolonies.structures.helpers.Structure in project minecolonies by Minecolonies.
the class RenderEventHandler method onRenderWorldLast.
/**
* Event used to render the schematics. Only render the schematic if there is one in the settings.
*
* @param event Object containing event details.
*/
@SubscribeEvent
public void onRenderWorldLast(final RenderWorldLastEvent event) {
final Structure structure = Settings.instance.getActiveStructure();
if (structure != null) {
BlockPos size = structure.getSize(BlockUtils.getRotation(Settings.instance.getRotation()));
BlockPos position = Settings.instance.getPosition();
final int x = size.getX();
final int z = size.getZ();
final int y = size.getY();
if (Settings.instance.getRotation() == 1) {
size = new BlockPos(-x, y, z);
}
if (Settings.instance.getRotation() == 2) {
size = new BlockPos(-x, y, -z);
}
if (Settings.instance.getRotation() == 3) {
size = new BlockPos(x, y, -z);
}
final BlockPos offset = Settings.instance.getOffset(new PlacementSettings().setRotation(BlockUtils.getRotation(Settings.instance.getRotation())).setMirror(Settings.instance.getMirror()));
if (offset.equals(new BlockPos(0, 0, 0))) {
position = position.subtract(new BlockPos(size.getX() / 2, 0, size.getZ() / 2));
} else {
position = position.subtract(offset);
}
structure.renderStructure(position, Minecraft.getMinecraft().world, Minecraft.getMinecraft().player, event.getPartialTicks());
}
}
use of com.minecolonies.structures.helpers.Structure in project minecolonies by Minecolonies.
the class WindowBuildTool method changeSchematic.
/*
* ---------------- Miscellaneous ----------------
*/
/**
* Changes the current structure.
* Set to button position at that time
*/
private void changeSchematic() {
final String sname;
if (Settings.instance.isStaticSchematicMode()) {
sname = Settings.instance.getStaticSchematicName();
} else {
sname = schematics.get(schematicsDropDownList.getSelectedIndex());
}
final StructureName structureName = new StructureName(sname);
final Structure structure = new Structure(null, structureName.toString(), new PlacementSettings().setRotation(BlockUtils.getRotation(Settings.instance.getRotation())).setMirror(Settings.instance.getMirror()));
final String md5 = Structures.getMD5(structureName.toString());
if (structure.isTemplateMissing() || !structure.isCorrectMD5(md5)) {
if (structure.isTemplateMissing()) {
Log.getLogger().info("Template structure " + structureName + " missing");
} else {
Log.getLogger().info("structure " + structureName + " md5 error");
}
Log.getLogger().info("Request To Server for structure " + structureName);
if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) {
MineColonies.getNetwork().sendToServer(new SchematicRequestMessage(structureName.toString()));
return;
} else {
Log.getLogger().error("WindowBuildTool: Need to download schematic on a standalone client/server. This should never happen");
}
}
Settings.instance.setStructureName(structureName.toString());
Settings.instance.setActiveSchematic(structure);
if (Settings.instance.getPosition() == null) {
Settings.instance.setPosition(this.pos);
}
}
use of com.minecolonies.structures.helpers.Structure in project minecolonies by Minecolonies.
the class ClientEventHandler method renderWorldLastEvent.
/**
* Used to catch the renderWorldLastEvent in order to draw the debug nodes for pathfinding.
*
* @param event the catched event.
*/
@SubscribeEvent
public void renderWorldLastEvent(@NotNull final RenderWorldLastEvent event) {
Pathfinding.debugDraw(event.getPartialTicks());
final Structure structure = Settings.instance.getActiveStructure();
final WorldClient world = Minecraft.getMinecraft().world;
final EntityPlayer player = Minecraft.getMinecraft().player;
if (structure != null) {
final BlockPos position = Settings.instance.getPosition();
if (Settings.instance.getStructureName().contains(AbstractEntityAIStructure.WAYPOINT_STRING)) {
RenderUtils.renderWayPoints(position, world, event.getPartialTicks());
} else {
RenderUtils.renderColonyBorder(position, world, event.getPartialTicks(), player, colonyBorder);
}
return;
} else {
if (citizen != null) {
final Entity entityCitizen = world.getEntityByID(citizen.getEntityId());
if (entityCitizen instanceof EntityCitizen) {
RenderUtils.renderSigns(world, event.getPartialTicks(), citizen, player, entityCitizen.getPosition());
ticksPassed += event.getPartialTicks();
if (ticksPassed > Constants.TICKS_SECOND * SECONDS_TO_SHOW) {
ticksPassed = 0;
citizen = null;
}
} else {
citizen = null;
ticksPassed = 0;
}
return;
}
final ColonyView colony = ColonyManager.getClosestColonyView(world, player.getPosition());
if (colony != null && player != null && colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
for (final CitizenDataView citizenDataView : new ArrayList<CitizenDataView>(colony.getCitizens().values())) {
final Entity entityCitizen = world.getEntityByID(citizenDataView.getEntityId());
if (entityCitizen instanceof EntityCitizen && entityCitizen.getPosition().distanceSq(player.getPosition()) <= 2) {
RenderUtils.renderSigns(world, event.getPartialTicks(), citizenDataView, player, entityCitizen.getPosition());
citizen = citizenDataView;
return;
}
}
}
}
colonyBorder.clear();
}
use of com.minecolonies.structures.helpers.Structure in project minecolonies by Minecolonies.
the class WindowBuildTool method init.
private void init(final BlockPos pos) {
@Nullable final Structure structure = Settings.instance.getActiveStructure();
if (structure != null) {
rotation = Settings.instance.getRotation();
} else if (pos != null) {
this.pos = pos;
Settings.instance.setPosition(pos);
Settings.instance.setRotation(0);
}
initBuildingTypeNavigation();
initStyleNavigation();
initSchematicNavigation();
// Register all necessary buttons with the window.
registerButton(BUTTON_CONFIRM, this::confirmClicked);
registerButton(BUTTON_CANCEL, this::cancelClicked);
registerButton(BUTTON_LEFT, this::moveLeftClicked);
registerButton(BUTTON_MIRROR, WindowBuildTool::mirror);
registerButton(BUTTON_RIGHT, this::moveRightClicked);
registerButton(BUTTON_BACKWARD, this::moveBackClicked);
registerButton(BUTTON_FORWARD, this::moveForwardClicked);
registerButton(BUTTON_UP, WindowBuildTool::moveUpClicked);
registerButton(BUTTON_DOWN, WindowBuildTool::moveDownClicked);
registerButton(BUTTON_ROTATE_RIGHT, this::rotateRightClicked);
registerButton(BUTTON_ROTATE_LEFT, this::rotateLeftClicked);
registerButton(BUTTON_PASTE, this::pasteComplete);
registerButton(BUTTON_PASTE_NICE, this::pasteNice);
registerButton(BUTTON_RENAME, this::renameClicked);
registerButton(BUTTON_DELETE, this::deleteClicked);
}
Aggregations