Skip to content

Commit

Permalink
Fix snow catcher bug
Browse files Browse the repository at this point in the history
  • Loading branch information
UnRealDinnerbone committed Aug 4, 2024
1 parent caeba08 commit 0e3275b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### 1.0.4
### 1.0.5

- Fix Mixin Debug Issue
- Fix Place Block snow cathcer
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project
mod_version=1.0.4
mod_version=1.0.5
maven_group=com.unrealdinnerbone
curse_id=1048090
mod_name=WeatherGate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import com.unrealdinnerbone.weathergate.data.WeatherGateData;
import com.unrealdinnerbone.weathergate.events.ServerEvents;
import com.unrealdinnerbone.weathergate.network.WeatherGateNetwork;
import net.minecraft.util.ExtraCodecs;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs;
import net.neoforged.neoforge.event.RegisterCommandsEvent;

@Mod(WeatherGate.MOD_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public SnowCatcherBlock() {
super(Properties.of().mapColor(MapColor.SNOW).requiresCorrectToolForDrops().strength(5f).sound(SoundType.SNOW));
}


@Override
public void setPlacedBy(Level level, BlockPos blockPos, BlockState blockState, @Nullable LivingEntity livingEntity, ItemStack itemStack) {
protected void onPlace(BlockState state, Level level, BlockPos blockPos, BlockState blockState, boolean update) {
if(level instanceof ServerLevel serverLevel) {
SnowCatcherAttachment.addBlockPos(serverLevel, blockPos);
}
super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MapColor;
import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.Nullable;

public class SunInABoxBlock extends Block {

Expand All @@ -23,12 +20,12 @@ public SunInABoxBlock() {
}

@Override
public void setPlacedBy(Level level, BlockPos blockPos, BlockState blockState, @Nullable LivingEntity livingEntity, ItemStack itemStack) {
public void onPlace(BlockState newState, Level level, BlockPos blockPos, BlockState oldState, boolean pistonMoved) {
if(level instanceof ServerLevel serverLevel) {
SunInABlockAttachment.addBlockPos(serverLevel, blockPos);
PacketDistributor.sendToPlayersInDimension(serverLevel, new UpdateSunInABoxPosPacket(new GlobalPos(level.dimension(), blockPos), UpdateSunInABoxPosPacket.UpdateType.ADD));
}
super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack);
super.onPlace(newState, level, blockPos, oldState, pistonMoved);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
Expand Down Expand Up @@ -75,12 +76,15 @@ public MySimpleButton(Panel panel, Type value, Color4I[] activeValue) {
super(panel, value.getComponent(), value.getIcon(), (button, mouseButton) -> {
ColorConfig config = new ColorConfig();
config.setValue(activeValue[0]);
ColorSelectorPanel colorSelectorPanel = ColorSelectorPanel.popupAtMouse(TerrainControllerScreen2.this, config, (accepted) -> {
ColorSelectorPanel colorSelectorPanel = new ColorSelectorPanel(TerrainControllerScreen2.this, config, (accepted) -> {
if(accepted) {
activeValue[0] = config.getValue();
PacketDistributor.sendToServer(new UpdateControllerPacket(GlobalPos.of(Minecraft.getInstance().player.level().dimension(), TerrainControllerScreen2.this.blockPos), Map.of(value, config.getValue())));
}
});
colorSelectorPanel.setPos(TerrainControllerScreen2.this.width / 2 - colorSelectorPanel.width / 2, TerrainControllerScreen2.this.width / 2 - colorSelectorPanel.height / 2);
colorSelectorPanel.setAllowAlphaEdit(config.isAllowAlphaEdit());
colorSelectorPanel.getGui().pushModalPanel(colorSelectorPanel);
colorSelectorPanel.setAllowAlphaEdit(false);
colorSelectorPanel.setExtraZlevel(100);
});
Expand Down

0 comments on commit 0e3275b

Please sign in to comment.