Few fixes for the Forge version.

This commit is contained in:
Matthew Miller 2019-03-26 21:09:41 +10:00
parent 8eccdc7444
commit 4629c1f7e4
7 changed files with 55 additions and 20 deletions

View File

@ -187,8 +187,9 @@ public class ForgeWorld extends AbstractWorld {
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Implement
return false;
BlockPos pos = new BlockPos(position.getX(), position.getY(), position.getZ());
getWorld().notifyBlockUpdate(pos, ForgeAdapter.adapt(previousType), getWorld().getBlockState(pos), 1 | 2);
return true;
}
@Override

View File

@ -31,6 +31,9 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.forge.net.handler.InternalPacketHandler;
import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage;
import com.sk89q.worldedit.forge.proxy.ClientProxy;
import com.sk89q.worldedit.forge.proxy.CommonProxy;
import com.sk89q.worldedit.forge.proxy.ServerProxy;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
@ -89,7 +92,7 @@ public class ForgeWorldEdit {
public static ForgeWorldEdit inst;
public static CommonProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
public static CommonProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
private ForgePlatform platform;
private ForgeConfiguration config;

View File

@ -41,7 +41,7 @@ public class KeyHandler {
if (mc.player != null && mc.world != null && mainKey.isPressed()) {
mc.displayGuiScreen(new GuiReferenceCard());
// TODO Seems GuiHandlers don't work on client right now
// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(CommonProxy.REFERENCE_GUI));
// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(ServerProxy.REFERENCE_GUI));
}
}

View File

@ -23,8 +23,11 @@ import com.sk89q.worldedit.forge.ForgeWorldEdit;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;
@OnlyIn(Dist.CLIENT)
public class GuiReferenceCard extends GuiScreen {
private GuiButton closeButton;

View File

@ -17,15 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.proxy;
import com.sk89q.worldedit.forge.KeyHandler;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
public class ClientProxy extends CommonProxy {
@OnlyIn(Dist.CLIENT)
public class ClientProxy implements CommonProxy {
@Override
public void registerHandlers() {
super.registerHandlers();
MinecraftForge.EVENT_BUS.register(new KeyHandler());
}

View File

@ -0,0 +1,25 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge.proxy;
public interface CommonProxy {
void registerHandlers();
}

View File

@ -17,24 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.proxy;
import com.sk89q.worldedit.forge.gui.GuiReferenceCard;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class CommonProxy {
@OnlyIn(Dist.DEDICATED_SERVER)
public class ServerProxy implements CommonProxy {
public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui");
// public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui");
@Override
public void registerHandlers() {
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> {
if (openContainer.getId().equals(REFERENCE_GUI)) {
return new GuiReferenceCard();
}
return null;
});
// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> {
// if (openContainer.getId().equals(REFERENCE_GUI)) {
// return new GuiReferenceCard();
// }
// return null;
// });
}
}