Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Jul 5, 2024
1 parent b26941a commit a98957b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.google.gson.JsonObject;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.BlockStateComponent;
import org.thinkingstudio.ryoamiclights.RyoamicLights;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -97,7 +98,7 @@ public String toString() {
return Optional.empty();
}

var affectId = Identifier.of(json.get("item").getAsString());
var affectId = Identifier.tryParse(json.get("item").getAsString());
var item = Registries.ITEM.get(affectId);

if (item == Items.AIR)
Expand Down Expand Up @@ -164,21 +165,10 @@ public int getLuminance(ItemStack stack) {
}

static int getLuminance(ItemStack stack, BlockState state) {
var nbt = stack.getComponents();

if (nbt != null) {
var blockStateTag = nbt.get(DataComponentTypes.BLOCK_STATE);
var stateManager = state.getBlock().getStateManager();

if (blockStateTag != null) {
for (var key : blockStateTag.properties().keySet()) {
var property = stateManager.getProperty(key);
if (property != null) {
var value = blockStateTag.properties().get(key);
state = with(state, property, value);
}
}
}
var nbt = stack.getComponents().getOrDefault(DataComponentTypes.BLOCK_STATE, BlockStateComponent.DEFAULT);

if (!nbt.isEmpty()) {
state = nbt.applyToState(state);
}

return state.getLuminance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package org.thinkingstudio.ryoamiclights.mixin.lightsource;

import net.minecraft.entity.decoration.BlockAttachedEntity;
import org.thinkingstudio.ryoamiclights.DynamicLightSource;
import org.thinkingstudio.ryoamiclights.RyoamicLights;
import org.thinkingstudio.ryoamiclights.api.DynamicLightHandlers;
Expand All @@ -19,29 +18,28 @@
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AbstractDecorationEntity.class)
public abstract class AbstractDecorationEntityMixin extends Entity implements DynamicLightSource {
public AbstractDecorationEntityMixin(EntityType<?> type, World world) {
super(type, world);
}

// @Inject(method = "tick", at = @At("TAIL"))
// private void onTick(CallbackInfo ci) {
// // We do not want to update the entity on the server.
// if (this.getWorld().isClient()) {
// if (this.isRemoved()) {
// this.ryoamicLights$setDynamicLightEnabled(false);
// } else {
// if (!RyoamicLights.get().config.getEntitiesLightSource().get() || !DynamicLightHandlers.canLightUp(this))
// this.ryoamicLights$resetDynamicLight();
// else
// this.ryoamicLights$dynamicLightTick();
// RyoamicLights.updateTracking(this);
// }
// }
// }
@Override
public void tick() {
super.tick();

// We do not want to update the entity on the server.
if (this.getWorld().isClient()) {
if (this.isRemoved()) {
this.ryoamicLights$setDynamicLightEnabled(false);
} else {
if (!RyoamicLights.get().config.getEntitiesLightSource().get() || !DynamicLightHandlers.canLightUp(this))
this.ryoamicLights$resetDynamicLight();
else
this.ryoamicLights$dynamicLightTick();
RyoamicLights.updateTracking(this);
}
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion common/src/main/resources/ryoamiclights.common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"EntityTypeMixin",
"MinecraftClientMixin",
"WorldMixin",
"lightsource.AbstractDecorationEntityMixin",
"lightsource.AbstractMinecartEntityMixin",
"lightsource.BlockAttachedEntityMixin",
"lightsource.BlockEntityMixin",
"lightsource.EntityMixin",
"lightsource.ExplosiveProjectileEntityMixin",
Expand Down

0 comments on commit a98957b

Please sign in to comment.