use of net.minecraft.util.crash.CrashReport in project fabric by FabricMC.
the class MixinSpriteAtlasTexture method beforeSpriteLoad.
// Handles DependentSprite + custom sprite object injections.
@ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/SpriteAtlasTexture;loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;"), method = "stitch")
public Set<Identifier> beforeSpriteLoad(Set<Identifier> set) {
fabric_injectedSprites = new HashMap<>();
ClientSpriteRegistryCallback.Registry registry = new ClientSpriteRegistryCallback.Registry(fabric_injectedSprites, set::add);
// noinspection ConstantConditions
for (Identifier id : fabric_localIds) {
SpriteRegistryCallbackHolder.eventLocal(id).invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
}
SpriteRegistryCallbackHolder.EVENT_GLOBAL.invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
// TODO: Unoptimized.
Set<DependentSprite> dependentSprites = new HashSet<>();
Set<Identifier> dependentSpriteIds = new HashSet<>();
for (Identifier id : set) {
Sprite sprite;
if ((sprite = fabric_injectedSprites.get(id)) instanceof DependentSprite) {
dependentSprites.add((DependentSprite) sprite);
dependentSpriteIds.add(id);
}
}
Set<Identifier> result = set;
boolean isResultNew = false;
if (!dependentSprites.isEmpty()) {
if (!isResultNew) {
result = new LinkedHashSet<>();
isResultNew = true;
}
for (Identifier id : set) {
if (!dependentSpriteIds.contains(id)) {
result.add(id);
}
}
int lastSpriteSize = 0;
while (lastSpriteSize != result.size() && result.size() < set.size()) {
lastSpriteSize = result.size();
for (DependentSprite sprite : dependentSprites) {
Identifier id = ((Sprite) sprite).getId();
if (!result.contains(id) && result.containsAll(sprite.getDependencies())) {
result.add(id);
}
}
}
if (result.size() < set.size()) {
CrashReport report = CrashReport.create(new Throwable(), "Resolving sprite dependencies");
for (DependentSprite sprite : dependentSprites) {
Identifier id = ((Sprite) sprite).getId();
if (!result.contains(id)) {
CrashReportSection element = report.addElement("Unresolved sprite");
element.add("Sprite", id);
element.add("Dependencies", Joiner.on(',').join(sprite.getDependencies()));
}
}
throw new CrashException(report);
}
}
if (!fabric_injectedSprites.isEmpty()) {
if (!isResultNew) {
result = new LinkedHashSet<>(set);
isResultNew = true;
}
result.removeAll(fabric_injectedSprites.keySet());
}
return result;
}
use of net.minecraft.util.crash.CrashReport in project fabric by FabricMC.
the class TerrainRenderContext method tesselateBlock.
/**
* Called from chunk renderer hook.
*/
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model) {
try {
aoCalc.clear();
blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
chunkInfo.beginBlock();
((FabricBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
} catch (Throwable var9) {
CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Indigo Renderer");
CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
throw new CrashException(crashReport_1);
}
return chunkInfo.resultFlags[blockInfo.defaultLayerIndex];
}
use of net.minecraft.util.crash.CrashReport in project databreaker by SuperCoder7979.
the class Databreaker method onInitialize.
@Override
public void onInitialize() {
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
logger.info("I am become Databreaker, destroyer of loading times");
} else {
// Congrats on making it this far, use -Ddatabreaker.i_accept_responsibility_for_my_actions=true to have a chance of screwing up your world.
if (System.getProperty("databreaker.i_accept_responsibility_for_my_actions", "false").equals("true")) {
logger.warn("SUPERCODER79 IS NOT RESPONSIBLE FOR ANY DAMAGE CAUSED BY USING DATABREAKER IN A PRODUCTION ENVIRONMENT.");
logger.warn("THERE IS A GOOD CHANCE THAT YOUR GAME WILL BE COMPLETELY SCREWED UP IF YOU LOAD UP A WORLD WITHOUT OPTIMIZING.");
logger.warn("DO NOT USE DATABREAKER IN A NON-DEVELOPMENT ENVIRONMENT.");
} else {
// Please don't do it.
throw new CrashException(new CrashReport("Do not use DataBreaker in a production environment.", new RuntimeException()));
}
}
}
use of net.minecraft.util.crash.CrashReport in project Wurst7 by Wurst-Imperium.
the class CmdProcessor method runCmd.
private void runCmd(Command cmd, String input) {
String[] args = input.split(" ");
args = Arrays.copyOfRange(args, 1, args.length);
try {
cmd.call(args);
} catch (CmdException e) {
e.printToChat(cmd);
} catch (Throwable e) {
CrashReport report = CrashReport.create(e, "Running Wurst command");
CrashReportSection section = report.addElement("Affected command");
section.add("Command input", () -> input);
throw new CrashException(report);
}
}
use of net.minecraft.util.crash.CrashReport in project Wurst7 by Wurst-Imperium.
the class EventManager method fireImpl.
private <L extends Listener, E extends Event<L>> void fireImpl(E event) {
if (!wurst.isEnabled())
return;
try {
Class<L> type = event.getListenerType();
@SuppressWarnings("unchecked") ArrayList<L> listeners = (ArrayList<L>) listenerMap.get(type);
if (listeners == null || listeners.isEmpty())
return;
// Creating a copy of the list to avoid concurrent modification
// issues.
ArrayList<L> listeners2 = new ArrayList<>(listeners);
// remove() sets an element to null before removing it. When one
// thread calls remove() while another calls fire(), it is possible
// for this list to contain null elements, which need to be filtered
// out.
listeners2.removeIf(Objects::isNull);
event.fire(listeners2);
} catch (Throwable e) {
e.printStackTrace();
CrashReport report = CrashReport.create(e, "Firing Wurst event");
CrashReportSection section = report.addElement("Affected event");
section.add("Event class", () -> event.getClass().getName());
throw new CrashException(report);
}
}
Aggregations